diff --git a/shadowsocks/obfsplugin/verify_simple.py b/shadowsocks/obfsplugin/verify_simple.py index c162c06..43f8c3e 100644 --- a/shadowsocks/obfsplugin/verify_simple.py +++ b/shadowsocks/obfsplugin/verify_simple.py @@ -338,6 +338,7 @@ class obfs_auth_data(object): def __init__(self): self.sub_obfs = None self.client_id = {} + self.startup_time = int(time.time() - 30) & 0xffffffff def update(self, client_id, connection_id): if client_id in self.client_id: @@ -491,7 +492,7 @@ class auth_simple(verify_base): client_id = struct.unpack(' 60 * 3: + if time_dif < 60 * -3 or time_dif > 60 * 3 or common.int32(utc_time - self.server_info.data.startup_time) < 0: self.raw_trans = True self.recv_buf = b'' logging.info('auth_simple: wrong timestamp, time_dif %d, data %s' % (time_dif, binascii.hexlify(out_buf),)) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 5d1f251..f82762b 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -115,8 +115,6 @@ class TCPRelayHandler(object): config['method']) self._encrypt_correct = True self._obfs = obfs.obfs(config['obfs']) - if server.obfs_data is None: - server.obfs_data = self._obfs.init_data() server_info = obfs.server_info(server.obfs_data) server_info.host = config['server'] server_info.port = server._listen_port @@ -769,7 +767,7 @@ class TCPRelay(object): self.server_transfer_ul = 0 self.server_transfer_dl = 0 self.server_connections = 0 - self.obfs_data = None + self.obfs_data = obfs.obfs(config['obfs']).init_data() self._timeout = config['timeout'] self._timeouts = [] # a list for all the handlers