local can listen at ::0 with -6 arg; bump 1.2.2
This commit is contained in:
parent
b3e5d81a0b
commit
ddaab6fbbf
3 changed files with 15 additions and 19 deletions
|
@ -2,7 +2,7 @@ shadowsocks
|
||||||
===========
|
===========
|
||||||
|
|
||||||
[](https://travis-ci.org/clowwindy/shadowsocks)
|
[](https://travis-ci.org/clowwindy/shadowsocks)
|
||||||
Current version: 1.2.1
|
Current version: 1.2.2
|
||||||
|
|
||||||
shadowsocks is a lightweight tunnel proxy which can help you get through firewalls
|
shadowsocks is a lightweight tunnel proxy which can help you get through firewalls
|
||||||
|
|
||||||
|
|
23
local.py
23
local.py
|
@ -131,15 +131,7 @@ class Socks5Server(SocketServer.StreamRequestHandler):
|
||||||
reply += socket.inet_aton('0.0.0.0') + struct.pack(">H", 2222)
|
reply += socket.inet_aton('0.0.0.0') + struct.pack(">H", 2222)
|
||||||
self.wfile.write(reply)
|
self.wfile.write(reply)
|
||||||
# reply immediately
|
# reply immediately
|
||||||
if '-6' in sys.argv[1:]:
|
remote = socket.create_connection((SERVER, REMOTE_PORT))
|
||||||
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))
|
|
||||||
|
|
||||||
self.send_encrypt(remote, addr_to_send)
|
self.send_encrypt(remote, addr_to_send)
|
||||||
logging.info('connecting %s:%d' % (addr, port[0]))
|
logging.info('connecting %s:%d' % (addr, port[0]))
|
||||||
except socket.error, e:
|
except socket.error, e:
|
||||||
|
@ -152,7 +144,7 @@ class Socks5Server(SocketServer.StreamRequestHandler):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
os.chdir(os.path.dirname(__file__) or '.')
|
os.chdir(os.path.dirname(__file__) or '.')
|
||||||
print 'shadowsocks v1.2.1'
|
print 'shadowsocks v1.2.2'
|
||||||
|
|
||||||
with open('config.json', 'rb') as f:
|
with open('config.json', 'rb') as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
|
@ -161,12 +153,9 @@ if __name__ == '__main__':
|
||||||
PORT = config['local_port']
|
PORT = config['local_port']
|
||||||
KEY = config['password']
|
KEY = config['password']
|
||||||
METHOD = config.get('method', None)
|
METHOD = config.get('method', None)
|
||||||
|
IPv6 = False
|
||||||
|
|
||||||
argv = sys.argv[1:]
|
optlist, args = getopt.getopt(sys.argv[1:], 's:p:k:l:m:6')
|
||||||
if '-6' in sys.argv[1:]:
|
|
||||||
argv.remove('-6')
|
|
||||||
|
|
||||||
optlist, args = getopt.getopt(argv, 's:p:k:l:m:')
|
|
||||||
for key, value in optlist:
|
for key, value in optlist:
|
||||||
if key == '-p':
|
if key == '-p':
|
||||||
REMOTE_PORT = int(value)
|
REMOTE_PORT = int(value)
|
||||||
|
@ -178,6 +167,8 @@ if __name__ == '__main__':
|
||||||
SERVER = value
|
SERVER = value
|
||||||
elif key == '-m':
|
elif key == '-m':
|
||||||
METHOD = value
|
METHOD = value
|
||||||
|
elif key == '-6':
|
||||||
|
IPv6 = True
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s',
|
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s',
|
||||||
datefmt='%Y-%m-%d %H:%M:%S', filemode='a+')
|
datefmt='%Y-%m-%d %H:%M:%S', filemode='a+')
|
||||||
|
@ -185,6 +176,8 @@ if __name__ == '__main__':
|
||||||
encrypt.init_table(KEY, METHOD)
|
encrypt.init_table(KEY, METHOD)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if IPv6:
|
||||||
|
ThreadingTCPServer.address_family = socket.AF_INET6
|
||||||
server = ThreadingTCPServer(('', PORT), Socks5Server)
|
server = ThreadingTCPServer(('', PORT), Socks5Server)
|
||||||
logging.info("starting server at port %d ..." % PORT)
|
logging.info("starting server at port %d ..." % PORT)
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
|
|
|
@ -125,7 +125,7 @@ class Socks5Server(SocketServer.StreamRequestHandler):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
os.chdir(os.path.dirname(__file__) or '.')
|
os.chdir(os.path.dirname(__file__) or '.')
|
||||||
|
|
||||||
print 'shadowsocks v1.2.1'
|
print 'shadowsocks v1.2.2'
|
||||||
|
|
||||||
with open('config.json', 'rb') as f:
|
with open('config.json', 'rb') as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
|
@ -134,8 +134,9 @@ if __name__ == '__main__':
|
||||||
PORT = config['server_port']
|
PORT = config['server_port']
|
||||||
KEY = config['password']
|
KEY = config['password']
|
||||||
METHOD = config.get('method', None)
|
METHOD = config.get('method', None)
|
||||||
|
IPv6 = False
|
||||||
|
|
||||||
optlist, args = getopt.getopt(sys.argv[1:], 'p:k:m:')
|
optlist, args = getopt.getopt(sys.argv[1:], 'p:k:m:6')
|
||||||
for key, value in optlist:
|
for key, value in optlist:
|
||||||
if key == '-p':
|
if key == '-p':
|
||||||
PORT = int(value)
|
PORT = int(value)
|
||||||
|
@ -143,12 +144,14 @@ if __name__ == '__main__':
|
||||||
KEY = value
|
KEY = value
|
||||||
elif key == '-m':
|
elif key == '-m':
|
||||||
METHOD = value
|
METHOD = value
|
||||||
|
elif key == '-6':
|
||||||
|
IPv6 = True
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s',
|
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s',
|
||||||
datefmt='%Y-%m-%d %H:%M:%S', filemode='a+')
|
datefmt='%Y-%m-%d %H:%M:%S', filemode='a+')
|
||||||
|
|
||||||
encrypt.init_table(KEY, METHOD)
|
encrypt.init_table(KEY, METHOD)
|
||||||
if '-6' in sys.argv[1:]:
|
if IPv6:
|
||||||
ThreadingTCPServer.address_family = socket.AF_INET6
|
ThreadingTCPServer.address_family = socket.AF_INET6
|
||||||
try:
|
try:
|
||||||
server = ThreadingTCPServer(('', PORT), Socks5Server)
|
server = ThreadingTCPServer(('', PORT), Socks5Server)
|
||||||
|
|
Loading…
Add table
Reference in a new issue