From 11b102b74159d49e34b6bbb8343e12549f99b018 Mon Sep 17 00:00:00 2001 From: wuhaotian Date: Sun, 24 Mar 2013 15:25:25 +0800 Subject: [PATCH] fix -6 params not work on client. fix IPv6 support --- local.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/local.py b/local.py index 2f8db87..8dd511a 100755 --- a/local.py +++ b/local.py @@ -136,10 +136,13 @@ class Socks5Server(SocketServer.StreamRequestHandler): # reply immediately if '-6' in sys.argv[1:]: remote = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + remote.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) + remote.connect((SERVER, REMOTE_PORT, 0, 0)) else: remote = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - remote.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) - remote.connect((SERVER, REMOTE_PORT)) + remote.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) + remote.connect((SERVER, REMOTE_PORT)) + self.send_encrypt(remote, addr_to_send) logging.info('connecting %s:%d' % (addr, port[0])) except socket.error, e: @@ -161,7 +164,11 @@ if __name__ == '__main__': PORT = config['local_port'] KEY = config['password'] - optlist, args = getopt.getopt(sys.argv[1:], 's:p:k:l:') + argv = sys.argv[1:] + if '-6' in sys.argv[1:]: + argv.remove('-6') + + optlist, args = getopt.getopt(argv, 's:p:k:l:') for key, value in optlist: if key == '-p': REMOTE_PORT = int(value)