BreakWa11
9 years ago
18 changed files with 163 additions and 149 deletions
@ -1 +0,0 @@ |
|||
#!/usr/bin/python |
@ -0,0 +1,39 @@ |
|||
import codecs |
|||
from setuptools import setup |
|||
|
|||
|
|||
with codecs.open('README.rst', encoding='utf-8') as f: |
|||
long_description = f.read() |
|||
|
|||
setup( |
|||
name="shadowsocks", |
|||
version="2.6.12", |
|||
license='http://www.apache.org/licenses/LICENSE-2.0', |
|||
description="A fast tunnel proxy that help you get through firewalls", |
|||
author='clowwindy', |
|||
author_email='clowwindy42@gmail.com', |
|||
url='https://github.com/shadowsocks/shadowsocks', |
|||
packages=['shadowsocks', 'shadowsocks.crypto'], |
|||
package_data={ |
|||
'shadowsocks': ['README.rst', 'LICENSE'] |
|||
}, |
|||
install_requires=[], |
|||
entry_points=""" |
|||
[console_scripts] |
|||
sslocal = shadowsocks.local:main |
|||
ssserver = shadowsocks.server:main |
|||
""", |
|||
classifiers=[ |
|||
'License :: OSI Approved :: Apache Software License', |
|||
'Programming Language :: Python :: 2', |
|||
'Programming Language :: Python :: 2.6', |
|||
'Programming Language :: Python :: 2.7', |
|||
'Programming Language :: Python :: 3', |
|||
'Programming Language :: Python :: 3.3', |
|||
'Programming Language :: Python :: 3.4', |
|||
'Programming Language :: Python :: Implementation :: CPython', |
|||
'Programming Language :: Python :: Implementation :: PyPy', |
|||
'Topic :: Internet :: Proxy Servers', |
|||
], |
|||
long_description=long_description, |
|||
) |
@ -1,117 +0,0 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2014 clowwindy |
|||
# |
|||
# Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
# of this software and associated documentation files (the "Software"), to deal |
|||
# in the Software without restriction, including without limitation the rights |
|||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
# copies of the Software, and to permit persons to whom the Software is |
|||
# furnished to do so, subject to the following conditions: |
|||
# |
|||
# The above copyright notice and this permission notice shall be included in |
|||
# all copies or substantial portions of the Software. |
|||
# |
|||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|||
# SOFTWARE. |
|||
|
|||
from __future__ import absolute_import, division, print_function, \ |
|||
with_statement |
|||
|
|||
import sys |
|||
import logging |
|||
|
|||
__all__ = ['ciphers'] |
|||
|
|||
has_m2 = True |
|||
try: |
|||
__import__('M2Crypto') |
|||
except ImportError: |
|||
has_m2 = False |
|||
|
|||
|
|||
def create_cipher(alg, key, iv, op, key_as_bytes=0, d=None, salt=None, i=1, |
|||
padding=1): |
|||
|
|||
import M2Crypto.EVP |
|||
return M2Crypto.EVP.Cipher(alg.replace('-', '_'), key, iv, op, |
|||
key_as_bytes=0, d='md5', salt=None, i=1, |
|||
padding=1) |
|||
|
|||
|
|||
def err(alg, key, iv, op, key_as_bytes=0, d=None, salt=None, i=1, padding=1): |
|||
logging.error(('M2Crypto is required to use %s, please run' |
|||
' `apt-get install python-m2crypto`') % alg) |
|||
sys.exit(1) |
|||
|
|||
|
|||
if has_m2: |
|||
ciphers = { |
|||
b'aes-128-cfb': (16, 16, create_cipher), |
|||
b'aes-192-cfb': (24, 16, create_cipher), |
|||
b'aes-256-cfb': (32, 16, create_cipher), |
|||
b'bf-cfb': (16, 8, create_cipher), |
|||
b'camellia-128-cfb': (16, 16, create_cipher), |
|||
b'camellia-192-cfb': (24, 16, create_cipher), |
|||
b'camellia-256-cfb': (32, 16, create_cipher), |
|||
b'cast5-cfb': (16, 8, create_cipher), |
|||
b'des-cfb': (8, 8, create_cipher), |
|||
b'idea-cfb': (16, 8, create_cipher), |
|||
b'rc2-cfb': (16, 8, create_cipher), |
|||
b'rc4': (16, 0, create_cipher), |
|||
b'seed-cfb': (16, 16, create_cipher), |
|||
} |
|||
else: |
|||
ciphers = {} |
|||
|
|||
|
|||
def run_method(method): |
|||
from shadowsocks.crypto import util |
|||
|
|||
cipher = create_cipher(method, b'k' * 32, b'i' * 16, 1) |
|||
decipher = create_cipher(method, b'k' * 32, b'i' * 16, 0) |
|||
|
|||
util.run_cipher(cipher, decipher) |
|||
|
|||
|
|||
def check_env(): |
|||
# skip this test on pypy and Python 3 |
|||
try: |
|||
import __pypy__ |
|||
del __pypy__ |
|||
from nose.plugins.skip import SkipTest |
|||
raise SkipTest |
|||
except ImportError: |
|||
pass |
|||
if bytes != str: |
|||
from nose.plugins.skip import SkipTest |
|||
raise SkipTest |
|||
|
|||
|
|||
def test_aes_128_cfb(): |
|||
check_env() |
|||
run_method(b'aes-128-cfb') |
|||
|
|||
|
|||
def test_aes_256_cfb(): |
|||
check_env() |
|||
run_method(b'aes-256-cfb') |
|||
|
|||
|
|||
def test_bf_cfb(): |
|||
check_env() |
|||
run_method(b'bf-cfb') |
|||
|
|||
|
|||
def test_rc4(): |
|||
check_env() |
|||
run_method(b'rc4') |
|||
|
|||
|
|||
if __name__ == '__main__': |
|||
test_aes_128_cfb() |
@ -0,0 +1,83 @@ |
|||
#!/usr/bin/python |
|||
|
|||
import socket |
|||
import socks |
|||
|
|||
|
|||
SERVER_IP = '127.0.0.1' |
|||
SERVER_PORT = 1081 |
|||
|
|||
|
|||
if __name__ == '__main__': |
|||
# Test 1: same source port IPv4 |
|||
sock_out = socks.socksocket(socket.AF_INET, socket.SOCK_DGRAM, |
|||
socket.SOL_UDP) |
|||
sock_out.set_proxy(socks.SOCKS5, SERVER_IP, SERVER_PORT) |
|||
sock_out.bind(('127.0.0.1', 9000)) |
|||
|
|||
sock_in1 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, |
|||
socket.SOL_UDP) |
|||
sock_in2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, |
|||
socket.SOL_UDP) |
|||
|
|||
sock_in1.bind(('127.0.0.1', 9001)) |
|||
sock_in2.bind(('127.0.0.1', 9002)) |
|||
|
|||
sock_out.sendto(b'data', ('127.0.0.1', 9001)) |
|||
result1 = sock_in1.recvfrom(8) |
|||
|
|||
sock_out.sendto(b'data', ('127.0.0.1', 9002)) |
|||
result2 = sock_in2.recvfrom(8) |
|||
|
|||
sock_out.close() |
|||
sock_in1.close() |
|||
sock_in2.close() |
|||
|
|||
# make sure they're from the same source port |
|||
assert result1 == result2 |
|||
|
|||
# Test 2: same source port IPv6 |
|||
# try again from the same port but IPv6 |
|||
sock_out = socks.socksocket(socket.AF_INET, socket.SOCK_DGRAM, |
|||
socket.SOL_UDP) |
|||
sock_out.set_proxy(socks.SOCKS5, SERVER_IP, SERVER_PORT) |
|||
sock_out.bind(('127.0.0.1', 9000)) |
|||
|
|||
sock_in1 = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM, |
|||
socket.SOL_UDP) |
|||
sock_in2 = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM, |
|||
socket.SOL_UDP) |
|||
|
|||
sock_in1.bind(('::1', 9001)) |
|||
sock_in2.bind(('::1', 9002)) |
|||
|
|||
sock_out.sendto(b'data', ('::1', 9001)) |
|||
result1 = sock_in1.recvfrom(8) |
|||
|
|||
sock_out.sendto(b'data', ('::1', 9002)) |
|||
result2 = sock_in2.recvfrom(8) |
|||
|
|||
sock_out.close() |
|||
sock_in1.close() |
|||
sock_in2.close() |
|||
|
|||
# make sure they're from the same source port |
|||
assert result1 == result2 |
|||
|
|||
# Test 3: different source ports IPv6 |
|||
sock_out = socks.socksocket(socket.AF_INET, socket.SOCK_DGRAM, |
|||
socket.SOL_UDP) |
|||
sock_out.set_proxy(socks.SOCKS5, SERVER_IP, SERVER_PORT) |
|||
sock_out.bind(('127.0.0.1', 9003)) |
|||
|
|||
sock_in1 = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM, |
|||
socket.SOL_UDP) |
|||
sock_in1.bind(('::1', 9001)) |
|||
sock_out.sendto(b'data', ('::1', 9001)) |
|||
result3 = sock_in1.recvfrom(8) |
|||
|
|||
# make sure they're from different source ports |
|||
assert result1 != result3 |
|||
|
|||
sock_out.close() |
|||
sock_in1.close() |
@ -0,0 +1,23 @@ |
|||
#!/bin/bash |
|||
|
|||
PYTHON="coverage run -p" |
|||
|
|||
mkdir -p tmp |
|||
|
|||
$PYTHON shadowsocks/local.py -c tests/aes.json -v & |
|||
LOCAL=$! |
|||
|
|||
$PYTHON shadowsocks/server.py -c tests/aes.json --forbidden-ip "" -v & |
|||
SERVER=$! |
|||
|
|||
sleep 3 |
|||
|
|||
python tests/test_udp_src.py |
|||
r=$? |
|||
|
|||
kill -s SIGINT $LOCAL |
|||
kill -s SIGINT $SERVER |
|||
|
|||
sleep 2 |
|||
|
|||
exit $r |
Loading…
Reference in new issue