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
+2 -1
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),))