From fb757c2bbf315eb98c5aec5607e20f0926421e54 Mon Sep 17 00:00:00 2001 From: Akkariiin Date: Mon, 14 Aug 2017 12:57:23 +0800 Subject: [PATCH] auth_chain_e --- shadowsocks/obfsplugin/auth_chain.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/shadowsocks/obfsplugin/auth_chain.py b/shadowsocks/obfsplugin/auth_chain.py index f796fd1..d9d3326 100644 --- a/shadowsocks/obfsplugin/auth_chain.py +++ b/shadowsocks/obfsplugin/auth_chain.py @@ -56,11 +56,16 @@ def create_auth_chain_d(method): return auth_chain_d(method) +def create_auth_chain_e(method): + return auth_chain_e(method) + + obfs_map = { 'auth_chain_a': (create_auth_chain_a,), 'auth_chain_b': (create_auth_chain_b,), 'auth_chain_c': (create_auth_chain_c,), 'auth_chain_d': (create_auth_chain_d,), + 'auth_chain_e': (create_auth_chain_e,), } @@ -836,3 +841,20 @@ class auth_chain_d(auth_chain_b): # random select a size in the leftover data_size_list0 final_pos = pos + random.next() % (len(self.data_size_list0) - pos) return self.data_size_list0[final_pos] - other_data_size + + +class auth_chain_e(auth_chain_d): + def __init__(self, method): + super(auth_chain_d, self).__init__(method) + self.salt = b"auth_chain_e" + self.no_compatible_method = 'auth_chain_e' + + def rnd_data_len(self, buf_size, last_hash, random): + other_data_size = buf_size + self.server_info.overhead + # if other_data_size > the bigest item in data_size_list0, not padding any data + if other_data_size >= self.data_size_list0[-1]: + return 0 + + # use the mini size in the data_size_list0 + pos = bisect.bisect_left(self.data_size_list0, other_data_size) + return self.data_size_list0[pos] - other_data_size