From 13436b224ec7f2e8001f960f1d2e05b2275843db Mon Sep 17 00:00:00 2001 From: clowwindy Date: Fri, 4 Jul 2014 21:57:11 +0300 Subject: [PATCH 1/3] add EWOULDBLOCK to fix Windows; close #138 --- shadowsocks/tcprelay.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 225fb28..fa10c67 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -166,7 +166,8 @@ class TCPRelayHandler(object): uncomplete = True except (OSError, IOError) as e: error_no = eventloop.errno_from_exception(e) - if error_no in (errno.EAGAIN, errno.EINPROGRESS): + if error_no in (errno.EAGAIN, errno.EINPROGRESS, + errno.EWOULDBLOCK): uncomplete = True else: logging.error(e) @@ -349,7 +350,7 @@ class TCPRelayHandler(object): data = self._local_sock.recv(BUF_SIZE) except (OSError, IOError) as e: if eventloop.errno_from_exception(e) in \ - (errno.ETIMEDOUT, errno.EAGAIN): + (errno.ETIMEDOUT, errno.EAGAIN, errno.EWOULDBLOCK): return if not data: self.destroy() @@ -381,7 +382,7 @@ class TCPRelayHandler(object): data = self._remote_sock.recv(BUF_SIZE) except (OSError, IOError) as e: if eventloop.errno_from_exception(e) in \ - (errno.ETIMEDOUT, errno.EAGAIN): + (errno.ETIMEDOUT, errno.EAGAIN, errno.EWOULDBLOCK): return if not data: self.destroy() @@ -610,7 +611,8 @@ class TCPRelay(object): self._is_local) except (OSError, IOError) as e: error_no = eventloop.errno_from_exception(e) - if error_no in (errno.EAGAIN, errno.EINPROGRESS): + if error_no in (errno.EAGAIN, errno.EINPROGRESS, + errno.EWOULDBLOCK): continue else: logging.error(e) From b0c8e50492bf66e257a0cd902541c467be888ac2 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Fri, 4 Jul 2014 22:25:27 +0300 Subject: [PATCH 2/3] fix #145 --- shadowsocks/utils.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/shadowsocks/utils.py b/shadowsocks/utils.py index 492f357..0b7b068 100644 --- a/shadowsocks/utils.py +++ b/shadowsocks/utils.py @@ -100,7 +100,7 @@ def get_config(is_local): logging.info('loading config from %s' % config_path) with open(config_path, 'rb') as f: try: - config = json.load(f) + config = json.load(f, object_hook=_decode_dict) except ValueError as e: logging.error('found an error in config.json: %s', e.message) @@ -210,4 +210,32 @@ optional arguments: -v verbose mode Online help: -''' \ No newline at end of file +''' + + +def _decode_list(data): + rv = [] + for item in data: + if isinstance(item, unicode): + item = item.encode('utf-8') + elif isinstance(item, list): + item = _decode_list(item) + elif isinstance(item, dict): + item = _decode_dict(item) + rv.append(item) + return rv + + +def _decode_dict(data): + rv = {} + for key, value in data.iteritems(): + if isinstance(key, unicode): + key = key.encode('utf-8') + if isinstance(value, unicode): + value = value.encode('utf-8') + elif isinstance(value, list): + value = _decode_list(value) + elif isinstance(value, dict): + value = _decode_dict(value) + rv[key] = value + return rv \ No newline at end of file From a614dd6e5b2bdf813bb34d0c2ceae6a99b398708 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Sun, 6 Jul 2014 18:43:50 +0300 Subject: [PATCH 3/3] bump --- CHANGES | 4 ++++ README.rst | 11 ++++------- setup.py | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index a50ec1d..5a27a49 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +2.0.9 2014-07-06 +- Fix EWOULDBLOCK on Windows +- Fix Unicode config problem on some platforms + 2.0.8 2014-06-23 - Use multiple DNS to query hostnames diff --git a/README.rst b/README.rst index f46ea8b..983a375 100644 --- a/README.rst +++ b/README.rst @@ -143,13 +143,10 @@ MIT Bugs and Issues --------------- -Please visit `Issue -Tracker `__ - -Mailing list: http://groups.google.com/group/shadowsocks - -Also see -`Troubleshooting `__ +- `Troubleshooting `__ +- `Issue + Tracker `__ +- `Mailing list `__ .. |PyPI version| image:: https://img.shields.io/pypi/v/shadowsocks.svg?style=flat :target: https://pypi.python.org/pypi/shadowsocks diff --git a/setup.py b/setup.py index 2bb28c9..9025d91 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open('README.rst') as f: setup( name="shadowsocks", - version="2.0.8", + version="2.0.9", license='MIT', description="A fast tunnel proxy that help you get through firewalls", author='clowwindy',