From fa31a233b6a3d2809d766baa66b2a6f31e2aec1e Mon Sep 17 00:00:00 2001 From: clowwindy Date: Sat, 8 Nov 2014 02:28:37 +0800 Subject: [PATCH] add ipv6 tests --- .travis.yml | 1 + shadowsocks/tcprelay.py | 2 +- tests/ipv6-client-side.json | 10 ++++++++++ tests/ipv6.json | 10 ++++++++++ tests/test.py | 4 ++-- 5 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tests/ipv6-client-side.json create mode 100644 tests/ipv6.json diff --git a/.travis.yml b/.travis.yml index 592ac6e..286c5df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,5 +28,6 @@ script: - python tests/test.py -c tests/server-multi-ports.json - python tests/test.py -s tests/server-multi-passwd.json -c tests/server-multi-passwd-client-side.json - python tests/test.py -c tests/workers.json + - python tests/test.py -s tests/ipv6.json -c tests/ipv6-client-side.json - python tests/test.py -b "-m rc4-md5 -k testrc4 -s 127.0.0.1 -p 8388" -a "-m rc4-md5 -k testrc4 -s 127.0.0.1 -p 8388 -l 1081" - python tests/test.py -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081" diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index e25c63f..e55f9dd 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -241,7 +241,7 @@ class TCPRelayHandler(object): header = b'\x05\x00\x00\x04' else: header = b'\x05\x00\x00\x01' - addr, port = self._local_sock.getsockname() + addr, port = self._local_sock.getsockname()[:2] addr_to_send = socket.inet_pton(self._local_sock.family, addr) port_to_send = struct.pack('>H', port) diff --git a/tests/ipv6-client-side.json b/tests/ipv6-client-side.json new file mode 100644 index 0000000..6c3cfaf --- /dev/null +++ b/tests/ipv6-client-side.json @@ -0,0 +1,10 @@ +{ + "server":"::1", + "server_port":8388, + "local_port":1081, + "password":"aes_password", + "timeout":60, + "method":"aes-256-cfb", + "local_address":"127.0.0.1", + "fast_open":false +} diff --git a/tests/ipv6.json b/tests/ipv6.json new file mode 100644 index 0000000..d855f9c --- /dev/null +++ b/tests/ipv6.json @@ -0,0 +1,10 @@ +{ + "server":"::", + "server_port":8388, + "local_port":1081, + "password":"aes_password", + "timeout":60, + "method":"aes-256-cfb", + "local_address":"127.0.0.1", + "fast_open":false +} diff --git a/tests/test.py b/tests/test.py index cefea87..34c10fb 100755 --- a/tests/test.py +++ b/tests/test.py @@ -42,8 +42,8 @@ parser.add_argument('-b', '--server-args', type=str, default=None) config = parser.parse_args() -client_args = [python, 'shadowsocks/local.py'] -server_args = [python, 'shadowsocks/server.py'] +client_args = [python, 'shadowsocks/local.py', '-v'] +server_args = [python, 'shadowsocks/server.py', '-v'] if config.client_conf: client_args.extend(['-c', config.client_conf])