Browse Source

add test

1.4
clowwindy 11 years ago
parent
commit
fd4efca0fe
  1. 8
      .travis.yml
  2. 16
      README.md
  3. 2
      config.json
  4. 3
      shadowsocks/encrypt.py
  5. 4
      test.py
  6. 0
      test/aes.json
  7. 10
      test/salsa20.json
  8. 10
      test/table.json

8
.travis.yml

@ -4,7 +4,9 @@ python:
- 2.7 - 2.7
before_install: before_install:
- sudo apt-get update -qq - sudo apt-get update -qq
- sudo apt-get install -qq build-essential libssl-dev swig libevent-dev python-gevent python-m2crypto - sudo apt-get install -qq build-essential libssl-dev swig libevent-dev python-gevent python-m2crypto python-numpy
- pip install gevent m2crypto - pip install gevent m2crypto salsa20
script: script:
- python test.py - python test.py -c test/table.json
- python test.py -c test/aes.json
- python test.py -c test/salsa20.json

16
README.md

@ -21,7 +21,7 @@ Install Shadowsocks.
#### Debian / Ubuntu: #### Debian / Ubuntu:
apt-get install python-gevent python-m2crypto apt-get install python-pip python-gevent python-m2crypto
pip install shadowsocks pip install shadowsocks
#### CentOS: #### CentOS:
@ -94,6 +94,20 @@ You can use args to override settings from `config.json`.
ssserver -p server_port -k password -m bf-cfb ssserver -p server_port -k password -m bf-cfb
ssserver -c /etc/shadowsocks/config.json ssserver -c /etc/shadowsocks/config.json
Salsa20
-------
Salsa20 is a fast stream cipher.
Use "salsa20-ctr" in shadowsocks.json.
And install these packages:
#### Debian / Ubuntu:
apt-get install python-numpy
pip install salsa20
Wiki Wiki
---- ----

2
config.json

@ -4,7 +4,7 @@
"local_port":1080, "local_port":1080,
"password":"barfoo!", "password":"barfoo!",
"timeout":300, "timeout":300,
"method":"table", "method":"aes-256-cfb",
"local_address":"127.0.0.1", "local_address":"127.0.0.1",
"fast_open":false "fast_open":false
} }

3
shadowsocks/encrypt.py

@ -151,7 +151,8 @@ class Encryptor(object):
if m: if m:
key, iv_ = EVP_BytesToKey(password, m[0], m[1]) key, iv_ = EVP_BytesToKey(password, m[0], m[1])
if iv is None: if iv is None:
iv = iv_[:m[1]] iv = iv_
iv = iv[:m[1]]
if op == 1: if op == 1:
self.cipher_iv = iv[:m[1]] # this iv is for cipher not decipher self.cipher_iv = iv[:m[1]] # this iv is for cipher not decipher
if method != 'salsa20-ctr': if method != 'salsa20-ctr':

4
test.py

@ -82,9 +82,9 @@ decrypt_table = string.maketrans(encrypt_table, string.maketrans('', ''))
for i in range(0, 256): for i in range(0, 256):
assert(target2[0][i] == ord(encrypt_table[i])) assert(target2[0][i] == ord(encrypt_table[i]))
assert(target2[1][i] == ord(decrypt_table[i])) assert(target2[1][i] == ord(decrypt_table[i]))
p1 = Popen(['python', 'shadowsocks/server.py', '-c', 'test/config.json'], shell=False, bufsize=0, stdin=PIPE, p1 = Popen(['python', 'shadowsocks/server.py', '-c', sys.argv[-1]], shell=False, bufsize=0, stdin=PIPE,
stdout=PIPE, stderr=PIPE, close_fds=True) stdout=PIPE, stderr=PIPE, close_fds=True)
p2 = Popen(['python', 'shadowsocks/local.py', '-c', 'test/config.json'], shell=False, bufsize=0, stdin=PIPE, p2 = Popen(['python', 'shadowsocks/local.py', '-c', sys.argv[-1]], shell=False, bufsize=0, stdin=PIPE,
stdout=PIPE, stderr=PIPE, close_fds=True) stdout=PIPE, stderr=PIPE, close_fds=True)
p3 = None p3 = None

0
test/config.json → test/aes.json

10
test/salsa20.json

@ -0,0 +1,10 @@
{
"server":"127.0.0.1",
"server_port":8388,
"local_port":1080,
"password":"barfoo!",
"timeout":300,
"method":"salsa20-ctr",
"local_address":"127.0.0.1",
"fast_open":false
}

10
test/table.json

@ -0,0 +1,10 @@
{
"server":"127.0.0.1",
"server_port":8388,
"local_port":1080,
"password":"barfoo!",
"timeout":300,
"method":"table",
"local_address":"127.0.0.1",
"fast_open":false
}
Loading…
Cancel
Save