5 Commits
Author SHA1 Message Date
clowwindy 56c289ba21 update CHANGES 2015-06-08 08:35:30 +08:00
clowwindy e74ae193d0 elaborate reasons of header parsing failure 2015-06-08 08:29:01 +08:00
clowwindy 16db66675b optimize LRUCache 2015-05-19 08:35:28 +08:00
clowwindy c46234af41 update CHANGES 2015-05-19 08:20:56 +08:00
clowwindy 405120c59f bump 2015-05-19 08:19:25 +08:00
4 changed files with 14 additions and 6 deletions
+7
View File
@@ -1,3 +1,10 @@
2.6.10 2015-06-08
- Optimize LRU cache
- Refine logging
2.6.9 2015-05-19
- Fix a stability issue on Windows
2.6.8 2015-02-10
- Support multiple server ip on client side
- Support --version
+1 -1
View File
@@ -7,7 +7,7 @@ with codecs.open('README.rst', encoding='utf-8') as f:
setup(
name="shadowsocks",
version="2.6.9",
version="2.6.10",
license='http://www.apache.org/licenses/LICENSE-2.0',
description="A fast tunnel proxy that help you get through firewalls",
author='clowwindy',
+2 -2
View File
@@ -171,8 +171,8 @@ def parse_header(data):
else:
logging.warn('header is too short')
else:
logging.warn('unsupported addrtype %d, maybe wrong password' %
addrtype)
logging.warn('unsupported addrtype %d, maybe wrong password or '
'encryption method' % addrtype)
if dest_addr is None:
return None
return addrtype, to_bytes(dest_addr), dest_port, header_length
+4 -3
View File
@@ -41,6 +41,7 @@ class LRUCache(collections.MutableMapping):
self._time_to_keys = collections.defaultdict(list)
self._keys_to_last_time = {}
self._last_visits = collections.deque()
self._closed_values = set()
self.update(dict(*args, **kwargs)) # use the free update to set keys
def __getitem__(self, key):
@@ -74,7 +75,6 @@ class LRUCache(collections.MutableMapping):
# O(m)
now = time.time()
c = 0
values_closed = list() # list is cheaper to create
while len(self._last_visits) > 0:
least = self._last_visits[0]
if now - least <= self.timeout:
@@ -84,9 +84,9 @@ class LRUCache(collections.MutableMapping):
if key in self._store:
if now - self._keys_to_last_time[key] > self.timeout:
value = self._store[key]
if value not in values_closed:
if value not in self._closed_values:
self.close_callback(value)
values_closed.append(value)
self._closed_values.add(value)
for key in self._time_to_keys[least]:
self._last_visits.popleft()
if key in self._store:
@@ -96,6 +96,7 @@ class LRUCache(collections.MutableMapping):
c += 1
del self._time_to_keys[least]
if c:
self._closed_values.clear()
logging.debug('%d keys swept' % c)