From 4f52dffcc1c1d7aadf60637ad43acada84b90777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=B4=E5=A8=83=E9=85=B1?= Date: Sun, 8 Jan 2017 00:26:49 +0800 Subject: [PATCH] parse protocol_param in py3 --- shadowsocks/obfsplugin/auth.py | 8 ++++---- shadowsocks/tcprelay.py | 8 ++++---- shadowsocks/udprelay.py | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/shadowsocks/obfsplugin/auth.py b/shadowsocks/obfsplugin/auth.py index 4150aaa..313a170 100644 --- a/shadowsocks/obfsplugin/auth.py +++ b/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) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 8db91f9..83a5274 100644 --- a/shadowsocks/tcprelay.py +++ b/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('