a little refractor
This commit is contained in:
parent
0e19700dac
commit
0f2ab22cc7
2 changed files with 4 additions and 17 deletions
|
@ -122,10 +122,7 @@ class TCPRelayHandler(object):
|
||||||
self._stage = STAGE_INIT
|
self._stage = STAGE_INIT
|
||||||
self._encryptor = encrypt.Encryptor(config['password'],
|
self._encryptor = encrypt.Encryptor(config['password'],
|
||||||
config['method'])
|
config['method'])
|
||||||
if 'one_time_auth' in config and config['one_time_auth']:
|
self._ota_enable = config.get('one_time_auth', False)
|
||||||
self._ota_enable = True
|
|
||||||
else:
|
|
||||||
self._ota_enable = False
|
|
||||||
self._ota_enable_session = self._ota_enable
|
self._ota_enable_session = self._ota_enable
|
||||||
self._ota_buff_head = b''
|
self._ota_buff_head = b''
|
||||||
self._ota_buff_data = b''
|
self._ota_buff_data = b''
|
||||||
|
@ -138,10 +135,7 @@ class TCPRelayHandler(object):
|
||||||
self._downstream_status = WAIT_STATUS_INIT
|
self._downstream_status = WAIT_STATUS_INIT
|
||||||
self._client_address = local_sock.getpeername()[:2]
|
self._client_address = local_sock.getpeername()[:2]
|
||||||
self._remote_address = None
|
self._remote_address = None
|
||||||
if 'forbidden_ip' in config:
|
self._forbidden_iplist = config.get('forbidden_ip')
|
||||||
self._forbidden_iplist = config['forbidden_ip']
|
|
||||||
else:
|
|
||||||
self._forbidden_iplist = None
|
|
||||||
if is_local:
|
if is_local:
|
||||||
self._chosen_server = self._get_a_server()
|
self._chosen_server = self._get_a_server()
|
||||||
fd_to_handlers[local_sock.fileno()] = self
|
fd_to_handlers[local_sock.fileno()] = self
|
||||||
|
|
|
@ -98,10 +98,7 @@ class UDPRelay(object):
|
||||||
self._password = common.to_bytes(config['password'])
|
self._password = common.to_bytes(config['password'])
|
||||||
self._method = config['method']
|
self._method = config['method']
|
||||||
self._timeout = config['timeout']
|
self._timeout = config['timeout']
|
||||||
if 'one_time_auth' in config and config['one_time_auth']:
|
self._ota_enable = config.get('one_time_auth', False)
|
||||||
self._ota_enable = True
|
|
||||||
else:
|
|
||||||
self._ota_enable = False
|
|
||||||
self._ota_enable_session = self._ota_enable
|
self._ota_enable_session = self._ota_enable
|
||||||
self._is_local = is_local
|
self._is_local = is_local
|
||||||
self._cache = lru_cache.LRUCache(timeout=config['timeout'],
|
self._cache = lru_cache.LRUCache(timeout=config['timeout'],
|
||||||
|
@ -112,11 +109,7 @@ class UDPRelay(object):
|
||||||
self._eventloop = None
|
self._eventloop = None
|
||||||
self._closed = False
|
self._closed = False
|
||||||
self._sockets = set()
|
self._sockets = set()
|
||||||
if 'forbidden_ip' in config:
|
self._forbidden_iplist = config.get('forbidden_ip')
|
||||||
self._forbidden_iplist = config['forbidden_ip']
|
|
||||||
else:
|
|
||||||
self._forbidden_iplist = None
|
|
||||||
|
|
||||||
addrs = socket.getaddrinfo(self._listen_addr, self._listen_port, 0,
|
addrs = socket.getaddrinfo(self._listen_addr, self._listen_port, 0,
|
||||||
socket.SOCK_DGRAM, socket.SOL_UDP)
|
socket.SOCK_DGRAM, socket.SOL_UDP)
|
||||||
if len(addrs) == 0:
|
if len(addrs) == 0:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue