Skip to content

Commit fd4efca

Browse files
author
clowwindy
committed
add test
1 parent ed39505 commit fd4efca

File tree

8 files changed

+45
-8
lines changed

8 files changed

+45
-8
lines changed

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ python:
44
- 2.7
55
before_install:
66
- sudo apt-get update -qq
7-
- sudo apt-get install -qq build-essential libssl-dev swig libevent-dev python-gevent python-m2crypto
8-
- pip install gevent m2crypto
7+
- sudo apt-get install -qq build-essential libssl-dev swig libevent-dev python-gevent python-m2crypto python-numpy
8+
- pip install gevent m2crypto salsa20
99
script:
10-
- python test.py
10+
- python test.py -c test/table.json
11+
- python test.py -c test/aes.json
12+
- python test.py -c test/salsa20.json

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Install Shadowsocks.
2121

2222
#### Debian / Ubuntu:
2323

24-
apt-get install python-gevent python-m2crypto
24+
apt-get install python-pip python-gevent python-m2crypto
2525
pip install shadowsocks
2626

2727
#### CentOS:
@@ -94,6 +94,20 @@ You can use args to override settings from `config.json`.
9494
ssserver -p server_port -k password -m bf-cfb
9595
ssserver -c /etc/shadowsocks/config.json
9696

97+
Salsa20
98+
-------
99+
100+
Salsa20 is a fast stream cipher.
101+
102+
Use "salsa20-ctr" in shadowsocks.json.
103+
104+
And install these packages:
105+
106+
#### Debian / Ubuntu:
107+
108+
apt-get install python-numpy
109+
pip install salsa20
110+
97111
Wiki
98112
----
99113

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"local_port":1080,
55
"password":"barfoo!",
66
"timeout":300,
7-
"method":"table",
7+
"method":"aes-256-cfb",
88
"local_address":"127.0.0.1",
99
"fast_open":false
1010
}

shadowsocks/encrypt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ def get_cipher(self, password, method, op, iv=None):
151151
if m:
152152
key, iv_ = EVP_BytesToKey(password, m[0], m[1])
153153
if iv is None:
154-
iv = iv_[:m[1]]
154+
iv = iv_
155+
iv = iv[:m[1]]
155156
if op == 1:
156157
self.cipher_iv = iv[:m[1]] # this iv is for cipher not decipher
157158
if method != 'salsa20-ctr':

test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def get_table(key):
8282
for i in range(0, 256):
8383
assert(target2[0][i] == ord(encrypt_table[i]))
8484
assert(target2[1][i] == ord(decrypt_table[i]))
85-
p1 = Popen(['python', 'shadowsocks/server.py', '-c', 'test/config.json'], shell=False, bufsize=0, stdin=PIPE,
85+
p1 = Popen(['python', 'shadowsocks/server.py', '-c', sys.argv[-1]], shell=False, bufsize=0, stdin=PIPE,
8686
stdout=PIPE, stderr=PIPE, close_fds=True)
87-
p2 = Popen(['python', 'shadowsocks/local.py', '-c', 'test/config.json'], shell=False, bufsize=0, stdin=PIPE,
87+
p2 = Popen(['python', 'shadowsocks/local.py', '-c', sys.argv[-1]], shell=False, bufsize=0, stdin=PIPE,
8888
stdout=PIPE, stderr=PIPE, close_fds=True)
8989
p3 = None
9090

File renamed without changes.

test/salsa20.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"server":"127.0.0.1",
3+
"server_port":8388,
4+
"local_port":1080,
5+
"password":"barfoo!",
6+
"timeout":300,
7+
"method":"salsa20-ctr",
8+
"local_address":"127.0.0.1",
9+
"fast_open":false
10+
}

test/table.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"server":"127.0.0.1",
3+
"server_port":8388,
4+
"local_port":1080,
5+
"password":"barfoo!",
6+
"timeout":300,
7+
"method":"table",
8+
"local_address":"127.0.0.1",
9+
"fast_open":false
10+
}

0 commit comments

Comments
 (0)