File tree 4 files changed +58
-2
lines changed
4 files changed +58
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ before_install:
13
13
- sudo dd if=/dev/urandom of=/usr/share/nginx/www/file bs=1M count=10
14
14
- sudo sh -c "echo '127.0.0.1 localhost' > /etc/hosts"
15
15
- sudo service nginx restart
16
- - pip install pep8 pyflakes nose coverage
16
+ - pip install pep8 pyflakes nose coverage PySocks
17
17
- sudo tests/socksify/install.sh
18
18
- sudo tests/libsodium/install.sh
19
19
- sudo tests/setup_tc.sh
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ function run_test {
24
24
return 0
25
25
}
26
26
27
+ pip install PySocks
28
+
27
29
python --version
28
30
coverage erase
29
31
mkdir tmp
@@ -69,7 +71,7 @@ if [ -f /proc/sys/net/ipv4/tcp_fastopen ] ; then
69
71
fi
70
72
71
73
run_test tests/test_large_file.sh
72
-
74
+ run_test tests/test_udp_src.sh
73
75
run_test tests/test_command.sh
74
76
75
77
coverage combine && coverage report --include=shadowsocks/*
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/python
2
+
3
+ import socket
4
+ import socks
5
+
6
+ if __name__ == '__main__' :
7
+ sock_out = socks .socksocket (socket .AF_INET , socket .SOCK_DGRAM ,
8
+ socket .SOL_UDP )
9
+ sock_out .set_proxy (socks .SOCKS5 , '127.0.0.1' , 1081 )
10
+ sock_out .bind (('127.0.0.1' , 9000 ))
11
+
12
+ sock_in1 = socket .socket (socket .AF_INET , socket .SOCK_DGRAM ,
13
+ socket .SOL_UDP )
14
+ sock_in2 = socket .socket (socket .AF_INET , socket .SOCK_DGRAM ,
15
+ socket .SOL_UDP )
16
+
17
+ sock_in1 .bind (('127.0.0.1' , 9001 ))
18
+ sock_in2 .bind (('127.0.0.1' , 9002 ))
19
+
20
+ sock_out .sendto ('data' , ('127.0.0.1' , 9001 ))
21
+ result1 = sock_in1 .recvfrom (8 )
22
+
23
+ sock_out .sendto ('data' , ('127.0.0.1' , 9002 ))
24
+ result2 = sock_in2 .recvfrom (8 )
25
+
26
+ sock_out .close ()
27
+ sock_in1 .close ()
28
+ sock_in2 .close ()
29
+
30
+ # make sure they're from the same source port
31
+ assert result1 == result2
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ PYTHON=" coverage run -p -a"
4
+
5
+ mkdir -p tmp
6
+
7
+ $PYTHON shadowsocks/local.py -c tests/aes.json &
8
+ LOCAL=$!
9
+
10
+ $PYTHON shadowsocks/server.py -c tests/aes.json --forbidden-ip " " &
11
+ SERVER=$!
12
+
13
+ sleep 3
14
+
15
+ python tests/test_udp_src.py
16
+ r=$?
17
+
18
+ kill -s SIGINT $LOCAL
19
+ kill -s SIGINT $SERVER
20
+
21
+ sleep 2
22
+
23
+ exit $r
You can’t perform that action at this time.
0 commit comments