From fbcc375e0f10b3c52de700e95b200faf96985102 Mon Sep 17 00:00:00 2001 From: dnomd343 Date: Sun, 30 Jan 2022 14:25:14 +0800 Subject: [PATCH] fix: auth_chain_f list index out of range --- shadowsocks/obfsplugin/auth_chain.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/shadowsocks/obfsplugin/auth_chain.py b/shadowsocks/obfsplugin/auth_chain.py index 9a2ce80..849f08e 100644 --- a/shadowsocks/obfsplugin/auth_chain.py +++ b/shadowsocks/obfsplugin/auth_chain.py @@ -884,9 +884,7 @@ class auth_chain_f(auth_chain_e): self.key_change_interval = int(server_info.protocol_param.split('#')[1]) # config are in second except: self.key_change_interval = 60 * 60 * 24 # a day by second - - def on_recv_auth_data(self, utc_time): - self.key_change_datetime_key = int(utc_time / self.key_change_interval) + self.key_change_datetime_key = int(int(time.time()) / self.key_change_interval) self.key_change_datetime_key_bytes = [] # big bit first list for i in range(7, -1, -1): # big-ending compare to c self.key_change_datetime_key_bytes.append((self.key_change_datetime_key >> (8 * i)) & 0xFF) @@ -898,13 +896,9 @@ class auth_chain_f(auth_chain_e): random = xorshift128plus() # key xor with key_change_datetime_key new_key = bytearray(key) - new_key_str = '' for i in range(0, 8): new_key[i] ^= self.key_change_datetime_key_bytes[i] - new_key_str += chr(new_key[i]) - for i in range(8, len(new_key)): - new_key_str += chr(new_key[i]) - random.init_from_bin(to_bytes(new_key_str)) + random.init_from_bin(new_key) # 补全数组长为12~24-1 list_len = random.next() % (8 + 16) + (4 + 8) for i in range(0, list_len):