Proxy Connect — File Browser

ProxyConnectv2.0 / ProxyConnectv2.0 / sxProxyConnect.mrc

sxProxyConnect.mrc — 10.19 KB — Download this file

;---------<  Simple Script  >------------
; Filename..: sxProxyConnect.mrc  [Connection]
; Release...: v2.0
; Author....: sprion
; Bugreport.: sprion@lyniq.com
; Date......: July 29th, 2004
; URL.......: www.mircscripts.org
;-------------------------------------------------------

; to use, type:
;   /pc.dialog
; *OR*
;   /pc.connect - for command line version

; on failed/weird connection type:
   /pc.next - to try next proxy

; when connection is good, it's best to type
;   /pc.end
; to end things, unless you want to try the next proxy
; when your irc server disconnects

; ------------
alias -l iecho {
  var %tmp.let = $1, %tmp.let2 = $mid(%tmp.let,1,1), %tmp.let3 =  $+ $gettok(4 7 12 13 5,$rand(1,5),32) $+ ,14]1,14 $+ $upper(%tmp.let2) $+  $+ 0,14 $+ $mid(%tmp.let,2,$len(%tmp.let)) $+ 1,15
  if @* iswm $2 {
    var %c = $3-
    echo -ta %tmp.let3 %c
  }
  else {
    var %c = $2-
    echo -t [ $+ [ $iif(@* iswm $active,s,a) ] $+ ] i2 %tmp.let3 %c
  }
  flash $strip($1) $strip(%c)
}
alias -l pc.file return $+(",$scriptdir,proxy.txt,")
alias -l pc.file2 return $+(",$scriptdir,proxy_tested.txt,")
alias pc.edit run $pc.file
alias pc.connect {
  sockclose pc.* | pc.end -s
  pc.addcid $cid
  if ((!$1) || ($0 < 3)) { iecho usage: '/pc.connect [-mh45] <server:port> <timeoutinsecs>' | iecho more: m - new server window, h - HTTP, 4 - SOCKS4, 5 - SOCKS5, specifies the types to use. | halt }
  %pc.server = $gettok($2,1,58)
  %pc.port = $gettok($2,2,58)
  %pc.timeout = $3
  %pc.typeallowed = $1
  if !$exists($pc.file) { iecho error: no proxy list found in $scriptdir (proxy.txt) | halt }
  var %i = $lines($pc.file), %c = 0, %r = $null, %t = 0
  %r = $read($pc.file, s, [http])
  %pc.httpline = $readn
  %r = $read($pc.file, s, [socks4])
  %pc.socks4line = $readn
  %r = $read($pc.file, s, [socks5])
  %pc.socks5line = $readn
  write -c $pc.file2
  while %c < %i {
    inc %c
    if (%c > %pc.httpline) %pc.current.type = h
    if (%c > %pc.socks4line) %pc.current.type = 4
    if (%c > %pc.socks5line) %pc.current.type = 5
    if (%pc.current.type !isin %pc.typeallowed) continue
    %r = $read($pc.file,%c)
    if ((%r = [http]) || (%r = [socks4]) || (%r = [socks5]) || (*.*.*.*:* !iswm $gettok(%r,1,32))) continue
    inc %t
    sockopen $+(pc.,%c) $gettok($gettok(%r,1,32),1,58) $gettok($gettok(%r,1,32),2,58)
  }
  if ($dialog(pcdialog)) {
    pc.d.msg Testing %t proxies' speed.. Timeout %pc.timeout secs.
    .timerpc.countdown %pc.timeout 1 pc.d.msg Testing %t proxies' speed.. Timeout $!timer(pc.close).secs secs.
  }
  else {
    iecho notice: Testing %t proxies' speed (reaction)..
    iecho notice: Opening connections.. Timeout %pc.timeout secs. Please wait..
  }
  .timerpc.close 1 %pc.timeout sockclose pc.*
  .timerpc.begin 1 $calc(%pc.timeout + 1) pc.begin
}
alias pc.next {
  if (!$istok($pc.getcid,$cid,44)) return
  inc %pc.current
  var %r = $null
  %r = $read($pc.file2,%pc.current)
  if (*.*.*.*:* iswm $gettok(%r,2,32)) {
    $iif($dialog(pcdialog),pc.d.msg,iecho notice:) Using firewall $+($chr(40), %pc.current of %pc.walls ,$chr(41)) - $gettok(%r,2,32) $pc.type($gettok(%r,1,32))
    firewall $+(-m,$gettok(%r,1,32),+d) on $gettok($gettok(%r,2,32),1,58) $gettok($gettok(%r,2,32),2,58) $gettok(%r,3,32) $gettok(%r,4,32)
    if ($server) {
      %pc.ignoredc = 1
      disconnect
      %pc.ignoredc = 0
    }
    server $iif(-*m* iswm %pc.typeallowed,-m) %pc.server %pc.port
    %pc.used = $gettok(%r,2,32) $pc.type($gettok(%r,1,32))
    .enable #pc.check
    .timerpc.next 1 %pc.timeout pc.next
  }
  if (%pc.current = %pc.walls) $iif($dialog(pcdialog),pc.d.msg,iecho notice:) Trying last proxy..
  else editbox /pc.next
}
alias -l pc.addcid %pc.cid = $addtok(%pc.cid,$cid,44)
alias -l pc.getcid return %pc.cid
alias -l pc.begin {
  %pc.walls = $lines($pc.file2)
  %pc.current = 0
  pc.next
}
alias -l pc.type if $1 = p return (HTTP) | elseif $1 = 4 return (SOCKS4) | elseif $1 = 5 return (SOCKS5)
alias -l pc.clear {
  $iif($dialog(pcdialog),pc.d.msg,iecho notice:) Successfully connected with $ord(%pc.current) firewall - %pc.used
  iecho notice: To try next firewall - /pc.next , to end, /pc.end
  ;  unset %pc.*
  .timerpc.* off
  .disable #pc.check
}
alias pc.end {
  if (!$istok($pc.getcid,$cid,44)) return
  .timerpc.* off | unset %pc.* | .disable #pc.check
  if ($1 != -s) $iif($dialog(pcdialog),pc.d.msg,iecho notice:) Ended sxProxyConnect prematurely.
}
on *:sockopen:pc.*:{
  if (!$istok($pc.getcid,$cid,44)) return
  if ($sockerr) return
  var %snum = $gettok($sockname,2,$asc(.))
  if (%snum > %pc.httpline) %pc.sock.type = p
  if (%snum > %pc.socks4line) %pc.sock.type = 4
  if (%snum > %pc.socks5line) %pc.sock.type = 5
  write $pc.file2 %pc.sock.type $read($pc.file, %snum)
  sockclose $sockname
  if ($lines($pc.file) = %snum) { $iif($dialog(pcdialog),pc.d.msg,iecho notice:) Incredible proxies! All responded before %pc.timeout s | .timerpc.begin off | pc.begin }
}
#pc.check off
on *:DISCONNECT:{
  if (!$istok($pc.getcid,$cid,44)) return
  if (%pc.ignoredc) return
  if (%pc.current = %pc.walls) { $iif($dialog(pcdialog),pc.d.msg,iecho notice:) All proxies and connections failed. | pc.end -s }
  else { $iif($dialog(pcdialog),pc.d.msg,iecho notice:) Disconnected server. Continuing to next proxy.. | pc.next }
}
on *:CONNECTFAIL:{
  if (!$istok($pc.getcid,$cid,44)) return
  if (%pc.current = %pc.walls) { $iif($dialog(pcdialog),pc.d.msg,iecho notice:) All proxies and connections failed. | pc.end -s }
  else pc.next
}
on *:connect:if ($istok($pc.getcid,$cid,44)) pc.clear
#pc.check end
alias pc.savedialog {
  write -c $pc.file
  var %z = write $pc.file
  %z lastserver $did($1,15)
  %z timeout $did($1,26)
  %z newserverwin $did($1,17).state
  %z usehttp $did($1,18).state
  %z usesocks4 $did($1,19).state
  %z usesocks5 $did($1,20).state
  %z ;begin proxies
  var %b = 1-9-12,%t = [http]-[socks4]-[socks5],%n1 = 1
  while ($gettok(%b,%n1,45)) {
    %z $gettok(%t,%n1,45)
    var %p = $didtok($1,$ifmatch,44), %n = 1
    while ($gettok(%p,%n,44)) {
      %z $ifmatch
      inc %n
    }
    inc %n1
  }
  unset %d.pc.doit
}
alias pc.d.msg did -a pcdialog 23 $1-
alias pc.dialog dialog -m pcdialog pcdialog
dialog pcdialog {
  title "sxProxyConnect v2.0 by sprion"
  size -1 -1 170 150
  option dbu
  box "Proxies List", 4, 4 56 163 82
  combo 1, 9 75 153 50, size vsbar
  button "+", 5, 136 124 13 12
  button "-", 6, 149 124 13 12
  box "Connect and GO!", 14, 4 2 163 54
  edit "", 15, 10 17 87 10
  text "Server:Port", 16, 11 10 32 7
  check "new server window", 17, 102 17 57 9
  check "use HTTP proxies", 18, 102 27 53 9
  check "use SOCKS4 proxies", 19, 102 36 61 9
  check "use SOCKS5", 20, 102 45 50 9
  button "Anonymise me!", 21, 43 29 53 24
  box "", 22, -5 138 214 16
  text "Idle", 23, 5 143 161 7
  radio "View HTTP", 2, 9 65 37 10
  radio "View SOCKS4", 3, 58 65 44 10
  radio "View SOCKS5", 7, 116 65 44 10
  text "i.e. 127.0.0.1:8080 [username] [password]", 8, 10 125 108 8, disable
  combo 9, 9 75 153 50, hide size vsbar
  button "+", 10, 136 124 13 12, hide
  button "-", 11, 149 124 13 12, hide
  combo 12, 9 75 153 50, hide size vsbar
  button "+", 13, 136 124 13 12, hide
  button "-", 24, 149 124 13 12, hide
  text "Timeout", 25, 11 35 25 7
  edit "", 26, 10 42 30 10
  button "Open Config", 27, 123 7 37 8
}
on *:dialog:pcdialog:*:*:{
  if ($devent = init) {
    %d.pc.save = 15,17,18,19,20,13,24,5,10,6,11,26
    %d.pc.doit = 0
    did -c pcdialog 2
    if $exists($pc.file) {
      var %i = $lines($pc.file), %c = 0, %r = $null, %t = 0
      
      %r = $read($pc.file, s, lastserver)
      if (%r) did -a pcdialog 15 $ifmatch
      
      %r = $read($pc.file, s, timeout)
      if (%r) did -a pcdialog 26 $ifmatch
      
      %r = $read($pc.file, s, newserverwin)
      if (%r) did -c pcdialog 17
      %r = $read($pc.file, s, usehttp)
      if (%r) did -c pcdialog 18
      %r = $read($pc.file, s, usesocks4)
      if (%r) did -c pcdialog 19
      %r = $read($pc.file, s, usesocks5)
      if (%r) did -c pcdialog 20
      
      
      %r = $read($pc.file, s, [http])
      var %p = $readn
      %r = $read($pc.file, s, [socks4])
      var %4 = $readn
      %r = $read($pc.file, s, [socks5])
      var %5 = $readn
      while %c < %i {
        inc %c
        if (%c > %p) %d = 1
        if (%c > %4) %d = 9
        if (%c > %5) %d = 12
        %r = $read($pc.file,%c)
        if ((%r = [http]) || (%r = [socks4]) || (%r = [socks5]) || (*.*.*.*:* !iswm $gettok(%r,1,32))) continue
        inc %t
        did -a pcdialog %d %r
      }
    }
    if (!$did(26)) did -a pcdialog 26 10
    did -f pcdialog 15
  }
  elseif $devent = sclick {
    if ($istok(%d.pc.save,$did,44)) %d.pc.doit = 1
    if (($did = 2) && ($did(2).state)) { did -v pcdialog 1,5,6 | did -h pcdialog 9,10,11,12,13,24 }
    elseif (($did = 3) && ($did(3).state)) { did -v pcdialog 9,10,11 | did -h pcdialog 1,5,6,12,13,24 }
    elseif (($did = 7) && ($did(7).state)) { did -v pcdialog 12,13,24 | did -h pcdialog 1,5,6,9,10,11 }
    elseif ($did = 5) && ($did(1)) { did -a pcdialog 1 $did(1) | did -c pcdialog 1 }
    elseif ($did = 10) && ($did(9)) { did -a pcdialog 9 $did(9) | did -c pcdialog 9 }
    elseif ($did = 13) && ($did(12)) { did -a pcdialog 12 $did(12) | did -c pcdialog 12 }
    elseif ($did = 6) && $did(1,1).sel { did -d pcdialog 1 $ifmatch }
    elseif ($did = 11) && $did(9,1).sel { did -d pcdialog 9 $ifmatch }
    elseif ($did = 24) && $did(12,1).sel { did -d pcdialog 12 $ifmatch }
    elseif ($did = 27) pc.edit
    elseif ($did = 21) {
      if (!$exists($pc.file)) pc.savedialog $dname
      if ($did(15)) {
        var %touse = -
        if ($did(17).state) %touse = %touse $+ m
        if ($did(18).state) %touse = %touse $+ h
        if ($did(19).state) %touse = %touse $+ 4
        if ($did(20).state) %touse = %touse $+ 5
        pc.connect %touse $did(15) $iif($did(26),$did(26),10)
      }
    }
  }
  elseif $devent = edit {
    if ($istok(%d.pc.save,$did,44)) %d.pc.doit = 1
  }
  elseif $devent = close {
    if ((%d.pc.doit) && ($input(Would you like to save the changes?,yq,Save Configuration))) {
      pc.savedialog $dname
    }
    unset %d.pc.*
  }
}