Browse Source

add udp_cache

dev
BreakWa11 9 years ago
parent
commit
4a02d19597
  1. 1
      shadowsocks/shell.py
  2. 3
      shadowsocks/udprelay.py

1
shadowsocks/shell.py

@ -237,6 +237,7 @@ def get_config(is_local):
config['port_password'] = config.get('port_password', None) config['port_password'] = config.get('port_password', None)
config['timeout'] = int(config.get('timeout', 300)) config['timeout'] = int(config.get('timeout', 300))
config['udp_timeout'] = int(config.get('udp_timeout', config['timeout'])) 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['fast_open'] = config.get('fast_open', False)
config['workers'] = config.get('workers', 1) config['workers'] = config.get('workers', 1)
config['pid-file'] = config.get('pid-file', '/var/run/shadowsocks.pid') config['pid-file'] = config.get('pid-file', '/var/run/shadowsocks.pid')

3
shadowsocks/udprelay.py

@ -882,6 +882,7 @@ class UDPRelay(object):
self._method = config['method'] self._method = config['method']
self._timeout = config['timeout'] self._timeout = config['timeout']
self._is_local = is_local self._is_local = is_local
self._udp_cache_size = config['udp_cache']
self._cache = lru_cache.LRUCache(timeout=config['udp_timeout'], self._cache = lru_cache.LRUCache(timeout=config['udp_timeout'],
close_callback=self._close_client) close_callback=self._close_client)
self._client_fd_to_server_addr = {} self._client_fd_to_server_addr = {}
@ -1086,7 +1087,7 @@ class UDPRelay(object):
(common.to_str(server_addr), server_port, (common.to_str(server_addr), server_port,
r_addr[0], r_addr[1])) r_addr[0], r_addr[1]))
self._cache.clear(256) self._cache.clear(self._udp_cache_size)
if self._is_local: if self._is_local:
ref_iv = [encrypt.encrypt_new_iv(self._method)] ref_iv = [encrypt.encrypt_new_iv(self._method)]

Loading…
Cancel
Save