Browse Source

parse protocol_param in py3

dev
破娃酱 8 years ago
parent
commit
4f52dffcc1
  1. 8
      shadowsocks/obfsplugin/auth.py
  2. 8
      shadowsocks/tcprelay.py
  3. 8
      shadowsocks/udprelay.py

8
shadowsocks/obfsplugin/auth.py

@ -1384,14 +1384,14 @@ class auth_aes128_sha1(auth_base):
def server_udp_post_decrypt(self, buf):
uid = buf[-8:-4]
if uid in self.server_info.users:
self.user_key = self.hashfunc(self.server_info.users[uid]).digest()
user_key = self.hashfunc(self.server_info.users[uid]).digest()
else:
uid = None
if not self.server_info.users:
self.user_key = self.server_info.key
user_key = self.server_info.key
else:
self.user_key = self.server_info.recv_iv
if hmac.new(self.user_key, buf[:-4], self.hashfunc).digest()[:4] != buf[-4:]:
user_key = self.server_info.recv_iv
if hmac.new(user_key, buf[:-4], self.hashfunc).digest()[:4] != buf[-4:]:
return (b'', None)
return (buf[:-8], uid)

8
shadowsocks/tcprelay.py

@ -1019,13 +1019,13 @@ class TCPRelay(object):
listen_port = config['server_port']
self._listen_port = listen_port
if config['protocol'] in ["auth_aes128_md5", "auth_aes128_sha1"]:
param = config['protocol_param'].split('#')
if common.to_bytes(config['protocol']) in ["auth_aes128_md5", "auth_aes128_sha1"]:
param = common.to_bytes(config['protocol_param']).split(b'#')
if len(param) == 2:
user_list = param[1].split(',')
user_list = param[1].split(b',')
if user_list:
for user in user_list:
items = user.split(':')
items = user.split(b':')
if len(items) == 2:
uid = struct.pack('<I', int(items[0]))
passwd = items[1]

8
shadowsocks/udprelay.py

@ -901,13 +901,13 @@ class UDPRelay(object):
self.server_user_transfer_ul = {}
self.server_user_transfer_dl = {}
if config['protocol'] in ["auth_aes128_md5", "auth_aes128_sha1"]:
param = config['protocol_param'].split('#')
if common.to_bytes(config['protocol']) in [b"auth_aes128_md5", b"auth_aes128_sha1"]:
param = common.to_bytes(config['protocol_param']).split(b'#')
if len(param) == 2:
user_list = param[1].split(',')
user_list = param[1].split(b',')
if user_list:
for user in user_list:
items = user.split(':')
items = user.split(b':')
if len(items) == 2:
uid = struct.pack('<I', int(items[0]))
passwd = items[1]

Loading…
Cancel
Save