parse protocol_param in py3
This commit is contained in:
parent
cd825c9c2c
commit
4f52dffcc1
3 changed files with 12 additions and 12 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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…
Add table
Add a link
Reference in a new issue