Compare commits
518 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
de7c05b449 | 9 years ago |
|
|
1ee344220a | 11 years ago |
|
|
a681a72b16 | 11 years ago |
|
|
2d695441d2 | 11 years ago |
|
|
7df3152608 | 11 years ago |
|
|
eebd5c548e | 11 years ago |
|
|
3db5a4918f | 11 years ago |
|
|
1e41de7d0b | 11 years ago |
|
|
9bb52acaf5 | 11 years ago |
|
|
b059b9ad85 | 11 years ago |
|
|
418cadb945 | 11 years ago |
|
|
c18b002754 | 11 years ago |
|
|
1bc0e60cfd | 11 years ago |
|
|
3200b7d4fe | 11 years ago |
|
|
8f402277e6 | 11 years ago |
|
|
a37623b0b7 | 11 years ago |
|
|
5b6dec5940 | 11 years ago |
|
|
a38db829f2 | 11 years ago |
|
|
d475076cdc | 12 years ago |
|
|
e751534234 | 12 years ago |
|
|
1bb0e51e8e | 12 years ago |
|
|
f7d69db6d1 | 12 years ago |
|
|
f55bd0302f | 12 years ago |
|
|
13a6bb007c | 12 years ago |
|
|
99b4121fd9 | 12 years ago |
|
|
c34c99450f | 12 years ago |
|
|
1a62694a3b | 12 years ago |
|
|
7c3e047449 | 12 years ago |
|
|
1b0504ade2 | 12 years ago |
|
|
a2edd6a46d | 12 years ago |
|
|
0edae7069f | 12 years ago |
|
|
e5b4a804e9 | 12 years ago |
|
|
3d1563ecac | 12 years ago |
|
|
c549929dfb | 12 years ago |
|
|
d065dba34f | 12 years ago |
|
|
f16749962a | 12 years ago |
|
|
62dca9d3cd | 12 years ago |
|
|
e001f1818c | 12 years ago |
|
|
56c289ba21 | 12 years ago |
|
|
e74ae193d0 | 12 years ago |
|
|
16db66675b | 12 years ago |
|
|
c46234af41 | 12 years ago |
|
|
405120c59f | 12 years ago |
|
|
082c8a80f4 | 12 years ago |
|
|
893d21da76 | 12 years ago |
|
|
ea7a3e1b58 | 12 years ago |
|
|
e898f92191 | 12 years ago |
|
|
5c0391d146 | 12 years ago |
|
|
e17279e5bf | 12 years ago |
|
|
f17da943b3 | 12 years ago |
|
|
d3831bef8c | 12 years ago |
|
|
b6e6e14b8a | 12 years ago |
|
|
4172639d48 | 12 years ago |
|
|
e8488895f0 | 12 years ago |
|
|
edb7822a7b | 12 years ago |
|
|
294556f8bc | 12 years ago |
|
|
1b7ab23f78 | 12 years ago |
|
|
0e14f3bbef | 12 years ago |
|
|
42ce2569c4 | 12 years ago |
|
|
581d6e687f | 12 years ago |
|
|
d774286dc0 | 12 years ago |
|
|
cb7062e1c1 | 12 years ago |
|
|
48ddc1714b | 12 years ago |
|
|
dfd81af844 | 12 years ago |
|
|
783a6ef7f2 | 12 years ago |
|
|
e71ce6c758 | 12 years ago |
|
|
e564f17505 | 12 years ago |
|
|
6d09cd21ca | 12 years ago |
|
|
318d88ec89 | 12 years ago |
|
|
ce805f0aea | 12 years ago |
|
|
96a86c028d | 12 years ago |
|
|
2c59ffb952 | 12 years ago |
|
|
27a0c7754d | 12 years ago |
|
|
0cd261dd10 | 12 years ago |
|
|
fbf15cb942 | 12 years ago |
|
|
1c81465436 | 12 years ago |
|
|
73f21ffbf6 | 12 years ago |
|
|
7aa37cad8e | 12 years ago |
|
|
ae99698b4e | 12 years ago |
|
|
da65d0a2ee | 12 years ago |
|
|
3b7755bd5e | 12 years ago |
|
|
5a7225c54b | 12 years ago |
|
|
4aba904d6e | 12 years ago |
|
|
b77f419336 | 12 years ago |
|
|
c39bbbe237 | 12 years ago |
|
|
453a9c61a6 | 12 years ago |
|
|
54181ef821 | 12 years ago |
|
|
17624d0b99 | 12 years ago |
|
|
a0aa9173a8 | 12 years ago |
|
|
79b9b53dbe | 12 years ago |
|
|
070108f78b | 12 years ago |
|
|
b11d848986 | 12 years ago |
|
|
aa28796524 | 12 years ago |
|
|
8af359ae05 | 12 years ago |
|
|
100ebcf064 | 12 years ago |
|
|
8783e0e9ae | 12 years ago |
|
|
ada97ab6d9 | 12 years ago |
|
|
5316b3bf11 | 12 years ago |
|
|
4a2d98b280 | 12 years ago |
|
|
51f47ccb91 | 12 years ago |
|
|
70ebd2ef28 | 12 years ago |
|
|
1f8819f790 | 12 years ago |
|
|
0e6a4cd8ff | 12 years ago |
|
|
f4052fbc84 | 12 years ago |
|
|
5e5d25efd9 | 12 years ago |
|
|
2e9ce11ea1 | 12 years ago |
|
|
6efb3d00e4 | 12 years ago |
|
|
13413267dc | 12 years ago |
|
|
bd22e3ef75 | 12 years ago |
|
|
5179e018e2 | 12 years ago |
|
|
af6c6f3f23 | 12 years ago |
|
|
5c05a74727 | 12 years ago |
|
|
53a7e4d0e4 | 12 years ago |
|
|
5e476843ec | 12 years ago |
|
|
32a6b8fd7a | 12 years ago |
|
|
9fe2f4ef16 | 12 years ago |
|
|
f7316c0047 | 12 years ago |
|
|
cc36de5a2f | 12 years ago |
|
|
4312eb9e58 | 12 years ago |
|
|
eb94bd1cc3 | 12 years ago |
|
|
f29bfb0cc7 | 12 years ago |
|
|
80b8bd7014 | 12 years ago |
|
|
a4b0ea5b8f | 12 years ago |
|
|
e582b2b929 | 12 years ago |
|
|
3d03dbf716 | 12 years ago |
|
|
1becc9362d | 12 years ago |
|
|
ebfd1486d8 | 12 years ago |
|
|
6eadfca78e | 12 years ago |
|
|
3294a92a61 | 12 years ago |
|
|
2711002142 | 12 years ago |
|
|
18da3554ff | 12 years ago |
|
|
a5fc1c7e5f | 12 years ago |
|
|
8b2deb01d8 | 12 years ago |
|
|
176e97bb45 | 12 years ago |
|
|
b6efc0efd9 | 12 years ago |
|
|
4598e09b78 | 12 years ago |
|
|
363965c364 | 12 years ago |
|
|
a90c354f42 | 12 years ago |
|
|
69d1d876bc | 12 years ago |
|
|
ae57ebde68 | 12 years ago |
|
|
09f8f1ccc8 | 12 years ago |
|
|
b12ba5383c | 12 years ago |
|
|
0bc0117cd7 | 12 years ago |
|
|
85cbac127d | 12 years ago |
|
|
f7a63a0ad7 | 12 years ago |
|
|
a3faf2c5fb | 12 years ago |
|
|
d01ef02b5a | 12 years ago |
|
|
1db1e4f4e9 | 12 years ago |
|
|
510dc64bf2 | 12 years ago |
|
|
8be120518b | 12 years ago |
|
|
e7984930d1 | 12 years ago |
|
|
b8f1825776 | 12 years ago |
|
|
dde25f89e1 | 12 years ago |
|
|
98f73e44d0 | 12 years ago |
|
|
e0189ab1de | 12 years ago |
|
|
e68b3e430b | 12 years ago |
|
|
bac675d7f6 | 12 years ago |
|
|
291adf8b85 | 12 years ago |
|
|
1423fe1921 | 12 years ago |
|
|
5a5c8b9c7e | 12 years ago |
|
|
70559a1030 | 12 years ago |
|
|
45ee594d58 | 12 years ago |
|
|
707b5c1def | 12 years ago |
|
|
d91f7d85d4 | 12 years ago |
|
|
5a5158b33f | 12 years ago |
|
|
7f19c31640 | 12 years ago |
|
|
937693519a | 12 years ago |
|
|
9e6e884b12 | 12 years ago |
|
|
e8501da271 | 12 years ago |
|
|
99c8bbafe7 | 12 years ago |
|
|
30f4f78557 | 12 years ago |
|
|
dd140814a8 | 12 years ago |
|
|
d228ffbe84 | 12 years ago |
|
|
ab975d1753 | 12 years ago |
|
|
c6bc912c11 | 12 years ago |
|
|
b785d95f66 | 12 years ago |
|
|
1d0c8b1800 | 12 years ago |
|
|
9cfffa360e | 12 years ago |
|
|
cd07001471 | 12 years ago |
|
|
2cc7ee5053 | 12 years ago |
|
|
9b3944c954 | 12 years ago |
|
|
f1b084be06 | 12 years ago |
|
|
5ea8403e56 | 12 years ago |
|
|
072afd68f2 | 12 years ago |
|
|
be1d1d5032 | 12 years ago |
|
|
536b7d1ee6 | 12 years ago |
|
|
c7b5a5a011 | 12 years ago |
|
|
be2ab378ff | 12 years ago |
|
|
2b4c3619d6 | 12 years ago |
|
|
dae2624b30 | 12 years ago |
|
|
fb789d8e9f | 12 years ago |
|
|
2733e6a4ba | 12 years ago |
|
|
35c3b0b41c | 12 years ago |
|
|
6dbabdea9d | 12 years ago |
|
|
28347b685e | 12 years ago |
|
|
134497c24f | 12 years ago |
|
|
78f93a091c | 12 years ago |
|
|
7274c7ad96 | 12 years ago |
|
|
706a137b3f | 12 years ago |
|
|
4b0b252953 | 12 years ago |
|
|
5257653440 | 12 years ago |
|
|
163992b98b | 12 years ago |
|
|
676bf9617b | 12 years ago |
|
|
cbbc880f44 | 12 years ago |
|
|
810db996cd | 12 years ago |
|
|
3e503bf677 | 12 years ago |
|
|
1459282ae6 | 12 years ago |
|
|
4d5d6c7c85 | 12 years ago |
|
|
a377cc3fb2 | 12 years ago |
|
|
92e49099b6 | 12 years ago |
|
|
95ed8a7576 | 12 years ago |
|
|
60c16fae69 | 12 years ago |
|
|
134bf332a4 | 12 years ago |
|
|
e1f2046229 | 12 years ago |
|
|
030cdbcec0 | 12 years ago |
|
|
d42a32fbc0 | 12 years ago |
|
|
2a149a5b3f | 12 years ago |
|
|
c214dbf7b5 | 12 years ago |
|
|
55630f5a7e | 12 years ago |
|
|
b4ce4b7f48 | 12 years ago |
|
|
5fe886efad | 12 years ago |
|
|
d7d9e5c103 | 12 years ago |
|
|
e6416562fc | 12 years ago |
|
|
9d33a59b60 | 12 years ago |
|
|
84dcff83c1 | 12 years ago |
|
|
ffcbf05975 | 12 years ago |
|
|
0a3730942f | 12 years ago |
|
|
fa31a233b6 | 12 years ago |
|
|
e476a54658 | 12 years ago |
|
|
f43906006a | 12 years ago |
|
|
ea535c74b2 | 12 years ago |
|
|
143750f699 | 12 years ago |
|
|
a8996b812b | 12 years ago |
|
|
70dae91e7c | 12 years ago |
|
|
b5010df575 | 12 years ago |
|
|
4e3c055406 | 12 years ago |
|
|
a88d47883b | 12 years ago |
|
|
6bbf347d0e | 12 years ago |
|
|
5209860db1 | 12 years ago |
|
|
f9ba6f7390 | 12 years ago |
|
|
710fe14190 | 12 years ago |
|
|
039451bcfb | 12 years ago |
|
|
cbf8c6705b | 12 years ago |
|
|
2519fb9abe | 12 years ago |
|
|
aca86f8685 | 12 years ago |
|
|
fb27cf52a9 | 12 years ago |
|
|
7ac8434983 | 12 years ago |
|
|
f02e9a3132 | 12 years ago |
|
|
9fe3cf17d5 | 12 years ago |
|
|
22b87f6f16 | 12 years ago |
|
|
d971cb44a8 | 12 years ago |
|
|
833c98e114 | 12 years ago |
|
|
4e08344035 | 12 years ago |
|
|
5892789005 | 12 years ago |
|
|
d64450915b | 12 years ago |
|
|
e6306f7b32 | 12 years ago |
|
|
90dc03c762 | 12 years ago |
|
|
4affb56d36 | 12 years ago |
|
|
13c6c393db | 12 years ago |
|
|
82ddafafa5 | 12 years ago |
|
|
1205b8c50e | 12 years ago |
|
|
812a286f12 | 12 years ago |
|
|
7bff002202 | 12 years ago |
|
|
c69a127772 | 12 years ago |
|
|
099323e28e | 12 years ago |
|
|
50e5e620a3 | 12 years ago |
|
|
aff411a456 | 12 years ago |
|
|
0719e80fbd | 12 years ago |
|
|
efd45ddfc6 | 12 years ago |
|
|
4699de1dd9 | 12 years ago |
|
|
a502dd32fc | 12 years ago |
|
|
5024b300f1 | 12 years ago |
|
|
be045f1687 | 12 years ago |
|
|
497524b313 | 12 years ago |
|
|
05ba3cc5aa | 12 years ago |
|
|
ede2b1b120 | 12 years ago |
|
|
753e46654d | 12 years ago |
|
|
f0b0c1edfa | 12 years ago |
|
|
0fd2f30911 | 12 years ago |
|
|
b409c18877 | 12 years ago |
|
|
53d1bfaecf | 12 years ago |
|
|
f98728a761 | 12 years ago |
|
|
2a53b67c65 | 12 years ago |
|
|
0814888ba5 | 12 years ago |
|
|
89dc6031e8 | 12 years ago |
|
|
c553e7a725 | 12 years ago |
|
|
ac94104ac0 | 12 years ago |
|
|
da11d02706 | 12 years ago |
|
|
03eecf1206 | 12 years ago |
|
|
8454220adc | 12 years ago |
|
|
3fc543cb7f | 12 years ago |
|
|
2461f623dd | 12 years ago |
|
|
89a9872308 | 12 years ago |
|
|
cd09638023 | 12 years ago |
|
|
9e8aa1c56a | 12 years ago |
|
|
b47de1dcf6 | 12 years ago |
|
|
0b64f7670f | 12 years ago |
|
|
eb9b6f0a9b | 12 years ago |
|
|
6609de4577 | 12 years ago |
|
|
dfd4cdd758 | 12 years ago |
|
|
1af7f84f41 | 12 years ago |
|
|
dda8f31bd3 | 12 years ago |
|
|
c668ddbc1b | 12 years ago |
|
|
f677c8152d | 12 years ago |
|
|
ab74c010fd | 12 years ago |
|
|
f0b0f6edff | 12 years ago |
|
|
81223902d0 | 12 years ago |
|
|
b3420f24c7 | 12 years ago |
|
|
4be2731293 | 12 years ago |
|
|
f6951c9633 | 12 years ago |
|
|
d6a5c567ae | 12 years ago |
|
|
402bc5743b | 12 years ago |
|
|
4ddc20945e | 12 years ago |
|
|
8114f7043a | 12 years ago |
|
|
0e649453ed | 12 years ago |
|
|
2122f96aeb | 12 years ago |
|
|
76fed23b34 | 12 years ago |
|
|
a2ed12611c | 12 years ago |
|
|
64503498d0 | 12 years ago |
|
|
5aece6f464 | 12 years ago |
|
|
e72594ffbe | 12 years ago |
|
|
3ce7c18dfb | 12 years ago |
|
|
ebf5baa311 | 12 years ago |
|
|
21f61c7d91 | 12 years ago |
|
|
2a61e80071 | 12 years ago |
|
|
ea70a5bd79 | 12 years ago |
|
|
380a646f09 | 12 years ago |
|
|
e43520da58 | 12 years ago |
|
|
fdb3a36170 | 12 years ago |
|
|
a6b8a5eef9 | 12 years ago |
|
|
327c70e353 | 12 years ago |
|
|
964d7613cb | 12 years ago |
|
|
3e3c885a42 | 12 years ago |
|
|
1044358a6b | 12 years ago |
|
|
1fea9dca8d | 12 years ago |
|
|
c9b489b5e3 | 12 years ago |
|
|
1e1b1adba9 | 12 years ago |
|
|
1b4e885818 | 12 years ago |
|
|
63fae5119d | 12 years ago |
|
|
f7a2878c6f | 12 years ago |
|
|
972bf22e6d | 12 years ago |
|
|
b468476c9c | 12 years ago |
|
|
eb7ef6e6e3 | 12 years ago |
|
|
a2cdc291fc | 12 years ago |
|
|
7ac2967d29 | 12 years ago |
|
|
6d16175636 | 12 years ago |
|
|
fcdb1a3402 | 12 years ago |
|
|
78f7ee2ca1 | 12 years ago |
|
|
47d0183b80 | 12 years ago |
|
|
a053b1e110 | 12 years ago |
|
|
b0be74ad48 | 12 years ago |
|
|
f7288e3490 | 12 years ago |
|
|
858dd5a62e | 12 years ago |
|
|
eafc3ab547 | 12 years ago |
|
|
8d74b6276e | 12 years ago |
|
|
48780fed24 | 12 years ago |
|
|
3b242bee5e | 12 years ago |
|
|
c7d2d76767 | 12 years ago |
|
|
e51aa4f137 | 12 years ago |
|
|
8165904eaf | 12 years ago |
|
|
4c29b54b7d | 12 years ago |
|
|
ca6f72e22b | 12 years ago |
|
|
fb7e83a753 | 12 years ago |
|
|
72fe18212e | 12 years ago |
|
|
da842918bd | 13 years ago |
|
|
da13e768b0 | 13 years ago |
|
|
c1cf02cbea | 13 years ago |
|
|
68b9a063c5 | 13 years ago |
|
|
0df13b5715 | 13 years ago |
|
|
c66d9b2c20 | 13 years ago |
|
|
e7e226768a | 13 years ago |
|
|
fed480bb17 | 13 years ago |
|
|
a323f878e1 | 13 years ago |
|
|
edeb66395a | 13 years ago |
|
|
a1bc23c161 | 13 years ago |
|
|
2950f99da6 | 13 years ago |
|
|
040c956472 | 13 years ago |
|
|
c788aa59b6 | 13 years ago |
|
|
122f233143 | 13 years ago |
|
|
68cf94b10e | 13 years ago |
|
|
130cf8fe35 | 13 years ago |
|
|
d97e351b88 | 13 years ago |
|
|
a614dd6e5b | 13 years ago |
|
|
b0c8e50492 | 13 years ago |
|
|
13436b224e | 13 years ago |
|
|
1d7d015cd3 | 13 years ago |
|
|
b7bfdb9918 | 13 years ago |
|
|
d82441e0b4 | 13 years ago |
|
|
63ed7a1bc6 | 13 years ago |
|
|
f4e68dc64e | 13 years ago |
|
|
012ab70500 | 13 years ago |
|
|
d4458bceb7 | 13 years ago |
|
|
5b193d6f92 | 13 years ago |
|
|
868c7c5b38 | 13 years ago |
|
|
bbd649b1c1 | 13 years ago |
|
|
61d9e17cae | 13 years ago |
|
|
f9fef0e229 | 13 years ago |
|
|
1dd722acc7 | 13 years ago |
|
|
9dd3922189 | 13 years ago |
|
|
c3ae04d07d | 13 years ago |
|
|
4b3c018aa9 | 13 years ago |
|
|
0592fcefbd | 13 years ago |
|
|
4fd19a7714 | 13 years ago |
|
|
cb5481499e | 13 years ago |
|
|
41010d810e | 13 years ago |
|
|
6c6afde2a5 | 13 years ago |
|
|
d639a375bc | 13 years ago |
|
|
d949d11b28 | 13 years ago |
|
|
35bfa56eaf | 13 years ago |
|
|
46d23bf0d4 | 13 years ago |
|
|
e811bdb891 | 13 years ago |
|
|
e594478852 | 13 years ago |
|
|
743d3cddb5 | 13 years ago |
|
|
a0e1a9f1b0 | 13 years ago |
|
|
08e351a55d | 13 years ago |
|
|
f19fb4ed8e | 13 years ago |
|
|
1c847a9a58 | 13 years ago |
|
|
eeda2c258d | 13 years ago |
|
|
3c0024cef0 | 13 years ago |
|
|
c1a6dc4c9e | 13 years ago |
|
|
71b4d34ce4 | 13 years ago |
|
|
a68b9a0520 | 13 years ago |
|
|
ed5888387b | 13 years ago |
|
|
f5caa5b3d2 | 13 years ago |
|
|
06a87c385b | 13 years ago |
|
|
a109f571e3 | 13 years ago |
|
|
df836bed77 | 13 years ago |
|
|
4fb6b9df98 | 13 years ago |
|
|
a7592b8625 | 13 years ago |
|
|
9422ef2fd3 | 13 years ago |
|
|
cb2e2ce0df | 13 years ago |
|
|
917acdf499 | 13 years ago |
|
|
2306add1df | 13 years ago |
|
|
4faf5cf8ae | 13 years ago |
|
|
4cc979b998 | 13 years ago |
|
|
6e93bdd5a5 | 13 years ago |
|
|
26fa1ab555 | 13 years ago |
|
|
24eadfbb5f | 13 years ago |
|
|
bcdc1e9671 | 13 years ago |
|
|
5c274a1bc7 | 13 years ago |
|
|
cdd333ea97 | 13 years ago |
|
|
de5461a17e | 13 years ago |
|
|
71c3759c12 | 13 years ago |
|
|
fbc4906445 | 13 years ago |
|
|
9c0bab297e | 13 years ago |
|
|
5fd2f3d6ee | 13 years ago |
|
|
45f9998fa9 | 13 years ago |
|
|
6b76319495 | 13 years ago |
|
|
7a77205530 | 13 years ago |
|
|
795e0f4b8e | 13 years ago |
|
|
4b630d0814 | 13 years ago |
|
|
d7d125082f | 13 years ago |
|
|
816592b674 | 13 years ago |
|
|
a185e1671b | 13 years ago |
|
|
c354d8a8af | 13 years ago |
|
|
d88d2802b0 | 13 years ago |
|
|
aab163f067 | 13 years ago |
|
|
a7bdac3578 | 13 years ago |
|
|
f3defc8b92 | 13 years ago |
|
|
dbaf83eb7b | 13 years ago |
|
|
e98e9232e8 | 13 years ago |
|
|
d3f294217c | 13 years ago |
|
|
a3748a292d | 13 years ago |
|
|
b50a89b1f5 | 13 years ago |
|
|
5f29cd6fb5 | 13 years ago |
|
|
f832628968 | 13 years ago |
|
|
345696cf29 | 13 years ago |
|
|
816eee8dc1 | 13 years ago |
|
|
8aae1f07ca | 13 years ago |
|
|
944c422768 | 13 years ago |
|
|
a08edd2007 | 13 years ago |
|
|
8d25047d56 | 13 years ago |
|
|
adda6d6e29 | 13 years ago |
|
|
0c12ee04cb | 13 years ago |
|
|
f6a9cad684 | 13 years ago |
|
|
fd6a0a8af0 | 13 years ago |
|
|
30e8d5d1a1 | 13 years ago |
|
|
6c35dfd832 | 13 years ago |
|
|
904498fdc7 | 13 years ago |
|
|
476738d273 | 13 years ago |
|
|
5d022e2828 | 13 years ago |
|
|
1966b643fc | 13 years ago |
|
|
74566308d1 | 13 years ago |
|
|
baebe31df0 | 13 years ago |
|
|
66bbe50719 | 13 years ago |
|
|
c5bcb9a050 | 13 years ago |
|
|
0e662e04b6 | 13 years ago |
|
|
cadf0e11bb | 13 years ago |
|
|
c225b808d6 | 13 years ago |
|
|
e66636867a | 13 years ago |
|
|
bbad408ace | 13 years ago |
|
|
d69272767f | 13 years ago |
|
|
fe01025ba7 | 13 years ago |
|
|
0c8a8ef23f | 13 years ago |
|
|
5e19fdc66b | 13 years ago |
|
|
7a1647278f | 13 years ago |
|
|
7a98331655 | 13 years ago |
|
|
77f74a0668 | 13 years ago |
|
|
21ab52c62b | 13 years ago |
|
|
20ba04c4ce | 13 years ago |
|
|
2672a6378e | 13 years ago |
|
|
fd35f1d067 | 13 years ago |
|
|
f49d086d6a | 13 years ago |
|
|
c721a1c02f | 13 years ago |
|
|
3cefe374c2 | 13 years ago |
|
|
5e9a9c9beb | 13 years ago |
|
|
cd22d474fe | 13 years ago |
|
|
47fd479d6e | 13 years ago |
|
|
bacf9cb443 | 13 years ago |
|
|
4ccf4081b3 | 13 years ago |
|
|
9b2a45583e | 13 years ago |
|
|
c2f6bc369c | 13 years ago |
|
|
d1aec8bc28 | 13 years ago |
|
|
0d6c39900b | 13 years ago |
|
|
2cdddd4515 | 13 years ago |
|
|
4f46400145 | 13 years ago |
|
|
5ad8cd6f3d | 13 years ago |
|
|
1868487c11 | 13 years ago |
@ -1,105 +0,0 @@
|
||||
1.4.5 2014-05-24
|
||||
- Add timeout in TCP server
|
||||
- Close sockets in master process
|
||||
|
||||
1.4.4 2014-05-17
|
||||
- Support multiple workers
|
||||
|
||||
1.4.3 2014-05-13
|
||||
- Fix Windows
|
||||
|
||||
1.4.2 2014-05-10
|
||||
- Add salsa20-ctr cipher
|
||||
|
||||
1.4.1 2014-05-03
|
||||
- Fix error log
|
||||
- Fix EINPROGESS with some version of gevent
|
||||
|
||||
1.4.0 2014-05-02
|
||||
- Adds UDP relay
|
||||
- TCP fast open support on Linux 3.7+
|
||||
|
||||
1.3.7 2014-04-10
|
||||
- Fix a typo in help
|
||||
|
||||
1.3.6 2014-04-10
|
||||
- Fix a typo in help
|
||||
|
||||
1.3.5 2014-04-07
|
||||
- Add help
|
||||
- Change default local binding address into 127.0.0.1
|
||||
|
||||
1.3.4 2014-02-17
|
||||
- Fix a bug when no config file exists
|
||||
- Client now support multiple server ports and multiple server/port pairs
|
||||
- Better error message with bad config.json format and wrong password
|
||||
|
||||
1.3.3 2013-07-09
|
||||
- Fix default key length of rc2
|
||||
|
||||
1.3.2 2013-07-04
|
||||
- Server will listen at server IP specified in config
|
||||
- Check config file and show some warning messages
|
||||
|
||||
1.3.1 2013-06-29
|
||||
- Fix -c arg
|
||||
|
||||
1.3.0 2013-06-22
|
||||
- Move to pypi
|
||||
|
||||
1.2.3 2013-06-14
|
||||
- add bind address
|
||||
|
||||
1.2.2 2013-05-31
|
||||
- local can listen at ::0 with -6 arg; bump 1.2.2
|
||||
|
||||
1.2.1 2013-05-23
|
||||
- Fix an OpenSSL crash
|
||||
|
||||
1.2 2013-05-22
|
||||
- Use random iv, we finally have strong encryption
|
||||
|
||||
1.1.1 2013-05-21
|
||||
- Add encryption, AES, blowfish, etc.
|
||||
|
||||
1.1 2013-05-16
|
||||
- Support IPv6 addresses (type 4)
|
||||
- Drop Python 2.5 support
|
||||
|
||||
1.0 2013-04-03
|
||||
- Fix -6 IPv6
|
||||
|
||||
0.9.4 2013-03-04
|
||||
- Support Python 2.5
|
||||
|
||||
0.9.3 2013-01-14
|
||||
- Fix conn termination null data
|
||||
|
||||
0.9.2 2013-01-05
|
||||
- Change default timeout
|
||||
|
||||
0.9.1 2013-01-05
|
||||
- Add Travis-CI test
|
||||
|
||||
0.9 2012-12-30
|
||||
- Replace send with sendall, fix FreeBSD
|
||||
|
||||
0.6 2012-12-06
|
||||
- Support args
|
||||
|
||||
0.5 2012-11-08
|
||||
- Fix encryption with negative md5sum
|
||||
|
||||
0.4 2012-11-02
|
||||
- Move config into a JSON file
|
||||
- Auto-detect config path
|
||||
|
||||
0.3 2012-06-06
|
||||
- Move socks5 negotiation to local
|
||||
|
||||
0.2 2012-05-11
|
||||
- Add -6 arg for IPv6
|
||||
- Fix socket.error
|
||||
|
||||
0.1 2012-04-20
|
||||
- Initial version
|
||||
@ -1,21 +0,0 @@
|
||||
Shadowsocks
|
||||
|
||||
Copyright (c) 2013 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.
|
||||
@ -1,138 +1 @@
|
||||
shadowsocks
|
||||
===========
|
||||
|
||||
Current version: 1.4.5 [![Build Status][1]][0]
|
||||
|
||||
shadowsocks is a lightweight tunnel proxy which can help you get through firewalls.
|
||||
|
||||
Both TCP CONNECT and UDP ASSOCIATE are implemented.
|
||||
|
||||
[中文说明][3]
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
First, make sure you have Python 2.6 or 2.7.
|
||||
|
||||
$ python --version
|
||||
Python 2.6.8
|
||||
|
||||
Install Shadowsocks.
|
||||
|
||||
#### Debian / Ubuntu:
|
||||
|
||||
apt-get install python-pip python-gevent python-m2crypto
|
||||
pip install shadowsocks
|
||||
|
||||
#### CentOS:
|
||||
|
||||
yum install m2crypto python-setuptools
|
||||
easy_install pip
|
||||
pip install shadowsocks
|
||||
|
||||
#### OS X:
|
||||
|
||||
git clone https://github.com/clowwindy/M2Crypto.git
|
||||
cd M2Crypto
|
||||
pip install .
|
||||
pip install shadowsocks
|
||||
|
||||
#### Windows:
|
||||
|
||||
Choose a [GUI client][7]
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Create a config file `/etc/shadowsocks.json` (or put it in other path).
|
||||
Example:
|
||||
|
||||
{
|
||||
"server":"my_server_ip",
|
||||
"server_port":8388,
|
||||
"local_address": "127.0.0.1",
|
||||
"local_port":1080,
|
||||
"password":"mypassword",
|
||||
"timeout":300,
|
||||
"method":"aes-256-cfb",
|
||||
"fast_open": false,
|
||||
"workers": 1
|
||||
}
|
||||
|
||||
Explanation of the fields:
|
||||
|
||||
| Name | Explanation |
|
||||
| ------------- | ----------------------------------------------- |
|
||||
| server | the address your server listens |
|
||||
| server_port | server port |
|
||||
| local_address | the address your local listens |
|
||||
| local_port | local port |
|
||||
| password | password used for encryption |
|
||||
| timeout | in seconds |
|
||||
| method | encryption method, "aes-256-cfb" is recommended |
|
||||
| fast_open | use [TCP_FASTOPEN][2], true / false |
|
||||
| workers | number of workers, available on Unix/Linux |
|
||||
|
||||
Run `ssserver -c /etc/shadowsocks.json` on your server. To run it in the background, [use supervisor][8].
|
||||
|
||||
On your client machine, run `sslocal -c /etc/shadowsocks.json`.
|
||||
|
||||
Change the proxy settings in your browser to
|
||||
|
||||
protocol: socks5
|
||||
hostname: 127.0.0.1
|
||||
port: your local_port
|
||||
|
||||
**Notice: If you want to use encryption methods other than "table", please install M2Crypto (See Encryption Section).**
|
||||
|
||||
It's recommended to use shadowsocks with AutoProxy or Proxy SwitchySharp.
|
||||
|
||||
Command line args
|
||||
------------------
|
||||
|
||||
You can use args to override settings from `config.json`.
|
||||
|
||||
sslocal -s server_name -p server_port -l local_port -k password -m bf-cfb
|
||||
ssserver -p server_port -k password -m bf-cfb --workers 2
|
||||
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
|
||||
----
|
||||
|
||||
https://github.com/clowwindy/shadowsocks/wiki
|
||||
|
||||
License
|
||||
-------
|
||||
MIT
|
||||
|
||||
Bugs and Issues
|
||||
----------------
|
||||
Please visit [issue tracker][5]
|
||||
|
||||
Mailing list: http://groups.google.com/group/shadowsocks
|
||||
|
||||
Also see [troubleshooting][6]
|
||||
|
||||
[0]: https://travis-ci.org/clowwindy/shadowsocks
|
||||
[1]: https://travis-ci.org/clowwindy/shadowsocks.png?branch=master
|
||||
[2]: https://github.com/clowwindy/shadowsocks/wiki/TCP-Fast-Open
|
||||
[3]: https://github.com/clowwindy/shadowsocks/wiki/Shadowsocks-%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E
|
||||
[4]: http://chandlerproject.org/Projects/MeTooCrypto
|
||||
[5]: https://github.com/clowwindy/shadowsocks/issues?state=open
|
||||
[6]: https://github.com/clowwindy/shadowsocks/wiki/Troubleshooting
|
||||
[7]: https://github.com/clowwindy/shadowsocks/wiki/Ports-and-Clients
|
||||
[8]: https://github.com/clowwindy/shadowsocks/wiki/Configure-Shadowsocks-with-Supervisor
|
||||
:)
|
||||
|
||||
@ -1,170 +0,0 @@
|
||||
shadowsocks
|
||||
===========
|
||||
|
||||
shadowsocks is a lightweight tunnel proxy which can help you get through
|
||||
firewalls.
|
||||
|
||||
Both TCP CONNECT and UDP ASSOCIATE are implemented.
|
||||
|
||||
`中文说明 <https://github.com/clowwindy/shadowsocks/wiki/Shadowsocks-%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E>`__
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
First, make sure you have Python 2.6 or 2.7.
|
||||
|
||||
::
|
||||
|
||||
$ python --version
|
||||
Python 2.6.8
|
||||
|
||||
Install Shadowsocks.
|
||||
|
||||
Debian / Ubuntu:
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
apt-get install python-pip python-gevent python-m2crypto
|
||||
pip install shadowsocks
|
||||
|
||||
CentOS:
|
||||
^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
yum install m2crypto python-setuptools
|
||||
easy_install pip
|
||||
pip install shadowsocks
|
||||
|
||||
OS X:
|
||||
^^^^^
|
||||
|
||||
::
|
||||
|
||||
git clone https://github.com/clowwindy/M2Crypto.git
|
||||
cd M2Crypto
|
||||
pip install .
|
||||
pip install shadowsocks
|
||||
|
||||
Windows:
|
||||
^^^^^^^^
|
||||
|
||||
Choose a `GUI
|
||||
client <https://github.com/clowwindy/shadowsocks/wiki/Ports-and-Clients>`__
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Create a config file ``/etc/shadowsocks.json`` (or put it in other
|
||||
path). Example:
|
||||
|
||||
::
|
||||
|
||||
{
|
||||
"server":"my_server_ip",
|
||||
"server_port":8388,
|
||||
"local_address": "127.0.0.1",
|
||||
"local_port":1080,
|
||||
"password":"mypassword",
|
||||
"timeout":300,
|
||||
"method":"aes-256-cfb",
|
||||
"fast_open": false,
|
||||
"workers": 1
|
||||
}
|
||||
|
||||
Explanation of the fields:
|
||||
|
||||
+------------------+-----------------------------------------------------------------------------------------------------+
|
||||
| Name | Explanation |
|
||||
+==================+=====================================================================================================+
|
||||
| server | the address your server listens |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------+
|
||||
| server\_port | server port |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------+
|
||||
| local\_address | the address your local listens |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------+
|
||||
| local\_port | local port |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------+
|
||||
| password | password used for encryption |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------+
|
||||
| timeout | in seconds |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------+
|
||||
| method | encryption method, "aes-256-cfb" is recommended |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------+
|
||||
| fast\_open | use `TCP\_FASTOPEN <https://github.com/clowwindy/shadowsocks/wiki/TCP-Fast-Open>`__, true / false |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------+
|
||||
| workers | number of workers, available on Unix/Linux |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------+
|
||||
|
||||
Run ``ssserver -c /etc/shadowsocks.json`` on your server. To run it in
|
||||
the background, `use
|
||||
supervisor <https://github.com/clowwindy/shadowsocks/wiki/Configure-Shadowsocks-with-Supervisor>`__.
|
||||
|
||||
On your client machine, run ``sslocal -c /etc/shadowsocks.json``.
|
||||
|
||||
Change the proxy settings in your browser to
|
||||
|
||||
::
|
||||
|
||||
protocol: socks5
|
||||
hostname: 127.0.0.1
|
||||
port: your local_port
|
||||
|
||||
**Notice: If you want to use encryption methods other than "table",
|
||||
please install M2Crypto (See Encryption Section).**
|
||||
|
||||
It's recommended to use shadowsocks with AutoProxy or Proxy
|
||||
SwitchySharp.
|
||||
|
||||
Command line args
|
||||
-----------------
|
||||
|
||||
You can use args to override settings from ``config.json``.
|
||||
|
||||
::
|
||||
|
||||
sslocal -s server_name -p server_port -l local_port -k password -m bf-cfb
|
||||
ssserver -p server_port -k password -m bf-cfb --workers 2
|
||||
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
|
||||
----
|
||||
|
||||
https://github.com/clowwindy/shadowsocks/wiki
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
MIT
|
||||
|
||||
Bugs and Issues
|
||||
---------------
|
||||
|
||||
Please visit `issue
|
||||
tracker <https://github.com/clowwindy/shadowsocks/issues?state=open>`__
|
||||
|
||||
Mailing list: http://groups.google.com/group/shadowsocks
|
||||
|
||||
Also see
|
||||
`troubleshooting <https://github.com/clowwindy/shadowsocks/wiki/Troubleshooting>`__
|
||||
|
||||
.. |Build Status| image:: https://travis-ci.org/clowwindy/shadowsocks.png?branch=master
|
||||
:target: https://travis-ci.org/clowwindy/shadowsocks
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"server":"0.0.0.0",
|
||||
"server_port":8388,
|
||||
"local_port":1080,
|
||||
"password":"barfoo!",
|
||||
"timeout":300,
|
||||
"method":"aes-256-cfb",
|
||||
"local_address":"127.0.0.1",
|
||||
"fast_open":false
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
from distutils.core import setup
|
||||
# NOTICE!!
|
||||
# This setup.py is written for py2exe
|
||||
# Don't make a python package using this file!
|
||||
|
||||
try:
|
||||
import py2exe
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
setup(name='shadowsocks',
|
||||
version='1.2.3',
|
||||
description='a lightweight tunnel proxy which can help you get through firewalls',
|
||||
author='clowwindy',
|
||||
author_email='clowwindy42@gmail.com',
|
||||
url='https://github.com/clowwindy/shadowsocks',
|
||||
options = {'py2exe': {'bundle_files': 1, 'compressed': True}},
|
||||
windows = [{"script":"local.py", "dest_base": "shadowsocks_local",}],
|
||||
zipfile = None)
|
||||
@ -1,33 +0,0 @@
|
||||
from setuptools import setup
|
||||
|
||||
|
||||
with open('README.rst') as f:
|
||||
long_description = f.read()
|
||||
|
||||
setup(
|
||||
name="shadowsocks",
|
||||
version="1.4.5",
|
||||
license='MIT',
|
||||
description="a lightweight tunnel proxy",
|
||||
author='clowwindy',
|
||||
author_email='clowwindy42@gmail.com',
|
||||
url='https://github.com/clowwindy/shadowsocks',
|
||||
packages=['shadowsocks'],
|
||||
package_data={
|
||||
'shadowsocks': ['README.rst', 'LICENSE', 'config.json']
|
||||
},
|
||||
install_requires=['setuptools'],
|
||||
entry_points="""
|
||||
[console_scripts]
|
||||
sslocal = shadowsocks.local:main
|
||||
ssserver = shadowsocks.server:main
|
||||
""",
|
||||
classifiers=[
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 2.6',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Topic :: Internet :: Proxy Servers',
|
||||
],
|
||||
long_description=long_description,
|
||||
)
|
||||
@ -1 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
@ -1,226 +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.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import hashlib
|
||||
import string
|
||||
import struct
|
||||
import logging
|
||||
import encrypt_salsa20
|
||||
|
||||
|
||||
def random_string(length):
|
||||
try:
|
||||
import M2Crypto.Rand
|
||||
return M2Crypto.Rand.rand_bytes(length)
|
||||
except ImportError:
|
||||
# TODO really strong enough on Linux?
|
||||
return os.urandom(length)
|
||||
|
||||
|
||||
cached_tables = {}
|
||||
cached_keys = {}
|
||||
|
||||
|
||||
def get_table(key):
|
||||
m = hashlib.md5()
|
||||
m.update(key)
|
||||
s = m.digest()
|
||||
(a, b) = struct.unpack('<QQ', s)
|
||||
table = [c for c in string.maketrans('', '')]
|
||||
for i in xrange(1, 1024):
|
||||
table.sort(lambda x, y: int(a % (ord(x) + i) - a % (ord(y) + i)))
|
||||
return table
|
||||
|
||||
|
||||
def init_table(key, method=None):
|
||||
if method is not None and method == 'table':
|
||||
method = None
|
||||
if method:
|
||||
try:
|
||||
__import__('M2Crypto')
|
||||
except ImportError:
|
||||
logging.error('M2Crypto is required to use encryption other than '
|
||||
'default method')
|
||||
sys.exit(1)
|
||||
if not method:
|
||||
if key in cached_tables:
|
||||
return cached_tables[key]
|
||||
encrypt_table = ''.join(get_table(key))
|
||||
decrypt_table = string.maketrans(encrypt_table,
|
||||
string.maketrans('', ''))
|
||||
cached_tables[key] = [encrypt_table, decrypt_table]
|
||||
else:
|
||||
try:
|
||||
Encryptor(key, method) # test if the settings if OK
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def EVP_BytesToKey(password, key_len, iv_len):
|
||||
# equivalent to OpenSSL's EVP_BytesToKey() with count 1
|
||||
# so that we make the same key and iv as nodejs version
|
||||
password = str(password)
|
||||
r = cached_keys.get(password, None)
|
||||
if r:
|
||||
return r
|
||||
m = []
|
||||
i = 0
|
||||
while len(''.join(m)) < (key_len + iv_len):
|
||||
md5 = hashlib.md5()
|
||||
data = password
|
||||
if i > 0:
|
||||
data = m[i - 1] + password
|
||||
md5.update(data)
|
||||
m.append(md5.digest())
|
||||
i += 1
|
||||
ms = ''.join(m)
|
||||
key = ms[:key_len]
|
||||
iv = ms[key_len:key_len + iv_len]
|
||||
cached_keys[password] = (key, iv)
|
||||
return (key, iv)
|
||||
|
||||
|
||||
method_supported = {
|
||||
'aes-128-cfb': (16, 16),
|
||||
'aes-192-cfb': (24, 16),
|
||||
'aes-256-cfb': (32, 16),
|
||||
'bf-cfb': (16, 8),
|
||||
'camellia-128-cfb': (16, 16),
|
||||
'camellia-192-cfb': (24, 16),
|
||||
'camellia-256-cfb': (32, 16),
|
||||
'cast5-cfb': (16, 8),
|
||||
'des-cfb': (8, 8),
|
||||
'idea-cfb': (16, 8),
|
||||
'rc2-cfb': (16, 8),
|
||||
'rc4': (16, 0),
|
||||
'seed-cfb': (16, 16),
|
||||
'salsa20-ctr': (32, 8),
|
||||
}
|
||||
|
||||
|
||||
class Encryptor(object):
|
||||
def __init__(self, key, method=None):
|
||||
if method == 'table':
|
||||
method = None
|
||||
self.key = key
|
||||
self.method = method
|
||||
self.iv = None
|
||||
self.iv_sent = False
|
||||
self.cipher_iv = ''
|
||||
self.decipher = None
|
||||
if method:
|
||||
self.cipher = self.get_cipher(key, method, 1, iv=random_string(32))
|
||||
else:
|
||||
self.encrypt_table, self.decrypt_table = init_table(key)
|
||||
self.cipher = None
|
||||
|
||||
def get_cipher_len(self, method):
|
||||
method = method.lower()
|
||||
m = method_supported.get(method, None)
|
||||
return m
|
||||
|
||||
def iv_len(self):
|
||||
return len(self.cipher_iv)
|
||||
|
||||
def get_cipher(self, password, method, op, iv=None):
|
||||
password = password.encode('utf-8')
|
||||
method = method.lower()
|
||||
m = self.get_cipher_len(method)
|
||||
if m:
|
||||
key, iv_ = EVP_BytesToKey(password, m[0], m[1])
|
||||
if iv is None:
|
||||
iv = iv_
|
||||
iv = iv[:m[1]]
|
||||
if op == 1:
|
||||
self.cipher_iv = iv[:m[1]] # this iv is for cipher not decipher
|
||||
if method != 'salsa20-ctr':
|
||||
import M2Crypto.EVP
|
||||
return M2Crypto.EVP.Cipher(method.replace('-', '_'), key, iv, op,
|
||||
key_as_bytes=0, d='md5', salt=None, i=1,
|
||||
padding=1)
|
||||
else:
|
||||
return encrypt_salsa20.Salsa20Cipher(method, key, iv, op)
|
||||
|
||||
logging.error('method %s not supported' % method)
|
||||
sys.exit(1)
|
||||
|
||||
def encrypt(self, buf):
|
||||
if len(buf) == 0:
|
||||
return buf
|
||||
if not self.method:
|
||||
return string.translate(buf, self.encrypt_table)
|
||||
else:
|
||||
if self.iv_sent:
|
||||
return self.cipher.update(buf)
|
||||
else:
|
||||
self.iv_sent = True
|
||||
return self.cipher_iv + self.cipher.update(buf)
|
||||
|
||||
def decrypt(self, buf):
|
||||
if len(buf) == 0:
|
||||
return buf
|
||||
if not self.method:
|
||||
return string.translate(buf, self.decrypt_table)
|
||||
else:
|
||||
if self.decipher is None:
|
||||
decipher_iv_len = self.get_cipher_len(self.method)[1]
|
||||
decipher_iv = buf[:decipher_iv_len]
|
||||
self.decipher = self.get_cipher(self.key, self.method, 0,
|
||||
iv=decipher_iv)
|
||||
buf = buf[decipher_iv_len:]
|
||||
if len(buf) == 0:
|
||||
return buf
|
||||
return self.decipher.update(buf)
|
||||
|
||||
|
||||
def encrypt_all(password, method, op, data):
|
||||
if method is not None and method.lower() == 'table':
|
||||
method = None
|
||||
if not method:
|
||||
[encrypt_table, decrypt_table] = init_table(password)
|
||||
if op:
|
||||
return string.translate(encrypt_table, data)
|
||||
else:
|
||||
return string.translate(decrypt_table, data)
|
||||
else:
|
||||
import M2Crypto.EVP
|
||||
result = []
|
||||
method = method.lower()
|
||||
(key_len, iv_len) = method_supported[method]
|
||||
(key, _) = EVP_BytesToKey(password, key_len, iv_len)
|
||||
if op:
|
||||
iv = random_string(iv_len)
|
||||
result.append(iv)
|
||||
else:
|
||||
iv = data[:iv_len]
|
||||
data = data[iv_len:]
|
||||
cipher = M2Crypto.EVP.Cipher(method.replace('-', '_'), key, iv, op,
|
||||
key_as_bytes=0, d='md5', salt=None, i=1,
|
||||
padding=1)
|
||||
result.append(cipher.update(data))
|
||||
f = cipher.final()
|
||||
if f:
|
||||
result.append(f)
|
||||
return ''.join(result)
|
||||
@ -1,132 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import time
|
||||
import struct
|
||||
import logging
|
||||
import sys
|
||||
|
||||
slow_xor = False
|
||||
imported = False
|
||||
|
||||
BLOCK_SIZE = 16384
|
||||
|
||||
|
||||
def run_imports():
|
||||
global imported, slow_xor, salsa20, numpy
|
||||
if not imported:
|
||||
imported = True
|
||||
try:
|
||||
import numpy
|
||||
except ImportError:
|
||||
logging.error('can not import numpy, using SLOW XOR')
|
||||
logging.error('please install numpy if you use salsa20')
|
||||
slow_xor = True
|
||||
try:
|
||||
import salsa20
|
||||
except ImportError:
|
||||
logging.error('you have to install salsa20 before you use salsa20')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def numpy_xor(a, b):
|
||||
if slow_xor:
|
||||
return py_xor_str(a, b)
|
||||
dtype = numpy.byte
|
||||
if len(a) % 4 == 0:
|
||||
dtype = numpy.uint32
|
||||
elif len(a) % 2 == 0:
|
||||
dtype = numpy.uint16
|
||||
|
||||
ab = numpy.frombuffer(a, dtype=dtype)
|
||||
bb = numpy.frombuffer(b, dtype=dtype)
|
||||
c = numpy.bitwise_xor(ab, bb)
|
||||
r = c.tostring()
|
||||
return r
|
||||
|
||||
|
||||
def py_xor_str(a, b):
|
||||
c = []
|
||||
for i in xrange(0, len(a)):
|
||||
c.append(chr(ord(a[i]) ^ ord(b[i])))
|
||||
return ''.join(c)
|
||||
|
||||
|
||||
class Salsa20Cipher(object):
|
||||
"""a salsa20 CTR implemetation, provides m2crypto like cipher API"""
|
||||
|
||||
def __init__(self, alg, key, iv, op, key_as_bytes=0, d=None, salt=None,
|
||||
i=1, padding=1):
|
||||
run_imports()
|
||||
if alg != 'salsa20-ctr':
|
||||
raise Exception('unknown algorithm')
|
||||
self._key = key
|
||||
self._nonce = struct.unpack('<Q', iv)[0]
|
||||
self._pos = 0
|
||||
self._next_stream()
|
||||
|
||||
def _next_stream(self):
|
||||
self._nonce &= 0xFFFFFFFFFFFFFFFF
|
||||
self._stream = salsa20.Salsa20_keystream(BLOCK_SIZE,
|
||||
struct.pack('<Q', self._nonce),
|
||||
self._key)
|
||||
self._nonce += 1
|
||||
|
||||
def update(self, data):
|
||||
results = []
|
||||
while True:
|
||||
remain = BLOCK_SIZE - self._pos
|
||||
cur_data = data[:remain]
|
||||
cur_data_len = len(cur_data)
|
||||
cur_stream = self._stream[self._pos:self._pos + cur_data_len]
|
||||
self._pos = self._pos + cur_data_len
|
||||
data = data[remain:]
|
||||
|
||||
results.append(numpy_xor(cur_data, cur_stream))
|
||||
|
||||
if self._pos >= BLOCK_SIZE:
|
||||
self._next_stream()
|
||||
self._pos = 0
|
||||
if not data:
|
||||
break
|
||||
return ''.join(results)
|
||||
|
||||
|
||||
def test():
|
||||
from os import urandom
|
||||
import random
|
||||
|
||||
rounds = 1 * 1024
|
||||
plain = urandom(BLOCK_SIZE * rounds)
|
||||
import M2Crypto.EVP
|
||||
# cipher = M2Crypto.EVP.Cipher('aes_128_cfb', 'k' * 32, 'i' * 16, 1,
|
||||
# key_as_bytes=0, d='md5', salt=None, i=1,
|
||||
# padding=1)
|
||||
# decipher = M2Crypto.EVP.Cipher('aes_128_cfb', 'k' * 32, 'i' * 16, 0,
|
||||
# key_as_bytes=0, d='md5', salt=None, i=1,
|
||||
# padding=1)
|
||||
|
||||
cipher = Salsa20Cipher('salsa20-ctr', 'k' * 32, 'i' * 8, 1)
|
||||
decipher = Salsa20Cipher('salsa20-ctr', 'k' * 32, 'i' * 8, 1)
|
||||
results = []
|
||||
pos = 0
|
||||
print 'start'
|
||||
start = time.time()
|
||||
while pos < len(plain):
|
||||
l = random.randint(100, 32768)
|
||||
c = cipher.update(plain[pos:pos + l])
|
||||
results.append(c)
|
||||
pos += l
|
||||
pos = 0
|
||||
c = ''.join(results)
|
||||
results = []
|
||||
while pos < len(plain):
|
||||
l = random.randint(100, 32768)
|
||||
results.append(decipher.update(c[pos:pos + l]))
|
||||
pos += l
|
||||
end = time.time()
|
||||
print BLOCK_SIZE * rounds / (end - start)
|
||||
assert ''.join(results) == plain
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test()
|
||||
@ -1,189 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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 ssloop
|
||||
# https://github.com/clowwindy/ssloop
|
||||
|
||||
|
||||
import select
|
||||
from collections import defaultdict
|
||||
|
||||
|
||||
__all__ = ['EventLoop', 'POLL_NULL', 'POLL_IN', 'POLL_OUT', 'POLL_ERR',
|
||||
'POLL_HUP', 'POLL_NVAL']
|
||||
|
||||
POLL_NULL = 0x00
|
||||
POLL_IN = 0x01
|
||||
POLL_OUT = 0x04
|
||||
POLL_ERR = 0x08
|
||||
POLL_HUP = 0x10
|
||||
POLL_NVAL = 0x20
|
||||
|
||||
|
||||
class EpollLoop(object):
|
||||
|
||||
def __init__(self):
|
||||
self._epoll = select.epoll()
|
||||
|
||||
def poll(self, timeout):
|
||||
return self._epoll.poll(timeout)
|
||||
|
||||
def add_fd(self, fd, mode):
|
||||
self._epoll.register(fd, mode)
|
||||
|
||||
def remove_fd(self, fd):
|
||||
self._epoll.unregister(fd)
|
||||
|
||||
def modify_fd(self, fd, mode):
|
||||
self._epoll.modify(fd, mode)
|
||||
|
||||
|
||||
class KqueueLoop(object):
|
||||
|
||||
MAX_EVENTS = 1024
|
||||
|
||||
def __init__(self):
|
||||
self._kqueue = select.kqueue()
|
||||
self._fds = {}
|
||||
|
||||
def _control(self, fd, mode, flags):
|
||||
events = []
|
||||
if mode & POLL_IN:
|
||||
events.append(select.kevent(fd, select.KQ_FILTER_READ, flags))
|
||||
if mode & POLL_OUT:
|
||||
events.append(select.kevent(fd, select.KQ_FILTER_WRITE, flags))
|
||||
for e in events:
|
||||
self._kqueue.control([e], 0)
|
||||
|
||||
def poll(self, timeout):
|
||||
if timeout < 0:
|
||||
timeout = None # kqueue behaviour
|
||||
events = self._kqueue.control(None, KqueueLoop.MAX_EVENTS, timeout)
|
||||
results = defaultdict(lambda: POLL_NULL)
|
||||
for e in events:
|
||||
fd = e.ident
|
||||
if e.filter == select.KQ_FILTER_READ:
|
||||
results[fd] |= POLL_IN
|
||||
elif e.filter == select.KQ_FILTER_WRITE:
|
||||
results[fd] |= POLL_OUT
|
||||
return results.iteritems()
|
||||
|
||||
def add_fd(self, fd, mode):
|
||||
self._fds[fd] = mode
|
||||
self._control(fd, mode, select.KQ_EV_ADD)
|
||||
|
||||
def remove_fd(self, fd):
|
||||
self._control(fd, self._fds[fd], select.KQ_EV_DELETE)
|
||||
del self._fds[fd]
|
||||
|
||||
def modify_fd(self, fd, mode):
|
||||
self.remove_fd(fd)
|
||||
self.add_fd(fd, mode)
|
||||
|
||||
|
||||
class SelectLoop(object):
|
||||
|
||||
def __init__(self):
|
||||
self._r_list = set()
|
||||
self._w_list = set()
|
||||
self._x_list = set()
|
||||
|
||||
def poll(self, timeout):
|
||||
r, w, x = select.select(self._r_list, self._w_list, self._x_list,
|
||||
timeout)
|
||||
results = defaultdict(lambda: POLL_NULL)
|
||||
for p in [(r, POLL_IN), (w, POLL_OUT), (x, POLL_ERR)]:
|
||||
for fd in p[0]:
|
||||
results[fd] |= p[1]
|
||||
return results.items()
|
||||
|
||||
def add_fd(self, fd, mode):
|
||||
if mode & POLL_IN:
|
||||
self._r_list.add(fd)
|
||||
if mode & POLL_OUT:
|
||||
self._w_list.add(fd)
|
||||
if mode & POLL_ERR:
|
||||
self._x_list.add(fd)
|
||||
|
||||
def remove_fd(self, fd):
|
||||
if fd in self._r_list:
|
||||
self._r_list.remove(fd)
|
||||
if fd in self._w_list:
|
||||
self._w_list.remove(fd)
|
||||
if fd in self._x_list:
|
||||
self._x_list.remove(fd)
|
||||
|
||||
def modify_fd(self, fd, mode):
|
||||
self.remove_fd(fd)
|
||||
self.add_fd(fd, mode)
|
||||
|
||||
|
||||
class EventLoop(object):
|
||||
def __init__(self):
|
||||
if hasattr(select, 'epoll'):
|
||||
self._impl = EpollLoop()
|
||||
elif hasattr(select, 'kqueue'):
|
||||
self._impl = KqueueLoop()
|
||||
elif hasattr(select, 'select'):
|
||||
self._impl = SelectLoop()
|
||||
else:
|
||||
raise Exception('can not find any available functions in select '
|
||||
'package')
|
||||
self._fd_to_f = {}
|
||||
|
||||
def poll(self, timeout=None):
|
||||
events = self._impl.poll(timeout)
|
||||
return ((self._fd_to_f[fd], event) for fd, event in events)
|
||||
|
||||
def add(self, f, mode):
|
||||
fd = f.fileno()
|
||||
self._fd_to_f[fd] = f
|
||||
self._impl.add_fd(fd, mode)
|
||||
|
||||
def remove(self, f):
|
||||
fd = f.fileno()
|
||||
self._fd_to_f[fd] = None
|
||||
self._impl.remove_fd(fd)
|
||||
|
||||
def modify(self, f, mode):
|
||||
fd = f.fileno()
|
||||
self._impl.modify_fd(fd, mode)
|
||||
|
||||
|
||||
# from tornado
|
||||
def errno_from_exception(e):
|
||||
"""Provides the errno from an Exception object.
|
||||
|
||||
There are cases that the errno attribute was not set so we pull
|
||||
the errno out of the args but if someone instatiates an Exception
|
||||
without any args you will get a tuple error. So this function
|
||||
abstracts all that behavior to give you a safe way to get the
|
||||
errno.
|
||||
"""
|
||||
|
||||
if hasattr(e, 'errno'):
|
||||
return e.errno
|
||||
elif e.args:
|
||||
return e.args[0]
|
||||
else:
|
||||
return None
|
||||
@ -1,374 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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 with_statement
|
||||
import sys
|
||||
if sys.version_info < (2, 6):
|
||||
import simplejson as json
|
||||
else:
|
||||
import json
|
||||
|
||||
try:
|
||||
import gevent
|
||||
import gevent.monkey
|
||||
gevent.monkey.patch_all(dns=gevent.version_info[0] >= 1)
|
||||
except ImportError:
|
||||
gevent = None
|
||||
print >>sys.stderr, 'warning: gevent not found, using threading instead'
|
||||
|
||||
import socket
|
||||
import eventloop
|
||||
import errno
|
||||
import select
|
||||
import SocketServer
|
||||
import struct
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import logging
|
||||
import getopt
|
||||
import encrypt
|
||||
import utils
|
||||
import udprelay
|
||||
|
||||
|
||||
MSG_FASTOPEN = 0x20000000
|
||||
|
||||
|
||||
def send_all(sock, data):
|
||||
bytes_sent = 0
|
||||
while True:
|
||||
r = sock.send(data[bytes_sent:])
|
||||
if r < 0:
|
||||
return r
|
||||
bytes_sent += r
|
||||
if bytes_sent == len(data):
|
||||
return bytes_sent
|
||||
|
||||
|
||||
class ThreadingTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
|
||||
allow_reuse_address = True
|
||||
|
||||
def get_request(self):
|
||||
connection = self.socket.accept()
|
||||
connection[0].settimeout(config_timeout)
|
||||
return connection
|
||||
|
||||
|
||||
class Socks5Server(SocketServer.StreamRequestHandler):
|
||||
@staticmethod
|
||||
def get_server():
|
||||
a_port = config_server_port
|
||||
a_server = config_server
|
||||
if isinstance(config_server_port, list):
|
||||
# support config like "server_port": [8081, 8082]
|
||||
a_port = random.choice(config_server_port)
|
||||
if isinstance(config_server, list):
|
||||
# support config like "server": ["123.123.123.1", "123.123.123.2"]
|
||||
a_server = random.choice(config_server)
|
||||
|
||||
r = re.match(r'^(.*):(\d+)$', a_server)
|
||||
if r:
|
||||
# support config like "server": "123.123.123.1:8381"
|
||||
# or "server": ["123.123.123.1:8381", "123.123.123.2:8381"]
|
||||
a_server = r.group(1)
|
||||
a_port = int(r.group(2))
|
||||
return a_server, a_port
|
||||
|
||||
@staticmethod
|
||||
def handle_tcp(sock, remote, encryptor, pending_data=None,
|
||||
server=None, port=None):
|
||||
connected = False
|
||||
try:
|
||||
if config_fast_open:
|
||||
fdset = [sock]
|
||||
else:
|
||||
fdset = [sock, remote]
|
||||
while True:
|
||||
should_break = False
|
||||
r, w, e = select.select(fdset, [], [], config_timeout)
|
||||
if not r:
|
||||
logging.warn('read time out')
|
||||
break
|
||||
if sock in r:
|
||||
if not connected and config_fast_open:
|
||||
data = sock.recv(4096)
|
||||
data = encryptor.encrypt(pending_data + data)
|
||||
pending_data = None
|
||||
logging.info('fast open %s:%d' % (server, port))
|
||||
try:
|
||||
remote.sendto(data, MSG_FASTOPEN, (server, port))
|
||||
except (OSError, IOError) as e:
|
||||
if eventloop.errno_from_exception(e) == errno.EINPROGRESS:
|
||||
pass
|
||||
else:
|
||||
raise e
|
||||
connected = True
|
||||
fdset = [sock, remote]
|
||||
else:
|
||||
data = sock.recv(4096)
|
||||
if pending_data:
|
||||
data = pending_data + data
|
||||
pending_data = None
|
||||
data = encryptor.encrypt(data)
|
||||
if len(data) <= 0:
|
||||
should_break = True
|
||||
else:
|
||||
result = send_all(remote, data)
|
||||
if result < len(data):
|
||||
raise Exception('failed to send all data')
|
||||
|
||||
if remote in r:
|
||||
data = encryptor.decrypt(remote.recv(4096))
|
||||
if len(data) <= 0:
|
||||
should_break = True
|
||||
else:
|
||||
result = send_all(sock, data)
|
||||
if result < len(data):
|
||||
raise Exception('failed to send all data')
|
||||
if should_break:
|
||||
# make sure all data are read before we close the sockets
|
||||
# TODO: we haven't read ALL the data, actually
|
||||
# http://cs.ecs.baylor.edu/~donahoo/practical/CSockets/TCPRST.pdf
|
||||
break
|
||||
finally:
|
||||
sock.close()
|
||||
remote.close()
|
||||
|
||||
def handle(self):
|
||||
try:
|
||||
encryptor = encrypt.Encryptor(config_password, config_method)
|
||||
sock = self.connection
|
||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||
data = sock.recv(262)
|
||||
if not data:
|
||||
sock.close()
|
||||
return
|
||||
if len(data) < 3:
|
||||
return
|
||||
method = ord(data[2])
|
||||
if method == 2:
|
||||
logging.warn('client tries to use username/password auth, prete'
|
||||
'nding the password is OK')
|
||||
sock.send('\x05\x02')
|
||||
try:
|
||||
ver_ulen = sock.recv(2)
|
||||
ulen = ord(ver_ulen[1])
|
||||
if ulen:
|
||||
username = sock.recv(ulen)
|
||||
assert(ulen == len(username))
|
||||
plen = ord(sock.recv(1))
|
||||
if plen:
|
||||
_password = sock.recv(plen)
|
||||
assert(plen == len(_password))
|
||||
sock.send('\x01\x00')
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
return
|
||||
elif method == 0:
|
||||
sock.send("\x05\x00")
|
||||
else:
|
||||
logging.error('unsupported method %d' % method)
|
||||
return
|
||||
data = self.rfile.read(4) or '\x00' * 4
|
||||
mode = ord(data[1])
|
||||
if mode == 1:
|
||||
pass
|
||||
elif mode == 3:
|
||||
# UDP
|
||||
logging.debug('UDP assc request')
|
||||
if sock.family == socket.AF_INET6:
|
||||
header = '\x05\x00\x00\x04'
|
||||
else:
|
||||
header = '\x05\x00\x00\x01'
|
||||
addr, port = sock.getsockname()
|
||||
addr_to_send = socket.inet_pton(sock.family, addr)
|
||||
port_to_send = struct.pack('>H', port)
|
||||
sock.send(header + addr_to_send + port_to_send)
|
||||
while True:
|
||||
data = sock.recv(4096)
|
||||
if not data:
|
||||
break
|
||||
return
|
||||
else:
|
||||
logging.warn('unknown mode %d' % mode)
|
||||
return
|
||||
addrtype = ord(data[3])
|
||||
addr_to_send = data[3]
|
||||
if addrtype == 1:
|
||||
addr_ip = self.rfile.read(4)
|
||||
addr = socket.inet_ntoa(addr_ip)
|
||||
addr_to_send += addr_ip
|
||||
elif addrtype == 3:
|
||||
addr_len = self.rfile.read(1)
|
||||
addr = self.rfile.read(ord(addr_len))
|
||||
addr_to_send += addr_len + addr
|
||||
elif addrtype == 4:
|
||||
addr_ip = self.rfile.read(16)
|
||||
addr = socket.inet_ntop(socket.AF_INET6, addr_ip)
|
||||
addr_to_send += addr_ip
|
||||
else:
|
||||
logging.warn('addr_type not supported')
|
||||
# not supported
|
||||
return
|
||||
addr_port = self.rfile.read(2)
|
||||
addr_to_send += addr_port
|
||||
port = struct.unpack('>H', addr_port)
|
||||
try:
|
||||
reply = "\x05\x00\x00\x01"
|
||||
reply += socket.inet_aton('0.0.0.0') + struct.pack(">H", 2222)
|
||||
self.wfile.write(reply)
|
||||
# reply immediately
|
||||
a_server, a_port = Socks5Server.get_server()
|
||||
addrs = socket.getaddrinfo(a_server, a_port)
|
||||
if addrs:
|
||||
af, socktype, proto, canonname, sa = addrs[0]
|
||||
if config_fast_open:
|
||||
remote = socket.socket(af, socktype, proto)
|
||||
remote.setsockopt(socket.IPPROTO_TCP,
|
||||
socket.TCP_NODELAY, 1)
|
||||
Socks5Server.handle_tcp(sock, remote, encryptor,
|
||||
addr_to_send, a_server, a_port)
|
||||
else:
|
||||
logging.info('connecting %s:%d' % (addr, port[0]))
|
||||
remote = socket.create_connection((a_server, a_port),
|
||||
timeout=config_timeout)
|
||||
remote.settimeout(config_timeout)
|
||||
remote.setsockopt(socket.IPPROTO_TCP,
|
||||
socket.TCP_NODELAY, 1)
|
||||
Socks5Server.handle_tcp(sock, remote, encryptor,
|
||||
addr_to_send)
|
||||
except (OSError, IOError) as e:
|
||||
logging.warn(e)
|
||||
return
|
||||
except (OSError, IOError) as e:
|
||||
raise e
|
||||
logging.warn(e)
|
||||
|
||||
|
||||
def main():
|
||||
global config_server, config_server_port, config_password, config_method,\
|
||||
config_fast_open, config_timeout
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s %(levelname)-8s %(message)s',
|
||||
datefmt='%Y-%m-%d %H:%M:%S', filemode='a+')
|
||||
|
||||
# fix py2exe
|
||||
if hasattr(sys, "frozen") and sys.frozen in \
|
||||
("windows_exe", "console_exe"):
|
||||
p = os.path.dirname(os.path.abspath(sys.executable))
|
||||
os.chdir(p)
|
||||
version = ''
|
||||
try:
|
||||
import pkg_resources
|
||||
version = pkg_resources.get_distribution('shadowsocks').version
|
||||
except:
|
||||
pass
|
||||
print 'shadowsocks %s' % version
|
||||
|
||||
config_password = None
|
||||
config_method = None
|
||||
|
||||
config_path = utils.find_config()
|
||||
try:
|
||||
optlist, args = getopt.getopt(sys.argv[1:], 's:b:p:k:l:m:c:t:',
|
||||
['fast-open'])
|
||||
for key, value in optlist:
|
||||
if key == '-c':
|
||||
config_path = value
|
||||
|
||||
if config_path:
|
||||
logging.info('loading config from %s' % config_path)
|
||||
with open(config_path, 'rb') as f:
|
||||
try:
|
||||
config = json.load(f)
|
||||
except ValueError as e:
|
||||
logging.error('found an error in config.json: %s',
|
||||
e.message)
|
||||
sys.exit(1)
|
||||
else:
|
||||
config = {}
|
||||
|
||||
optlist, args = getopt.getopt(sys.argv[1:], 's:b:p:k:l:m:c:t:',
|
||||
['fast-open'])
|
||||
for key, value in optlist:
|
||||
if key == '-p':
|
||||
config['server_port'] = int(value)
|
||||
elif key == '-k':
|
||||
config['password'] = value
|
||||
elif key == '-l':
|
||||
config['local_port'] = int(value)
|
||||
elif key == '-s':
|
||||
config['server'] = value
|
||||
elif key == '-m':
|
||||
config['method'] = value
|
||||
elif key == '-b':
|
||||
config['local_address'] = value
|
||||
elif key == '--fast-open':
|
||||
config['fast_open'] = True
|
||||
except getopt.GetoptError as e:
|
||||
logging.error(e)
|
||||
utils.print_local_help()
|
||||
sys.exit(2)
|
||||
|
||||
config_server = config['server']
|
||||
config_server_port = config['server_port']
|
||||
config_local_port = config['local_port']
|
||||
config_password = config['password']
|
||||
config_method = config.get('method', None)
|
||||
config_local_address = config.get('local_address', '127.0.0.1')
|
||||
config_timeout = int(config.get('timeout', 300))
|
||||
config_fast_open = config.get('fast_open', False)
|
||||
|
||||
if not config_password and not config_path:
|
||||
sys.exit('config not specified, please read '
|
||||
'https://github.com/clowwindy/shadowsocks')
|
||||
|
||||
utils.check_config(config)
|
||||
|
||||
encrypt.init_table(config_password, config_method)
|
||||
|
||||
addrs = socket.getaddrinfo(config_local_address, config_local_port)
|
||||
if not addrs:
|
||||
logging.error('cant resolve listen address')
|
||||
sys.exit(1)
|
||||
ThreadingTCPServer.address_family = addrs[0][0]
|
||||
try:
|
||||
udprelay.UDPRelay(config_local_address, int(config_local_port),
|
||||
config_server, config_server_port, config_password,
|
||||
config_method, int(config_timeout), True).start()
|
||||
server = ThreadingTCPServer((config_local_address, config_local_port),
|
||||
Socks5Server)
|
||||
server.timeout = int(config_timeout)
|
||||
logging.info("starting local at %s:%d" %
|
||||
tuple(server.server_address[:2]))
|
||||
server.serve_forever()
|
||||
except socket.error, e:
|
||||
logging.error(e)
|
||||
except KeyboardInterrupt:
|
||||
server.shutdown()
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@ -1,64 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import collections
|
||||
import logging
|
||||
import heapq
|
||||
import time
|
||||
|
||||
|
||||
class LRUCache(collections.MutableMapping):
|
||||
"""This class is not thread safe"""
|
||||
|
||||
def __init__(self, timeout=60, close_callback=None, *args, **kwargs):
|
||||
self.timeout = timeout
|
||||
self.close_callback = close_callback
|
||||
self.store = {}
|
||||
self.time_to_keys = collections.defaultdict(list)
|
||||
self.last_visits = []
|
||||
self.update(dict(*args, **kwargs)) # use the free update to set keys
|
||||
|
||||
def __getitem__(self, key):
|
||||
"O(logm)"
|
||||
t = time.time()
|
||||
self.time_to_keys[t].append(key)
|
||||
heapq.heappush(self.last_visits, t)
|
||||
return self.store[key]
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
"O(logm)"
|
||||
t = time.time()
|
||||
self.store[key] = value
|
||||
self.time_to_keys[t].append(key)
|
||||
heapq.heappush(self.last_visits, t)
|
||||
|
||||
def __delitem__(self, key):
|
||||
"O(1)"
|
||||
del self.store[key]
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.store)
|
||||
|
||||
def __len__(self):
|
||||
return len(self.store)
|
||||
|
||||
def sweep(self):
|
||||
"O(m)"
|
||||
now = time.time()
|
||||
c = 0
|
||||
while len(self.last_visits) > 0:
|
||||
least = self.last_visits[0]
|
||||
if now - least <= self.timeout:
|
||||
break
|
||||
for key in self.time_to_keys[least]:
|
||||
heapq.heappop(self.last_visits)
|
||||
if self.store.__contains__(key):
|
||||
value = self.store[key]
|
||||
if self.close_callback is not None:
|
||||
self.close_callback(value)
|
||||
|
||||
del self.store[key]
|
||||
c += 1
|
||||
del self.time_to_keys[least]
|
||||
if c:
|
||||
logging.debug('%d keys swept' % c)
|
||||
@ -1,322 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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 with_statement
|
||||
import sys
|
||||
if sys.version_info < (2, 6):
|
||||
import simplejson as json
|
||||
else:
|
||||
import json
|
||||
|
||||
|
||||
# TODO remove gevent
|
||||
try:
|
||||
import gevent
|
||||
import gevent.monkey
|
||||
gevent.monkey.patch_all(dns=gevent.version_info[0] >= 1)
|
||||
except ImportError:
|
||||
gevent = None
|
||||
print >>sys.stderr, 'warning: gevent not found, using threading instead'
|
||||
|
||||
|
||||
import socket
|
||||
import select
|
||||
import threading
|
||||
import SocketServer
|
||||
import struct
|
||||
import logging
|
||||
import getopt
|
||||
import encrypt
|
||||
import os
|
||||
import utils
|
||||
import udprelay
|
||||
|
||||
|
||||
def send_all(sock, data):
|
||||
bytes_sent = 0
|
||||
while True:
|
||||
r = sock.send(data[bytes_sent:])
|
||||
if r < 0:
|
||||
return r
|
||||
bytes_sent += r
|
||||
if bytes_sent == len(data):
|
||||
return bytes_sent
|
||||
|
||||
|
||||
class ThreadingTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
|
||||
allow_reuse_address = True
|
||||
|
||||
def server_activate(self):
|
||||
if config_fast_open:
|
||||
try:
|
||||
self.socket.setsockopt(socket.SOL_TCP, 23, 5)
|
||||
except socket.error:
|
||||
logging.error('warning: fast open is not available')
|
||||
self.socket.listen(self.request_queue_size)
|
||||
|
||||
def get_request(self):
|
||||
connection = self.socket.accept()
|
||||
connection[0].settimeout(config_timeout)
|
||||
return connection
|
||||
|
||||
|
||||
class Socks5Server(SocketServer.StreamRequestHandler):
|
||||
def handle_tcp(self, sock, remote):
|
||||
try:
|
||||
fdset = [sock, remote]
|
||||
while True:
|
||||
should_break = False
|
||||
r, w, e = select.select(fdset, [], [], config_timeout)
|
||||
if not r:
|
||||
logging.warn('read time out')
|
||||
break
|
||||
if sock in r:
|
||||
data = self.decrypt(sock.recv(4096))
|
||||
if len(data) <= 0:
|
||||
should_break = True
|
||||
else:
|
||||
result = send_all(remote, data)
|
||||
if result < len(data):
|
||||
raise Exception('failed to send all data')
|
||||
if remote in r:
|
||||
data = self.encrypt(remote.recv(4096))
|
||||
if len(data) <= 0:
|
||||
should_break = True
|
||||
else:
|
||||
result = send_all(sock, data)
|
||||
if result < len(data):
|
||||
raise Exception('failed to send all data')
|
||||
if should_break:
|
||||
# make sure all data are read before we close the sockets
|
||||
# TODO: we haven't read ALL the data, actually
|
||||
# http://cs.ecs.baylor.edu/~donahoo/practical/CSockets/TCPRST.pdf
|
||||
break
|
||||
|
||||
finally:
|
||||
sock.close()
|
||||
remote.close()
|
||||
|
||||
def encrypt(self, data):
|
||||
return self.encryptor.encrypt(data)
|
||||
|
||||
def decrypt(self, data):
|
||||
return self.encryptor.decrypt(data)
|
||||
|
||||
def handle(self):
|
||||
try:
|
||||
self.encryptor = encrypt.Encryptor(self.server.key,
|
||||
self.server.method)
|
||||
sock = self.connection
|
||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||
iv_len = self.encryptor.iv_len()
|
||||
data = sock.recv(iv_len)
|
||||
if iv_len > 0 and not data:
|
||||
sock.close()
|
||||
return
|
||||
if iv_len:
|
||||
self.decrypt(data)
|
||||
data = sock.recv(1)
|
||||
if not data:
|
||||
sock.close()
|
||||
return
|
||||
addrtype = ord(self.decrypt(data))
|
||||
if addrtype == 1:
|
||||
addr = socket.inet_ntoa(self.decrypt(self.rfile.read(4)))
|
||||
elif addrtype == 3:
|
||||
addr = self.decrypt(
|
||||
self.rfile.read(ord(self.decrypt(sock.recv(1)))))
|
||||
elif addrtype == 4:
|
||||
addr = socket.inet_ntop(socket.AF_INET6,
|
||||
self.decrypt(self.rfile.read(16)))
|
||||
else:
|
||||
# not supported
|
||||
logging.warn('addr_type not supported, maybe wrong password')
|
||||
return
|
||||
port = struct.unpack('>H', self.decrypt(self.rfile.read(2)))
|
||||
try:
|
||||
logging.info('connecting %s:%d' % (addr, port[0]))
|
||||
remote = socket.create_connection((addr, port[0]),
|
||||
timeout=config_timeout)
|
||||
remote.settimeout(config_timeout)
|
||||
remote.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||
except socket.error, e:
|
||||
# Connection refused
|
||||
logging.warn(e)
|
||||
return
|
||||
self.handle_tcp(sock, remote)
|
||||
except socket.error, e:
|
||||
logging.warn(e)
|
||||
|
||||
|
||||
def main():
|
||||
global config_server, config_server_port, config_method, config_fast_open, \
|
||||
config_timeout
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s %(levelname)-8s %(message)s',
|
||||
datefmt='%Y-%m-%d %H:%M:%S', filemode='a+')
|
||||
|
||||
|
||||
version = ''
|
||||
try:
|
||||
import pkg_resources
|
||||
version = pkg_resources.get_distribution('shadowsocks').version
|
||||
except:
|
||||
pass
|
||||
print 'shadowsocks %s' % version
|
||||
|
||||
config_path = utils.find_config()
|
||||
try:
|
||||
optlist, args = getopt.getopt(sys.argv[1:], 's:p:k:m:c:t:',
|
||||
['fast-open', 'workers:'])
|
||||
for key, value in optlist:
|
||||
if key == '-c':
|
||||
config_path = value
|
||||
|
||||
if config_path:
|
||||
logging.info('loading config from %s' % config_path)
|
||||
with open(config_path, 'rb') as f:
|
||||
try:
|
||||
config = json.load(f)
|
||||
except ValueError as e:
|
||||
logging.error('found an error in config.json: %s',
|
||||
e.message)
|
||||
sys.exit(1)
|
||||
else:
|
||||
config = {}
|
||||
|
||||
optlist, args = getopt.getopt(sys.argv[1:], 's:p:k:m:c:t:',
|
||||
['fast-open', 'workers='])
|
||||
for key, value in optlist:
|
||||
if key == '-p':
|
||||
config['server_port'] = int(value)
|
||||
elif key == '-k':
|
||||
config['password'] = value
|
||||
elif key == '-s':
|
||||
config['server'] = value
|
||||
elif key == '-m':
|
||||
config['method'] = value
|
||||
elif key == '-t':
|
||||
config['timeout'] = value
|
||||
elif key == '--fast-open':
|
||||
config['fast_open'] = True
|
||||
elif key == '--workers':
|
||||
config['workers'] = value
|
||||
except getopt.GetoptError:
|
||||
utils.print_server_help()
|
||||
sys.exit(2)
|
||||
|
||||
config_server = config['server']
|
||||
config_server_port = config['server_port']
|
||||
config_key = config['password']
|
||||
config_method = config.get('method', None)
|
||||
config_port_password = config.get('port_password', None)
|
||||
config_timeout = int(config.get('timeout', 300))
|
||||
config_fast_open = config.get('fast_open', False)
|
||||
config_workers = config.get('workers', 1)
|
||||
|
||||
if not config_key and not config_path:
|
||||
sys.exit('config not specified, please read '
|
||||
'https://github.com/clowwindy/shadowsocks')
|
||||
|
||||
utils.check_config(config)
|
||||
|
||||
if config_port_password:
|
||||
if config_server_port or config_key:
|
||||
logging.warn('warning: port_password should not be used with '
|
||||
'server_port and password. server_port and password '
|
||||
'will be ignored')
|
||||
else:
|
||||
config_port_password = {}
|
||||
config_port_password[str(config_server_port)] = config_key
|
||||
|
||||
encrypt.init_table(config_key, config_method)
|
||||
addrs = socket.getaddrinfo(config_server, int(8387))
|
||||
if not addrs:
|
||||
logging.error('cant resolve listen address')
|
||||
sys.exit(1)
|
||||
ThreadingTCPServer.address_family = addrs[0][0]
|
||||
tcp_servers = []
|
||||
udp_servers = []
|
||||
for port, key in config_port_password.items():
|
||||
tcp_server = ThreadingTCPServer((config_server, int(port)),
|
||||
Socks5Server)
|
||||
tcp_server.key = key
|
||||
tcp_server.method = config_method
|
||||
tcp_server.timeout = int(config_timeout)
|
||||
logging.info("starting server at %s:%d" %
|
||||
tuple(tcp_server.server_address[:2]))
|
||||
tcp_servers.append(tcp_server)
|
||||
udp_server = udprelay.UDPRelay(config_server, int(port), None, None,
|
||||
key, config_method, int(config_timeout),
|
||||
False)
|
||||
udp_servers.append(udp_server)
|
||||
|
||||
def run_server():
|
||||
for tcp_server in tcp_servers:
|
||||
threading.Thread(target=tcp_server.serve_forever).start()
|
||||
for udp_server in udp_servers:
|
||||
udp_server.start()
|
||||
|
||||
if int(config_workers) > 1:
|
||||
if os.name == 'posix':
|
||||
children = []
|
||||
is_child = False
|
||||
for i in xrange(0, int(config_workers)):
|
||||
r = os.fork()
|
||||
if r == 0:
|
||||
logging.info('worker started')
|
||||
is_child = True
|
||||
run_server()
|
||||
break
|
||||
else:
|
||||
children.append(r)
|
||||
if not is_child:
|
||||
def handler(signum, frame):
|
||||
for pid in children:
|
||||
os.kill(pid, signum)
|
||||
os.waitpid(pid, 0)
|
||||
sys.exit()
|
||||
import signal
|
||||
signal.signal(signal.SIGTERM, handler)
|
||||
|
||||
# master
|
||||
for tcp_server in tcp_servers:
|
||||
tcp_server.server_close()
|
||||
for udp_server in udp_servers:
|
||||
udp_server.close()
|
||||
|
||||
for child in children:
|
||||
os.waitpid(child, 0)
|
||||
else:
|
||||
logging.warn('worker is only available on Unix/Linux')
|
||||
run_server()
|
||||
else:
|
||||
run_server()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except socket.error, e:
|
||||
logging.error(e)
|
||||
@ -1,291 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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.
|
||||
|
||||
# SOCKS5 UDP Request
|
||||
# +----+------+------+----------+----------+----------+
|
||||
# |RSV | FRAG | ATYP | DST.ADDR | DST.PORT | DATA |
|
||||
# +----+------+------+----------+----------+----------+
|
||||
# | 2 | 1 | 1 | Variable | 2 | Variable |
|
||||
# +----+------+------+----------+----------+----------+
|
||||
|
||||
# SOCKS5 UDP Response
|
||||
# +----+------+------+----------+----------+----------+
|
||||
# |RSV | FRAG | ATYP | DST.ADDR | DST.PORT | DATA |
|
||||
# +----+------+------+----------+----------+----------+
|
||||
# | 2 | 1 | 1 | Variable | 2 | Variable |
|
||||
# +----+------+------+----------+----------+----------+
|
||||
|
||||
# shadowsocks UDP Request (before encrypted)
|
||||
# +------+----------+----------+----------+
|
||||
# | ATYP | DST.ADDR | DST.PORT | DATA |
|
||||
# +------+----------+----------+----------+
|
||||
# | 1 | Variable | 2 | Variable |
|
||||
# +------+----------+----------+----------+
|
||||
|
||||
# shadowsocks UDP Response (before encrypted)
|
||||
# +------+----------+----------+----------+
|
||||
# | ATYP | DST.ADDR | DST.PORT | DATA |
|
||||
# +------+----------+----------+----------+
|
||||
# | 1 | Variable | 2 | Variable |
|
||||
# +------+----------+----------+----------+
|
||||
|
||||
# shadowsocks UDP Request and Response (after encrypted)
|
||||
# +-------+--------------+
|
||||
# | IV | PAYLOAD |
|
||||
# +-------+--------------+
|
||||
# | Fixed | Variable |
|
||||
# +-------+--------------+
|
||||
|
||||
# HOW TO NAME THINGS
|
||||
# ------------------
|
||||
# `dest` means destination server, which is from DST fields in the SOCKS5
|
||||
# request
|
||||
# `local` means local server of shadowsocks
|
||||
# `remote` means remote server of shadowsocks
|
||||
# `client` means UDP clients that connects to other servers
|
||||
# `server` means the UDP server that handles user requests
|
||||
|
||||
|
||||
import time
|
||||
import threading
|
||||
import socket
|
||||
import logging
|
||||
import struct
|
||||
import encrypt
|
||||
import eventloop
|
||||
import lru_cache
|
||||
import errno
|
||||
|
||||
|
||||
BUF_SIZE = 65536
|
||||
|
||||
|
||||
def parse_header(data):
|
||||
addrtype = ord(data[0])
|
||||
dest_addr = None
|
||||
dest_port = None
|
||||
header_length = 0
|
||||
if addrtype == 1:
|
||||
if len(data) >= 7:
|
||||
dest_addr = socket.inet_ntoa(data[1:5])
|
||||
dest_port = struct.unpack('>H', data[5:7])[0]
|
||||
header_length = 7
|
||||
else:
|
||||
logging.warn('[udp] header is too short')
|
||||
elif addrtype == 3:
|
||||
if len(data) > 2:
|
||||
addrlen = ord(data[1])
|
||||
if len(data) >= 2 + addrlen:
|
||||
dest_addr = data[2:2 + addrlen]
|
||||
dest_port = struct.unpack('>H', data[2 + addrlen:4 +
|
||||
addrlen])[0]
|
||||
header_length = 4 + addrlen
|
||||
else:
|
||||
logging.warn('[udp] header is too short')
|
||||
else:
|
||||
logging.warn('[udp] header is too short')
|
||||
elif addrtype == 4:
|
||||
if len(data) >= 19:
|
||||
dest_addr = socket.inet_ntop(socket.AF_INET6, data[1:17])
|
||||
dest_port = struct.unpack('>H', data[17:19])[0]
|
||||
header_length = 19
|
||||
else:
|
||||
logging.warn('[udp] header is too short')
|
||||
else:
|
||||
logging.warn('unsupported addrtype %d' % addrtype)
|
||||
if dest_addr is None:
|
||||
return None
|
||||
return (addrtype, dest_addr, dest_port, header_length)
|
||||
|
||||
|
||||
def client_key(a, b, c, d):
|
||||
return '%s:%s:%s:%s' % (a, b, c, d)
|
||||
|
||||
|
||||
class UDPRelay(object):
|
||||
def __init__(self, listen_addr='127.0.0.1', listen_port=1080,
|
||||
remote_addr='127.0.0.1', remote_port=8387, password=None,
|
||||
method='table', timeout=300, is_local=True):
|
||||
self._listen_addr = listen_addr
|
||||
self._listen_port = listen_port
|
||||
self._remote_addr = remote_addr
|
||||
self._remote_port = remote_port
|
||||
self._password = password
|
||||
self._method = method
|
||||
self._timeout = timeout
|
||||
self._is_local = is_local
|
||||
self._cache = lru_cache.LRUCache(timeout=timeout,
|
||||
close_callback=self._close_client)
|
||||
self._client_fd_to_server_addr = lru_cache.LRUCache(timeout=timeout)
|
||||
self._closed = False
|
||||
|
||||
addrs = socket.getaddrinfo(self._listen_addr, self._listen_port, 0,
|
||||
socket.SOCK_DGRAM, socket.SOL_UDP)
|
||||
if len(addrs) == 0:
|
||||
raise Exception("can't get addrinfo for %s:%d" %
|
||||
(self._listen_addr, self._listen_port))
|
||||
af, socktype, proto, canonname, sa = addrs[0]
|
||||
server_socket = socket.socket(af, socktype, proto)
|
||||
server_socket.bind((self._listen_addr, self._listen_port))
|
||||
server_socket.setblocking(False)
|
||||
self._server_socket = server_socket
|
||||
|
||||
def _close_client(self, client):
|
||||
if hasattr(client, 'close'):
|
||||
self._eventloop.remove(client)
|
||||
client.close()
|
||||
else:
|
||||
# just an address
|
||||
pass
|
||||
|
||||
def _handle_server(self):
|
||||
server = self._server_socket
|
||||
data, r_addr = server.recvfrom(BUF_SIZE)
|
||||
if self._is_local:
|
||||
frag = ord(data[2])
|
||||
if frag != 0:
|
||||
logging.warn('drop a message since frag is not 0')
|
||||
return
|
||||
else:
|
||||
data = data[3:]
|
||||
else:
|
||||
# decrypt data
|
||||
data = encrypt.encrypt_all(self._password, self._method, 0, data)
|
||||
if not data:
|
||||
return
|
||||
header_result = parse_header(data)
|
||||
if header_result is None:
|
||||
return
|
||||
addrtype, dest_addr, dest_port, header_length = header_result
|
||||
|
||||
if self._is_local:
|
||||
server_addr, server_port = self._remote_addr, self._remote_port
|
||||
else:
|
||||
server_addr, server_port = dest_addr, dest_port
|
||||
|
||||
key = client_key(r_addr[0], r_addr[1], dest_addr, dest_port)
|
||||
client = self._cache.get(key, None)
|
||||
if not client:
|
||||
# TODO async getaddrinfo
|
||||
addrs = socket.getaddrinfo(server_addr, server_port, 0,
|
||||
socket.SOCK_DGRAM, socket.SOL_UDP)
|
||||
if addrs:
|
||||
af, socktype, proto, canonname, sa = addrs[0]
|
||||
client = socket.socket(af, socktype, proto)
|
||||
client.setblocking(False)
|
||||
self._cache[key] = client
|
||||
self._client_fd_to_server_addr[client.fileno()] = r_addr
|
||||
else:
|
||||
# drop
|
||||
return
|
||||
self._eventloop.add(client, eventloop.POLL_IN)
|
||||
|
||||
data = data[header_length:]
|
||||
if not data:
|
||||
return
|
||||
if self._is_local:
|
||||
data = encrypt.encrypt_all(self._password, self._method, 1, data)
|
||||
if not data:
|
||||
return
|
||||
try:
|
||||
client.sendto(data, (server_addr, server_port))
|
||||
except IOError as e:
|
||||
err = eventloop.errno_from_exception(e)
|
||||
if err in (errno.EINPROGRESS, errno.EAGAIN):
|
||||
pass
|
||||
else:
|
||||
logging.error(e)
|
||||
|
||||
def _handle_client(self, sock):
|
||||
data, r_addr = sock.recvfrom(BUF_SIZE)
|
||||
if not self._is_local:
|
||||
addrlen = len(r_addr[0])
|
||||
if addrlen > 255:
|
||||
# drop
|
||||
return
|
||||
data = '\x03' + chr(addrlen) + r_addr[0] + \
|
||||
struct.pack('>H', r_addr[1]) + data
|
||||
response = encrypt.encrypt_all(self._password, self._method, 1,
|
||||
data)
|
||||
if not response:
|
||||
return
|
||||
else:
|
||||
data = encrypt.encrypt_all(self._password, self._method, 0,
|
||||
data)
|
||||
if not data:
|
||||
return
|
||||
header_result = parse_header(data)
|
||||
if header_result is None:
|
||||
return
|
||||
# addrtype, dest_addr, dest_port, header_length = header_result
|
||||
response = '\x00\x00\x00' + data
|
||||
client_addr = self._client_fd_to_server_addr.get(sock.fileno(), None)
|
||||
if client_addr:
|
||||
self._server_socket.sendto(response, client_addr)
|
||||
else:
|
||||
# this packet is from somewhere else we know
|
||||
# simply drop that packet
|
||||
pass
|
||||
|
||||
def _run(self):
|
||||
server_socket = self._server_socket
|
||||
self._eventloop = eventloop.EventLoop()
|
||||
self._eventloop.add(server_socket, eventloop.POLL_IN)
|
||||
last_time = time.time()
|
||||
while not self._closed:
|
||||
try:
|
||||
events = self._eventloop.poll(10)
|
||||
except (OSError, IOError) as e:
|
||||
if eventloop.errno_from_exception(e) == errno.EPIPE:
|
||||
# Happens when the client closes the connection
|
||||
continue
|
||||
else:
|
||||
logging.error(e)
|
||||
continue
|
||||
for sock, event in events:
|
||||
if sock == self._server_socket:
|
||||
self._handle_server()
|
||||
else:
|
||||
self._handle_client(sock)
|
||||
now = time.time()
|
||||
if now - last_time > 3.5:
|
||||
self._cache.sweep()
|
||||
if now - last_time > 7:
|
||||
self._client_fd_to_server_addr.sweep()
|
||||
last_time = now
|
||||
|
||||
def start(self):
|
||||
if self._closed:
|
||||
raise Exception('closed')
|
||||
t = threading.Thread(target=self._run)
|
||||
t.setName('UDPThread')
|
||||
t.setDaemon(False)
|
||||
t.start()
|
||||
self._thread = t
|
||||
|
||||
def close(self):
|
||||
self._closed = True
|
||||
self._server_socket.close()
|
||||
|
||||
def thread(self):
|
||||
return self._thread
|
||||
@ -1,132 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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.
|
||||
|
||||
import os
|
||||
import socket
|
||||
import logging
|
||||
|
||||
|
||||
def inet_ntop(family, ipstr):
|
||||
if family == socket.AF_INET:
|
||||
return socket.inet_ntoa(ipstr)
|
||||
elif family == socket.AF_INET6:
|
||||
v6addr = ':'.join(('%02X%02X' % (ord(i), ord(j)))
|
||||
for i, j in zip(ipstr[::2], ipstr[1::2]))
|
||||
return v6addr
|
||||
|
||||
|
||||
def inet_pton(family, addr):
|
||||
if family == socket.AF_INET:
|
||||
return socket.inet_aton(addr)
|
||||
elif family == socket.AF_INET6:
|
||||
if '.' in addr: # a v4 addr
|
||||
v4addr = addr[addr.rindex(':') + 1:]
|
||||
v4addr = socket.inet_aton(v4addr)
|
||||
v4addr = map(lambda x: ('%02X' % ord(x)), v4addr)
|
||||
v4addr.insert(2, ':')
|
||||
newaddr = addr[:addr.rindex(':') + 1] + ''.join(v4addr)
|
||||
return inet_pton(family, newaddr)
|
||||
dbyts = [0] * 8 # 8 groups
|
||||
grps = addr.split(':')
|
||||
for i, v in enumerate(grps):
|
||||
if v:
|
||||
dbyts[i] = int(v, 16)
|
||||
else:
|
||||
for j, w in enumerate(grps[::-1]):
|
||||
if w:
|
||||
dbyts[7 - j] = int(w, 16)
|
||||
else:
|
||||
break
|
||||
break
|
||||
return ''.join((chr(i // 256) + chr(i % 256)) for i in dbyts)
|
||||
else:
|
||||
raise RuntimeError("What family?")
|
||||
|
||||
|
||||
if not hasattr(socket, 'inet_pton'):
|
||||
socket.inet_pton = inet_pton
|
||||
|
||||
if not hasattr(socket, 'inet_ntop'):
|
||||
socket.inet_ntop = inet_ntop
|
||||
|
||||
def find_config():
|
||||
config_path = 'config.json'
|
||||
if os.path.exists(config_path):
|
||||
return config_path
|
||||
config_path = os.path.join(os.path.dirname(__file__), '../', 'config.json')
|
||||
if os.path.exists(config_path):
|
||||
return config_path
|
||||
return None
|
||||
|
||||
|
||||
def check_config(config):
|
||||
if config.get('local_address', '') in ['0.0.0.0']:
|
||||
logging.warn('warning: local set to listen 0.0.0.0, which is not safe')
|
||||
if config.get('server', '') in ['127.0.0.1', 'localhost']:
|
||||
logging.warn('warning: server set to listen %s:%s, are you sure?' %
|
||||
(config['server'], config['server_port']))
|
||||
if (config.get('method', '') or '').lower() == 'rc4':
|
||||
logging.warn('warning: RC4 is not safe; please use a safer cipher, '
|
||||
'like AES-256-CFB')
|
||||
if (int(config.get('timeout', 300)) or 300) < 100:
|
||||
logging.warn('warning: your timeout %d seems too short' %
|
||||
int(config.get('timeout')))
|
||||
if (int(config.get('timeout', 300)) or 300) > 600:
|
||||
logging.warn('warning: your timeout %d seems too long' %
|
||||
int(config.get('timeout')))
|
||||
|
||||
|
||||
def print_local_help():
|
||||
print '''usage: sslocal [-h] -s SERVER_ADDR -p SERVER_PORT [-b LOCAL_ADDR]
|
||||
-l LOCAL_PORT -k PASSWORD -m METHOD [-t TIMEOUT] [-c CONFIG]
|
||||
[--fast-open]
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-s SERVER_ADDR server address
|
||||
-p SERVER_PORT server port
|
||||
-b LOCAL_ADDR local binding address, default is 127.0.0.1
|
||||
-l LOCAL_PORT local port
|
||||
-k PASSWORD password
|
||||
-m METHOD encryption method, for example, aes-256-cfb
|
||||
-t TIMEOUT timeout in seconds
|
||||
-c CONFIG path to config file
|
||||
--fast-open use TCP_FASTOPEN, requires Linux 3.7+
|
||||
'''
|
||||
|
||||
|
||||
def print_server_help():
|
||||
print '''usage: ssserver [-h] -s SERVER_ADDR -p SERVER_PORT -k PASSWORD
|
||||
-m METHOD [-t TIMEOUT] [-c CONFIG] [--fast-open]
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-s SERVER_ADDR server address
|
||||
-p SERVER_PORT server port
|
||||
-k PASSWORD password
|
||||
-m METHOD encryption method, for example, aes-256-cfb
|
||||
-t TIMEOUT timeout in seconds
|
||||
-c CONFIG path to config file
|
||||
--fast-open use TCP_FASTOPEN, requires Linux 3.7+
|
||||
--workers WORKERS number of workers, available on Unix/Linux
|
||||
'''
|
||||
@ -1,131 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
import select
|
||||
import struct
|
||||
import hashlib
|
||||
import string
|
||||
import time
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
target1 = [
|
||||
[60, 53, 84, 138, 217, 94, 88, 23, 39, 242, 219, 35, 12, 157, 165, 181, 255, 143, 83, 247, 162, 16, 31, 209, 190,
|
||||
171, 115, 65, 38, 41, 21, 245, 236, 46, 121, 62, 166, 233, 44, 154, 153, 145, 230, 49, 128, 216, 173, 29, 241, 119,
|
||||
64, 229, 194, 103, 131, 110, 26, 197, 218, 59, 204, 56, 27, 34, 141, 221, 149, 239, 192, 195, 24, 155, 170, 183, 11
|
||||
, 254, 213, 37, 137, 226, 75, 203, 55, 19, 72, 248, 22, 129, 33, 175, 178, 10, 198, 71, 77, 36, 113, 167, 48, 2,
|
||||
117, 140, 142, 66, 199, 232, 243, 32, 123, 54, 51, 82, 57, 177, 87, 251, 150, 196, 133, 5, 253, 130, 8, 184, 14,
|
||||
152, 231, 3, 186, 159, 76, 89, 228, 205, 156, 96, 163, 146, 18, 91, 132, 85, 80, 109, 172, 176, 105, 13, 50, 235,
|
||||
127, 0, 189, 95, 98, 136, 250, 200, 108, 179, 211, 214, 106, 168, 78, 79, 74, 210, 30, 73, 201, 151, 208, 114, 101,
|
||||
174, 92, 52, 120, 240, 15, 169, 220, 182, 81, 224, 43, 185, 40, 99, 180, 17, 212, 158, 42, 90, 9, 191, 45, 6, 25, 4
|
||||
, 222, 67, 126, 1, 116, 124, 206, 69, 61, 7, 68, 97, 202, 63, 244, 20, 28, 58, 93, 134, 104, 144, 227, 147, 102,
|
||||
118, 135, 148, 47, 238, 86, 112, 122, 70, 107, 215, 100, 139, 223, 225, 164, 237, 111, 125, 207, 160, 187, 246, 234
|
||||
, 161, 188, 193, 249, 252],
|
||||
[151, 205, 99, 127, 201, 119, 199, 211, 122, 196, 91, 74, 12, 147, 124, 180, 21, 191, 138, 83, 217, 30, 86, 7, 70,
|
||||
200, 56, 62, 218, 47, 168, 22, 107, 88, 63, 11, 95, 77, 28, 8, 188, 29, 194, 186, 38, 198, 33, 230, 98, 43, 148,
|
||||
110, 177, 1, 109, 82, 61, 112, 219, 59, 0, 210, 35, 215, 50, 27, 103, 203, 212, 209, 235, 93, 84, 169, 166, 80, 130
|
||||
, 94, 164, 165, 142, 184, 111, 18, 2, 141, 232, 114, 6, 131, 195, 139, 176, 220, 5, 153, 135, 213, 154, 189, 238
|
||||
, 174, 226, 53, 222, 146, 162, 236, 158, 143, 55, 244, 233, 96, 173, 26, 206, 100, 227, 49, 178, 34, 234, 108,
|
||||
207, 245, 204, 150, 44, 87, 121, 54, 140, 118, 221, 228, 155, 78, 3, 239, 101, 64, 102, 17, 223, 41, 137, 225, 229,
|
||||
66, 116, 171, 125, 40, 39, 71, 134, 13, 193, 129, 247, 251, 20, 136, 242, 14, 36, 97, 163, 181, 72, 25, 144, 46,
|
||||
175, 89, 145, 113, 90, 159, 190, 15, 183, 73, 123, 187, 128, 248, 252, 152, 24, 197, 68, 253, 52, 69, 117, 57, 92,
|
||||
104, 157, 170, 214, 81, 60, 133, 208, 246, 172, 23, 167, 160, 192, 76, 161, 237, 45, 4, 58, 10, 182, 65, 202, 240,
|
||||
185, 241, 79, 224, 132, 51, 42, 126, 105, 37, 250, 149, 32, 243, 231, 67, 179, 48, 9, 106, 216, 31, 249, 19, 85,
|
||||
254, 156, 115, 255, 120, 75, 16]]
|
||||
|
||||
target2 = [
|
||||
[124, 30, 170, 247, 27, 127, 224, 59, 13, 22, 196, 76, 72, 154, 32, 209, 4, 2, 131, 62, 101, 51, 230, 9, 166, 11, 99
|
||||
, 80, 208, 112, 36, 248, 81, 102, 130, 88, 218, 38, 168, 15, 241, 228, 167, 117, 158, 41, 10, 180, 194, 50, 204,
|
||||
243, 246, 251, 29, 198, 219, 210, 195, 21, 54, 91, 203, 221, 70, 57, 183, 17, 147, 49, 133, 65, 77, 55, 202, 122,
|
||||
162, 169, 188, 200, 190, 125, 63, 244, 96, 31, 107, 106, 74, 143, 116, 148, 78, 46, 1, 137, 150, 110, 181, 56, 95,
|
||||
139, 58, 3, 231, 66, 165, 142, 242, 43, 192, 157, 89, 175, 109, 220, 128, 0, 178, 42, 255, 20, 214, 185, 83, 160,
|
||||
253, 7, 23, 92, 111, 153, 26, 226, 33, 176, 144, 18, 216, 212, 28, 151, 71, 206, 222, 182, 8, 174, 205, 201, 152,
|
||||
240, 155, 108, 223, 104, 239, 98, 164, 211, 184, 34, 193, 14, 114, 187, 40, 254, 12, 67, 93, 217, 6, 94, 16, 19, 82
|
||||
, 86, 245, 24, 197, 134, 132, 138, 229, 121, 5, 235, 238, 85, 47, 103, 113, 179, 69, 250, 45, 135, 156, 25, 61,
|
||||
75, 44, 146, 189, 84, 207, 172, 119, 53, 123, 186, 120, 171, 68, 227, 145, 136, 100, 90, 48, 79, 159, 149, 39, 213,
|
||||
236, 126, 52, 60, 225, 199, 105, 73, 233, 252, 118, 215, 35, 115, 64, 37, 97, 129, 161, 177, 87, 237, 141, 173, 191
|
||||
, 163, 140, 234, 232, 249],
|
||||
[117, 94, 17, 103, 16, 186, 172, 127, 146, 23, 46, 25, 168, 8, 163, 39, 174, 67, 137, 175, 121, 59, 9, 128, 179, 199
|
||||
, 132, 4, 140, 54, 1, 85, 14, 134, 161, 238, 30, 241, 37, 224, 166, 45, 119, 109, 202, 196, 93, 190, 220, 69, 49
|
||||
, 21, 228, 209, 60, 73, 99, 65, 102, 7, 229, 200, 19, 82, 240, 71, 105, 169, 214, 194, 64, 142, 12, 233, 88, 201
|
||||
, 11, 72, 92, 221, 27, 32, 176, 124, 205, 189, 177, 246, 35, 112, 219, 61, 129, 170, 173, 100, 84, 242, 157, 26,
|
||||
218, 20, 33, 191, 155, 232, 87, 86, 153, 114, 97, 130, 29, 192, 164, 239, 90, 43, 236, 208, 212, 185, 75, 210, 0,
|
||||
81, 227, 5, 116, 243, 34, 18, 182, 70, 181, 197, 217, 95, 183, 101, 252, 248, 107, 89, 136, 216, 203, 68, 91, 223,
|
||||
96, 141, 150, 131, 13, 152, 198, 111, 44, 222, 125, 244, 76, 251, 158, 106, 24, 42, 38, 77, 2, 213, 207, 249, 147,
|
||||
113, 135, 245, 118, 193, 47, 98, 145, 66, 160, 123, 211, 165, 78, 204, 80, 250, 110, 162, 48, 58, 10, 180, 55, 231,
|
||||
79, 149, 74, 62, 50, 148, 143, 206, 28, 15, 57, 159, 139, 225, 122, 237, 138, 171, 36, 56, 115, 63, 144, 154, 6,
|
||||
230, 133, 215, 41, 184, 22, 104, 254, 234, 253, 187, 226, 247, 188, 156, 151, 40, 108, 51, 83, 178, 52, 3, 31, 255,
|
||||
195, 53, 235, 126, 167, 120]]
|
||||
|
||||
|
||||
def get_table(key):
|
||||
m = hashlib.md5()
|
||||
m.update(key)
|
||||
s = m.digest()
|
||||
(a, b) = struct.unpack('<QQ', s)
|
||||
table = [c for c in string.maketrans('', '')]
|
||||
for i in xrange(1, 1024):
|
||||
table.sort(lambda x, y: int(a % (ord(x) + i) - a % (ord(y) + i)))
|
||||
return table
|
||||
|
||||
encrypt_table = ''.join(get_table('foobar!'))
|
||||
decrypt_table = string.maketrans(encrypt_table, string.maketrans('', ''))
|
||||
|
||||
for i in range(0, 256):
|
||||
assert(target1[0][i] == ord(encrypt_table[i]))
|
||||
assert(target1[1][i] == ord(decrypt_table[i]))
|
||||
|
||||
encrypt_table = ''.join(get_table('barfoo!'))
|
||||
decrypt_table = string.maketrans(encrypt_table, string.maketrans('', ''))
|
||||
|
||||
for i in range(0, 256):
|
||||
assert(target2[0][i] == ord(encrypt_table[i]))
|
||||
assert(target2[1][i] == ord(decrypt_table[i]))
|
||||
p1 = Popen(['python', 'shadowsocks/server.py', '-c', sys.argv[-1]], shell=False, bufsize=0, stdin=PIPE,
|
||||
stdout=PIPE, stderr=PIPE, close_fds=True)
|
||||
p2 = Popen(['python', 'shadowsocks/local.py', '-c', sys.argv[-1]], shell=False, bufsize=0, stdin=PIPE,
|
||||
stdout=PIPE, stderr=PIPE, close_fds=True)
|
||||
p3 = None
|
||||
|
||||
print 'encryption test passed'
|
||||
|
||||
try:
|
||||
local_ready = False
|
||||
server_ready = False
|
||||
fdset = [p1.stdout, p2.stdout, p1.stderr, p2.stderr]
|
||||
while True:
|
||||
r, w, e = select.select(fdset, [], fdset)
|
||||
if e:
|
||||
break
|
||||
|
||||
for fd in r:
|
||||
line = fd.readline()
|
||||
sys.stdout.write(line)
|
||||
if line.find('starting local') >= 0:
|
||||
local_ready = True
|
||||
if line.find('starting server') >= 0:
|
||||
server_ready = True
|
||||
|
||||
if local_ready and server_ready and p3 is None:
|
||||
time.sleep(1)
|
||||
p3 = Popen(['curl', 'http://www.example.com/', '-v', '-L',
|
||||
'--socks5-hostname', '127.0.0.1:1080'], shell=False,
|
||||
bufsize=0, close_fds=True)
|
||||
break
|
||||
|
||||
if p3 is not None:
|
||||
r = p3.wait()
|
||||
if r == 0:
|
||||
print 'test passed'
|
||||
sys.exit(r)
|
||||
|
||||
finally:
|
||||
for p in [p1, p2]:
|
||||
try:
|
||||
os.kill(p.pid, signal.SIGTERM)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
sys.exit(-1)
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"server":"127.0.0.1",
|
||||
"server_port":8388,
|
||||
"local_port":1080,
|
||||
"password":"barfoo!",
|
||||
"timeout":300,
|
||||
"method":"aes-256-cfb",
|
||||
"local_address":"127.0.0.1",
|
||||
"fast_open":false
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
{
|
||||
"server": "127.0.0.1",
|
||||
"server_port": 8384,
|
||||
"local_port": 1080,
|
||||
"password": "foobar4",
|
||||
"port_password": {
|
||||
"8381": "foobar1",
|
||||
"8382": "foobar2",
|
||||
"8383": "foobar3",
|
||||
"8384": "foobar4",
|
||||
"8385": "foobar5",
|
||||
"8386": "foobar6",
|
||||
"8387": "foobar7",
|
||||
"8388": "foobar8",
|
||||
"8389": "foobar9",
|
||||
"8390": "foobar10",
|
||||
"8391": "foobar11",
|
||||
"8392": "foobar12"
|
||||
},
|
||||
"timeout": 60,
|
||||
"method": "aes-256-cfb"
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"server":"127.0.0.1",
|
||||
"server_port":8388,
|
||||
"local_port":1080,
|
||||
"password":"barfoo!",
|
||||
"timeout":300,
|
||||
"method":"aes-256-cfb",
|
||||
"local_address":"127.0.0.1",
|
||||
"workers": 4
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
before = time.time()
|
||||
|
||||
for line in sys.stdin:
|
||||
if 'HTTP/1.1 ' in line:
|
||||
diff = time.time() - before
|
||||
print 'headline %dms' % (diff * 1000)
|
||||
|
||||
Loading…
Reference in New Issue