add udp_cache
This commit is contained in:
parent
b71af8f4df
commit
4a02d19597
2 changed files with 3 additions and 1 deletions
|
@ -237,6 +237,7 @@ def get_config(is_local):
|
|||
config['port_password'] = config.get('port_password', None)
|
||||
config['timeout'] = int(config.get('timeout', 300))
|
||||
config['udp_timeout'] = int(config.get('udp_timeout', config['timeout']))
|
||||
config['udp_cache'] = int(config.get('udp_cache', 64))
|
||||
config['fast_open'] = config.get('fast_open', False)
|
||||
config['workers'] = config.get('workers', 1)
|
||||
config['pid-file'] = config.get('pid-file', '/var/run/shadowsocks.pid')
|
||||
|
|
|
@ -882,6 +882,7 @@ class UDPRelay(object):
|
|||
self._method = config['method']
|
||||
self._timeout = config['timeout']
|
||||
self._is_local = is_local
|
||||
self._udp_cache_size = config['udp_cache']
|
||||
self._cache = lru_cache.LRUCache(timeout=config['udp_timeout'],
|
||||
close_callback=self._close_client)
|
||||
self._client_fd_to_server_addr = {}
|
||||
|
@ -1086,7 +1087,7 @@ class UDPRelay(object):
|
|||
(common.to_str(server_addr), server_port,
|
||||
r_addr[0], r_addr[1]))
|
||||
|
||||
self._cache.clear(256)
|
||||
self._cache.clear(self._udp_cache_size)
|
||||
|
||||
if self._is_local:
|
||||
ref_iv = [encrypt.encrypt_new_iv(self._method)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue