Browse Source

support IPv6 address

1.4
clowwindy 12 years ago
parent
commit
db0fc87a22
  1. 6
      local.py
  2. 4
      server.py

6
local.py

@ -122,6 +122,10 @@ class Socks5Server(SocketServer.StreamRequestHandler):
addr_len = self.rfile.read(1)
addr = self.rfile.read(ord(addr_len))
addr_to_send += addr_len + addr
elif addrtype == 4:
addr_ip = self.rfile.read(16)
addr = socket.inet_ntop(socket.AF_INET6, addr_ip)
addr_to_send += addr_ip
else:
logging.warn('addr_type not support')
# not support
@ -155,7 +159,7 @@ class Socks5Server(SocketServer.StreamRequestHandler):
if __name__ == '__main__':
os.chdir(os.path.dirname(__file__) or '.')
print 'shadowsocks v1.0'
print 'shadowsocks v1.1'
with open('config.json', 'rb') as f:
config = json.load(f)

4
server.py

@ -108,6 +108,8 @@ class Socks5Server(SocketServer.StreamRequestHandler):
elif addrtype == 3:
addr = self.decrypt(
self.rfile.read(ord(self.decrypt(sock.recv(1)))))
elif addrtype == 4:
addr = socket.inet_ntop(socket.AF_INET6, self.decrypt(self.rfile.read(16)))
else:
# not support
logging.warn('addr_type not support')
@ -129,7 +131,7 @@ class Socks5Server(SocketServer.StreamRequestHandler):
if __name__ == '__main__':
os.chdir(os.path.dirname(__file__) or '.')
print 'shadowsocks v1.0'
print 'shadowsocks v1.1'
with open('config.json', 'rb') as f:
config = json.load(f)

Loading…
Cancel
Save