shadowsocks 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/config.json +1 -1
- data/lib/shadowsocks/cli.rb +1 -0
- data/lib/shadowsocks/connection.rb +3 -3
- data/lib/shadowsocks/crypto.rb +30 -33
- data/lib/shadowsocks/listener.rb +1 -1
- data/lib/shadowsocks/local.rb +1 -1
- data/lib/shadowsocks/server.rb +1 -1
- data/lib/shadowsocks/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89505690269fc4fea4a159ad713ea3a69045a269
|
4
|
+
data.tar.gz: 076b3e073b3cd64d4c56b4dd22647eddaa866e22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6016baaee667416efb16d7884e41cba5957a8f2f3ccd12036ddf2c36238341965a8ca3971fcda5ea28d2254e4c15f3d5dc384d5621732a23145197473368e1e9
|
7
|
+
data.tar.gz: e839023341a1870a1c624d7263909c6e65657954dd90336eb4e5c841d23a474c391251f974c1564a274904d707d7877f80172da504345cebde85afee23b56acb
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@ shadowsocks-ruby
|
|
3
3
|
|
4
4
|
[![Code Climate](https://codeclimate.com/repos/524baea6c7f3a37df208dd4c/badges/9dd6c11b6a17c3a55631/gpa.png)](https://codeclimate.com/repos/524baea6c7f3a37df208dd4c/feed)
|
5
5
|
|
6
|
-
Current version: 0.
|
6
|
+
Current version: 0.6
|
7
7
|
|
8
8
|
shadowsocks-ruby is a lightweight tunnel proxy which can help you get through firewalls. It is a port of [shadowsocks](https://github.com/clowwindy/shadowsocks).
|
9
9
|
|
@@ -27,7 +27,7 @@ Create a file named `config.json`, with the following content.
|
|
27
27
|
"local_port":1080,
|
28
28
|
"password":"barfoo!",
|
29
29
|
"timeout":60,
|
30
|
-
"method":"aes-
|
30
|
+
"method":"aes-128-cfb"
|
31
31
|
}
|
32
32
|
|
33
33
|
Explanation of the fields:
|
@@ -37,7 +37,7 @@ Explanation of the fields:
|
|
37
37
|
local_port local port
|
38
38
|
password a password used to encrypt transfer
|
39
39
|
timeout in seconds
|
40
|
-
method encryption method, "bf-cfb", "aes-256-cfb", "des-cfb", "rc4", etc. Default is aes-
|
40
|
+
method encryption method, "bf-cfb", "aes-256-cfb", "des-cfb", "rc4", etc. Default is "aes-128-cfb"
|
41
41
|
|
42
42
|
`cd` into the directory of `config.json`. Run `ss-server` on your server. To run it in the background, run
|
43
43
|
`nohup ss-server -c ./config.json > log &`.
|
data/config.json
CHANGED
data/lib/shadowsocks/cli.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Shadowsocks
|
2
2
|
class Connection < EventMachine::Connection
|
3
|
-
BackpressureLevel =
|
3
|
+
BackpressureLevel = 524288 # 512k
|
4
4
|
|
5
5
|
attr_accessor :crypto
|
6
6
|
|
@@ -18,10 +18,10 @@ module Shadowsocks
|
|
18
18
|
remote.get_outbound_data_size > BackpressureLevel
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
21
|
+
def outbound_scheduler
|
22
22
|
if over_pressure?
|
23
23
|
pause unless paused?
|
24
|
-
EM.add_timer(
|
24
|
+
EM.add_timer(0.2) { outbound_scheduler }
|
25
25
|
else
|
26
26
|
resume if paused?
|
27
27
|
end
|
data/lib/shadowsocks/crypto.rb
CHANGED
@@ -9,6 +9,23 @@ module Shadowsocks
|
|
9
9
|
attr_accessor :encrypt_table, :decrypt_table, :password, :method,
|
10
10
|
:cipher, :bytes_to_key_results, :iv_sent
|
11
11
|
|
12
|
+
def initialize(options = {})
|
13
|
+
@password = options[:password]
|
14
|
+
@method = options[:method].downcase
|
15
|
+
if method == 'table'
|
16
|
+
@encrypt_table = options[:encrypt_table]
|
17
|
+
@decrypt_table = options[:decrypt_table]
|
18
|
+
else
|
19
|
+
if method_supported.nil?
|
20
|
+
raise "Encrypt method not support"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
if method != 'table'
|
25
|
+
@cipher = get_cipher(1, SecureRandom.hex(32))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
12
29
|
def method_supported
|
13
30
|
case method
|
14
31
|
when 'aes-128-cfb' then [16, 16]
|
@@ -28,24 +45,6 @@ module Shadowsocks
|
|
28
45
|
end
|
29
46
|
alias_method :get_cipher_len, :method_supported
|
30
47
|
|
31
|
-
def initialize(options = {})
|
32
|
-
@password = options[:password]
|
33
|
-
@method = options[:method].downcase
|
34
|
-
@iv_sent = false
|
35
|
-
if method == 'table'
|
36
|
-
@encrypt_table = options[:encrypt_table]
|
37
|
-
@decrypt_table = options[:decrypt_table]
|
38
|
-
else
|
39
|
-
if method_supported.nil?
|
40
|
-
raise "Encrypt method not support"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
if method != 'table'
|
45
|
-
@cipher = get_cipher(1, SecureRandom.hex(32))
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
48
|
def encrypt buf
|
50
49
|
return buf if buf.length == 0
|
51
50
|
if method == 'table'
|
@@ -71,6 +70,7 @@ module Shadowsocks
|
|
71
70
|
@iv = decipher_iv
|
72
71
|
@decipher = get_cipher(0, @iv)
|
73
72
|
buf = buf[decipher_iv_len..-1]
|
73
|
+
|
74
74
|
return buf if buf.length == 0
|
75
75
|
end
|
76
76
|
@decipher.update(buf)
|
@@ -85,21 +85,20 @@ module Shadowsocks
|
|
85
85
|
|
86
86
|
def get_cipher(op, iv)
|
87
87
|
m = get_cipher_len
|
88
|
-
unless m.nil?
|
89
|
-
key, _iv = EVP_BytesToKey(m[0], m[1])
|
90
88
|
|
91
|
-
|
92
|
-
@iv = iv unless @iv
|
93
|
-
@cipher_iv = iv if op == 1
|
89
|
+
key, _iv = EVP_BytesToKey(m[0], m[1])
|
94
90
|
|
95
|
-
|
91
|
+
iv = _iv[0..m[1] - 1]
|
92
|
+
@iv = iv unless @iv
|
93
|
+
@cipher_iv = iv if op == 1
|
96
94
|
|
97
|
-
|
95
|
+
cipher = OpenSSL::Cipher.new method
|
98
96
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
97
|
+
op == 1 ? cipher.encrypt : cipher.decrypt
|
98
|
+
|
99
|
+
cipher.key = key
|
100
|
+
cipher.iv = @iv
|
101
|
+
cipher
|
103
102
|
end
|
104
103
|
|
105
104
|
def EVP_BytesToKey key_len, iv_len
|
@@ -112,21 +111,19 @@ module Shadowsocks
|
|
112
111
|
|
113
112
|
len = key_len + iv_len
|
114
113
|
|
115
|
-
code = password.unpack('H*').first
|
116
|
-
|
117
114
|
while m.join.length < len do
|
118
115
|
data = if i > 0
|
119
116
|
m[i - 1] + password
|
120
117
|
else
|
121
118
|
password
|
122
119
|
end
|
123
|
-
m.push Digest::MD5.digest
|
120
|
+
m.push Digest::MD5.digest(data)
|
124
121
|
i += 1
|
125
122
|
end
|
126
123
|
ms = m.join
|
127
124
|
key = ms[0, key_len]
|
128
125
|
iv = ms[key_len, key_len + iv_len]
|
129
|
-
bytes_to_key_results = [key, iv]
|
126
|
+
@bytes_to_key_results = [key, iv]
|
130
127
|
bytes_to_key_results
|
131
128
|
end
|
132
129
|
end
|
data/lib/shadowsocks/listener.rb
CHANGED
data/lib/shadowsocks/local.rb
CHANGED
data/lib/shadowsocks/server.rb
CHANGED
data/lib/shadowsocks/version.rb
CHANGED