Browse Source

fix auth, refine log

dev
BreakWa11 8 years ago
parent
commit
7259b211c6
  1. 22
      shadowsocks/obfsplugin/auth.py

22
shadowsocks/obfsplugin/auth.py

@ -90,7 +90,7 @@ class client_queue(object):
def __init__(self, begin_id): def __init__(self, begin_id):
self.front = begin_id - 64 self.front = begin_id - 64
self.back = begin_id + 1 self.back = begin_id + 1
self.alloc = {begin_id: 1} self.alloc = {}
self.enable = True self.enable = True
self.last_update = time.time() self.last_update = time.time()
@ -104,23 +104,23 @@ class client_queue(object):
self.enable = True self.enable = True
self.front = connection_id - 64 self.front = connection_id - 64
self.back = connection_id + 1 self.back = connection_id + 1
self.alloc = {connection_id: 1} self.alloc = {}
def insert(self, connection_id): def insert(self, connection_id):
self.update()
if not self.enable: if not self.enable:
logging.warn('auth_simple: not enable') logging.warn('obfs auth: not enable')
return False
if connection_id < self.front:
logging.warn('auth_simple: duplicate id')
return False return False
if not self.is_active(): if not self.is_active():
self.re_enable(connection_id) self.re_enable(connection_id)
self.update()
if connection_id < self.front:
logging.warn('obfs auth: duplicate id')
return False
if connection_id > self.front + 0x4000: if connection_id > self.front + 0x4000:
logging.warn('auth_simple: wrong id') logging.warn('obfs auth: wrong id')
return False return False
if connection_id in self.alloc: if connection_id in self.alloc:
logging.warn('auth_simple: duplicate id 2') logging.warn('obfs auth: duplicate id 2')
return False return False
if self.back <= connection_id: if self.back <= connection_id:
self.back = connection_id + 1 self.back = connection_id + 1
@ -154,7 +154,7 @@ class obfs_auth_data(object):
if self.client_id[c_id].is_active(): if self.client_id[c_id].is_active():
active += 1 active += 1
if active >= self.max_client: if active >= self.max_client:
logging.warn('auth_simple: max active clients exceeded') logging.warn('obfs auth: max active clients exceeded')
return False return False
if len(self.client_id) < self.max_client: if len(self.client_id) < self.max_client:
@ -176,7 +176,7 @@ class obfs_auth_data(object):
else: else:
self.client_id[client_id].re_enable(connection_id) self.client_id[client_id].re_enable(connection_id)
return self.client_id[client_id].insert(connection_id) return self.client_id[client_id].insert(connection_id)
logging.warn('auth_simple: no inactive client [assert]') logging.warn('obfs auth: no inactive client [assert]')
return False return False
else: else:
return self.client_id[client_id].insert(connection_id) return self.client_id[client_id].insert(connection_id)

Loading…
Cancel
Save