From 5179e018e2f14b377ca1c8b95f4c42bfb0c3b9c1 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Wed, 14 Jan 2015 13:12:12 +0800 Subject: [PATCH 01/12] bump --- CHANGES | 5 ++++- setup.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index b5c9062..27c8562 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,7 @@ -2.6.3 2015-01-03 +2.6.4 2015-01-14 +- Also search lib* when searching libraries + +2.6.3 2015-01-12 - Support --forbidden-ip to ban some IP, i.e. localhost - Search OpenSSL and libsodium harder - Now works on OpenWRT diff --git a/setup.py b/setup.py index 725ec71..c287c5c 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with codecs.open('README.rst', encoding='utf-8') as f: setup( name="shadowsocks", - version="2.6.3", + version="2.6.4", license='MIT', description="A fast tunnel proxy that help you get through firewalls", author='clowwindy', From bd22e3ef753f0530a0124d15be6d29f13681ccf1 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Fri, 16 Jan 2015 16:50:18 +0800 Subject: [PATCH 02/12] try every dll that matches by name in PATH --- shadowsocks/crypto/util.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/shadowsocks/crypto/util.py b/shadowsocks/crypto/util.py index 6d7d222..1242f8e 100644 --- a/shadowsocks/crypto/util.py +++ b/shadowsocks/crypto/util.py @@ -23,9 +23,28 @@ from __future__ import absolute_import, division, print_function, \ with_statement +import os import logging +def find_library_nt(name): + # modified from ctypes.util + # ctypes.util.find_library just returns first result he found + # but we want to try them all + # because on Windows, users may have both 32bit and 64bit version installed + results = [] + for directory in os.environ['PATH'].split(os.pathsep): + fname = os.path.join(directory, name) + if os.path.isfile(fname): + results.append(fname) + if fname.lower().endswith(".dll"): + continue + fname = fname + ".dll" + if os.path.isfile(fname): + results.append(fname) + return results + + def find_library(possible_lib_names, search_symbol, library_name): import ctypes.util from ctypes import CDLL @@ -41,9 +60,12 @@ def find_library(possible_lib_names, search_symbol, library_name): lib_names.append('lib' + lib_name) for name in lib_names: - path = ctypes.util.find_library(name) - if path: - paths.append(path) + if os.name == "nt": + paths.extend(find_library_nt(name)) + else: + path = ctypes.util.find_library(name) + if path: + paths.append(path) if not paths: # We may get here when find_library fails because, for example, @@ -56,8 +78,7 @@ def find_library(possible_lib_names, search_symbol, library_name): '/usr/local/lib*/lib%s.*' % name, '/usr/lib*/lib%s.*' % name, 'lib%s.*' % name, - '%s.dll' % name, - 'lib%s.dll' % name] + '%s.dll' % name] for pat in patterns: files = glob.glob(pat) From 13413267dcc8dc16f667fcf4996c93a8fec7aa87 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Fri, 16 Jan 2015 17:06:48 +0800 Subject: [PATCH 03/12] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7b351ba..0e45c91 100644 --- a/README.md +++ b/README.md @@ -12,17 +12,17 @@ Server ### Install -#### Debian / Ubuntu: +Debian / Ubuntu: apt-get install python-pip pip install shadowsocks -#### CentOS: +CentOS: yum install python-setuptools && easy_install pip pip install shadowsocks -#### Windows: +Windows: See [Install Server on Windows] From 6efb3d00e414a69c77f018dab1c853d808a7c4e4 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Fri, 16 Jan 2015 18:52:01 +0800 Subject: [PATCH 04/12] fix #264 --- shadowsocks/asyncdns.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/shadowsocks/asyncdns.py b/shadowsocks/asyncdns.py index 18222a6..6f60dc9 100644 --- a/shadowsocks/asyncdns.py +++ b/shadowsocks/asyncdns.py @@ -93,11 +93,12 @@ def build_address(address): return b''.join(results) -def build_request(address, qtype, request_id): - header = struct.pack('!HBBHHHH', request_id, 1, 0, 1, 0, 0, 0) +def build_request(address, qtype): + request_id = os.urandom(2) + header = struct.pack('!BBHHHH', 1, 0, 1, 0, 0, 0) addr = build_address(address) qtype_qclass = struct.pack('!HH', qtype, QCLASS_IN) - return header + addr + qtype_qclass + return request_id + header + addr + qtype_qclass def parse_ip(addrtype, data, length, offset): @@ -270,7 +271,6 @@ class DNSResolver(object): def __init__(self): self._loop = None - self._request_id = 1 self._hosts = {} self._hostname_status = {} self._hostname_to_cb = {} @@ -412,10 +412,7 @@ class DNSResolver(object): del self._hostname_status[hostname] def _send_req(self, hostname, qtype): - self._request_id += 1 - if self._request_id > 32768: - self._request_id = 1 - req = build_request(hostname, qtype, self._request_id) + req = build_request(hostname, qtype) for server in self._servers: logging.debug('resolving %s with type %d using server %s', hostname, qtype, server) From 2e9ce11ea15c303b769c2ab5e327c7372cfef2c7 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Sun, 18 Jan 2015 18:32:04 +0800 Subject: [PATCH 05/12] bump --- CHANGES | 3 +++ setup.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 27c8562..e90ad72 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +2.6.5 2015-01-18 +- Try both 32 bit and 64 bit dll on Windows + 2.6.4 2015-01-14 - Also search lib* when searching libraries diff --git a/setup.py b/setup.py index c287c5c..8c022ea 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with codecs.open('README.rst', encoding='utf-8') as f: setup( name="shadowsocks", - version="2.6.4", + version="2.6.5", license='MIT', description="A fast tunnel proxy that help you get through firewalls", author='clowwindy', From 5e5d25efd989903648f7e6d1d5865eb6f890b1c8 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Mon, 19 Jan 2015 16:20:08 +0800 Subject: [PATCH 06/12] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 04aaa02..fbdb9c1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,6 +21,8 @@ a pull request, or ask some of your friends to do so. 3. We don't answer questions of any other types here. Since very few people are watching the issue tracker here, you'll probably get no help from here. Read [Troubleshooting] and get help from forums or [mailing lists]. +4. Issues in languages other than English will be Google translated into English +later. [Troubleshooting]: https://github.com/clowwindy/shadowsocks/wiki/Troubleshooting From f4052fbc84904bd377965adbb5ff7e58b4754e8e Mon Sep 17 00:00:00 2001 From: clowwindy Date: Wed, 21 Jan 2015 14:32:21 +0800 Subject: [PATCH 07/12] fix MANIFEST.in --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 1dc4c8e..1882dd7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,3 @@ -recursive-include *.py +recursive-include shadowsocks *.py include README.rst include LICENSE From 0e6a4cd8ff118b9362be8a33c961290081a8373f Mon Sep 17 00:00:00 2001 From: clowwindy Date: Fri, 23 Jan 2015 14:06:01 +0800 Subject: [PATCH 08/12] output python version in unit tests --- .jenkins.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.jenkins.sh b/.jenkins.sh index bb58e04..28583f9 100755 --- a/.jenkins.sh +++ b/.jenkins.sh @@ -24,6 +24,7 @@ function run_test { return 0 } +python --version coverage erase mkdir tmp run_test pep8 . From 1f8819f790e20ff30a8d6357d9a2509bc3229d17 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Fri, 23 Jan 2015 17:33:48 +0800 Subject: [PATCH 09/12] fix #270 --- .jenkins.sh | 2 +- shadowsocks/tcprelay.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.jenkins.sh b/.jenkins.sh index 28583f9..f14969f 100755 --- a/.jenkins.sh +++ b/.jenkins.sh @@ -46,7 +46,7 @@ run_test python tests/test.py --with-coverage -c tests/workers.json run_test python tests/test.py --with-coverage -s tests/ipv6.json -c tests/ipv6-client-side.json run_test python tests/test.py --with-coverage -b "-m rc4-md5 -k testrc4 -s 127.0.0.1 -p 8388 -q" -a "-m rc4-md5 -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -vv" run_test python tests/test.py --with-coverage -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 --workers 1" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -qq -b 127.0.0.1" -run_test python tests/test.py --with-coverage --should-fail --url="http://127.0.0.1/" -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 --forbidden-ip=127.0.0.1,::1,8.8.8.8" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -b 127.0.0.1" +run_test python tests/test.py --with-coverage --should-fail --url="http://localhost/" -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 --forbidden-ip=127.0.0.1,::1,8.8.8.8" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -b 127.0.0.1" if [ -f /proc/sys/net/ipv4/tcp_fastopen ] ; then if [ 3 -eq `cat /proc/sys/net/ipv4/tcp_fastopen` ] ; then diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index c148208..3b48901 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -387,7 +387,7 @@ class TCPRelayHandler(object): self._update_stream(STREAM_UP, WAIT_STATUS_READWRITING) self._update_stream(STREAM_DOWN, WAIT_STATUS_READING) return - except (OSError, IOError) as e: + except Exception as e: logging.error(e) if self._config['verbose']: traceback.print_exc() From 70ebd2ef285cc52f903dce2ea990936a8581f731 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Fri, 23 Jan 2015 17:35:32 +0800 Subject: [PATCH 10/12] bump --- CHANGES | 3 +++ setup.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index e90ad72..6e0331f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +2.6.6 2015-01-23 +- Fix a crash in forbidden list + 2.6.5 2015-01-18 - Try both 32 bit and 64 bit dll on Windows diff --git a/setup.py b/setup.py index 8c022ea..33cc44c 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with codecs.open('README.rst', encoding='utf-8') as f: setup( name="shadowsocks", - version="2.6.5", + version="2.6.6", license='MIT', description="A fast tunnel proxy that help you get through firewalls", author='clowwindy', From 51f47ccb9167721527aac69a909d9ea83c93929c Mon Sep 17 00:00:00 2001 From: clowwindy Date: Sat, 24 Jan 2015 14:28:39 +0800 Subject: [PATCH 11/12] update coverage url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e45c91..efc4406 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Bugs and Issues [Build Status]: https://img.shields.io/travis/shadowsocks/shadowsocks/master.svg?style=flat [Configuration]: https://github.com/shadowsocks/shadowsocks/wiki/Configuration-via-Config-File [Coverage Status]: https://jenkins.shadowvpn.org/result/shadowsocks -[Coverage]: https://jenkins.shadowvpn.org/job/Shadowsocks/ws/htmlcov/index.html +[Coverage]: https://jenkins.shadowvpn.org/job/Shadowsocks/ws/PYENV/py34/label/linux01/htmlcov/index.html [Debian sid]: https://packages.debian.org/unstable/python/shadowsocks [iOS]: https://github.com/shadowsocks/shadowsocks-iOS/wiki/Help [Issue Tracker]: https://github.com/shadowsocks/shadowsocks/issues?state=open From 4a2d98b28005ff2e53ab874d460eb5e463876d89 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Sat, 24 Jan 2015 14:43:11 +0800 Subject: [PATCH 12/12] update coverage url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index efc4406..aba545b 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Bugs and Issues [Build Status]: https://img.shields.io/travis/shadowsocks/shadowsocks/master.svg?style=flat [Configuration]: https://github.com/shadowsocks/shadowsocks/wiki/Configuration-via-Config-File [Coverage Status]: https://jenkins.shadowvpn.org/result/shadowsocks -[Coverage]: https://jenkins.shadowvpn.org/job/Shadowsocks/ws/PYENV/py34/label/linux01/htmlcov/index.html +[Coverage]: https://jenkins.shadowvpn.org/job/Shadowsocks/ws/PYENV/py34/label/linux/htmlcov/index.html [Debian sid]: https://packages.debian.org/unstable/python/shadowsocks [iOS]: https://github.com/shadowsocks/shadowsocks-iOS/wiki/Help [Issue Tracker]: https://github.com/shadowsocks/shadowsocks/issues?state=open