diff options
author | d3v11 <d3v11@d3v11.ano> | 2012-11-04 16:42:44 +0000 |
---|---|---|
committer | d3v11 <d3v11@d3v11.ano> | 2012-11-04 16:42:44 +0000 |
commit | 74ae7ca47a6c65362fc119c3b8b3c45a68fdf3d0 (patch) | |
tree | ab1670a4ef507c6aaffeed98560b4375fc0e15fd /contrib | |
parent | fbdb1f2e4764d7a120f0885c6234fd1cbbd72ccd (diff) | |
download | resdb-74ae7ca47a6c65362fc119c3b8b3c45a68fdf3d0.tar.gz resdb-74ae7ca47a6c65362fc119c3b8b3c45a68fdf3d0.zip |
[quicktun.socks4a] more simple
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/quicktun.socks4a/quicktun.socks4a | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/contrib/quicktun.socks4a/quicktun.socks4a b/contrib/quicktun.socks4a/quicktun.socks4a index 6aa6733..c6f4fdc 100755 --- a/contrib/quicktun.socks4a/quicktun.socks4a +++ b/contrib/quicktun.socks4a/quicktun.socks4a @@ -28,9 +28,11 @@ udp_poll.register (udp.fileno(),select.POLLIN|select.POLLPRI) if REMOTE_FLOAT==0: tun = subprocess.Popen ( - [ 'socat','stdio','socks4a:'+SOCKS_ADDRESS+':' - +DST_ADDRESS+':'+DST_PORT - +',socksport='+SOCKS_PORT + [ 'socat', + 'STDIO', + 'SOCKS4A:' + +SOCKS_ADDRESS+':'+DST_ADDRESS+':'+DST_PORT + +',SOCKSPORT='+SOCKS_PORT, ], stdout = subprocess.PIPE, stdin = subprocess.PIPE, ) @@ -41,23 +43,21 @@ if REMOTE_FLOAT==0: tun.stdout.fileno(),select.POLLIN|select.POLLPRI) if REMOTE_FLOAT==1: - tcp = socket.socket ( - socket.AF_INET,socket.SOCK_STREAM) - tcp.setsockopt (socket.SOL_SOCKET,socket.SO_REUSEADDR,1) - tcp.setblocking (0) - tcp.bind ((LOCAL_ADDRESS,LOCAL_PORT)) - tcp.listen (1) - tcp_poll = select.poll () - tcp_poll.register (tcp.fileno(),select.POLLIN|select.POLLPRI) - - while len(tcp_poll.poll(65536))>0: - tun = tcp.accept ()[0] - tun_stdout = tun.fileno () - tun_stdin = tun.fileno () - tun_poll = select.poll () - tun_poll.register ( - tun.fileno(),select.POLLIN|select.POLLPRI) - break + tun = subprocess.Popen ( + [ 'socat', + 'TCP-LISTEN:' + +str(LOCAL_PORT)+',BIND='+LOCAL_ADDRESS + +',REUSEADDR', + 'UDP-CONNECT:'+LOCAL_ADDRESS+':' + +str(LOCAL_PORT), + ], + stdout = subprocess.PIPE, + stdin = subprocess.PIPE, ) + tun_stdout = tun.stdout.fileno () + tun_stdin = tun.stdin.fileno () + tun_poll = select.poll () + tun_poll.register ( + tun.stdout.fileno(),select.POLLIN|select.POLLPRI) fcntl.fcntl (tun_stdin,fcntl.F_SETFL,fcntl.fcntl (tun_stdin,fcntl.F_GETFL)&~os.O_NONBLOCK|os.O_NONBLOCK) @@ -66,7 +66,8 @@ fcntl.fcntl (tun_stdout,fcntl.F_SETFL,fcntl.fcntl (tun_stdout,fcntl.F_GETFL)&~os.O_NONBLOCK|os.O_NONBLOCK) tun = subprocess.Popen ( - ['/usr/sbin/quicktun.'+PROTOCOL], + [ '/usr/sbin/quicktun.'+PROTOCOL, + ], stdout = subprocess.PIPE, stdin = subprocess.PIPE, ) |