summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authord3v11 <d3v11@d3v11.ano>2012-11-11 04:07:07 +0000
committerd3v11 <d3v11@d3v11.ano>2012-11-11 04:07:07 +0000
commita097c6516a45ab816785493a509d50ad32bbb543 (patch)
tree0cf720f239309623d9ad8476083be72975418f65
parentd1297e83dd146fe0110bb946cd321ff4c8a9dfe8 (diff)
downloadresdb-a097c6516a45ab816785493a509d50ad32bbb543.tar.gz
resdb-a097c6516a45ab816785493a509d50ad32bbb543.zip
[quicktun.socks4a] bugfixes
-rwxr-xr-xcontrib/quicktun.socks4a/quicktun.socks4a37
1 files changed, 21 insertions, 16 deletions
diff --git a/contrib/quicktun.socks4a/quicktun.socks4a b/contrib/quicktun.socks4a/quicktun.socks4a
index c6f4fdc..7aeb559 100755
--- a/contrib/quicktun.socks4a/quicktun.socks4a
+++ b/contrib/quicktun.socks4a/quicktun.socks4a
@@ -1,5 +1,14 @@
#!/usr/bin/env python
-import subprocess, socket, select, fcntl, sys, os
+import subprocess, signal, socket, select, fcntl, time, sys, os
+
+def exit(sn,sf):
+ try:
+ tun.terminate ()
+ except:
+ pass
+signal.signal (signal.SIGHUP, exit)
+signal.signal (signal.SIGINT, exit)
+signal.signal (signal.SIGTERM,exit)
DEBUG = os.getenv ('DEBUG' ,'1' )
TUN_MODE = os.getenv ('TUN_MODE' ,'1' )
@@ -16,8 +25,8 @@ REMOTE_PORT = int(os.getenv ('REMOTE_PORT' ,'2998' ))
DST_ADDRESS = os.getenv ('DST_ADDRESS' ,'127.0.0.3')
DST_PORT = os.getenv ('DST_PORT' ,'2998' )
-SOCKS_ADDRESS = os.getenv ('LOCAL_ADDRESS' ,'127.0.0.1')
-SOCKS_PORT = os.getenv ('LOCAL_PORT' ,'9050' )
+SOCKS_ADDRESS = os.getenv ('SOCKS_ADDRESS' ,'127.0.0.1')
+SOCKS_PORT = os.getenv ('SOCKS_PORT' ,'9050' )
udp = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
udp.setsockopt (socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
@@ -28,12 +37,9 @@ 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, )
tun_stdout = tun.stdout.fileno ()
@@ -44,13 +50,10 @@ if REMOTE_FLOAT==0:
if REMOTE_FLOAT==1:
tun = subprocess.Popen (
- [ 'socat',
- 'TCP-LISTEN:'
- +str(LOCAL_PORT)+',BIND='+LOCAL_ADDRESS
- +',REUSEADDR',
- 'UDP-CONNECT:'+LOCAL_ADDRESS+':'
- +str(LOCAL_PORT),
- ],
+ ['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 ()
@@ -65,6 +68,8 @@ fcntl.fcntl (tun_stdin,fcntl.F_SETFL,fcntl.fcntl
fcntl.fcntl (tun_stdout,fcntl.F_SETFL,fcntl.fcntl
(tun_stdout,fcntl.F_GETFL)&~os.O_NONBLOCK|os.O_NONBLOCK)
+time.sleep (4)
+
tun = subprocess.Popen (
[ '/usr/sbin/quicktun.'+PROTOCOL,
],