add startup time in auth_simple

This commit is contained in:
BreakWa11 2015-10-23 22:23:59 +08:00
parent 39dffa220f
commit 83c8b50ea2
2 changed files with 3 additions and 4 deletions

View file

@ -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('<I', out_buf[4:8])[0]
connection_id = struct.unpack('<I', out_buf[8:12])[0]
time_dif = common.int32((int(time.time()) & 0xffffffff) - utc_time)
if time_dif < 60 * -3 or time_dif > 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),))

View file

@ -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