r_socks 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/r_socks/config.rb +24 -0
- data/lib/r_socks/connection_handler.rb +15 -0
- data/lib/r_socks/target_connection_handler.rb +24 -6
- data/lib/r_socks/version.rb +1 -1
- data/r_socks.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9f3daabf6b654e432702a1f8ec25cb8a31360cbd199badd407d3f8b0beb4a75
|
4
|
+
data.tar.gz: 20a333f1b28ffd89094362e27b7dccd4c0b7053bd8f5e83154fd29c2485a11ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cbb6b31615e0448dab30fb0eb6a6b39485415d091d8f559b01d4a60a1982496c998c45b0870971ee002b3ac4d9e0eba078b5efce546baa5909170600b525624
|
7
|
+
data.tar.gz: 991c43cbb67f8f52c2ffce971bfd0e7cecdaad8a02565e0489494ac6893036e2464e5404053887f8b5cbaeca840927c698a1a41b9023afc34f41698d9c1d3fbc
|
data/Gemfile.lock
CHANGED
data/lib/r_socks/config.rb
CHANGED
@@ -94,5 +94,29 @@ module RSocks
|
|
94
94
|
def unbind_handler
|
95
95
|
@store[:unbind_handler]
|
96
96
|
end
|
97
|
+
|
98
|
+
def forward_server?
|
99
|
+
@store[:forward_server] || false
|
100
|
+
end
|
101
|
+
|
102
|
+
def forward_server=(value)
|
103
|
+
@store[:forward_server] = value
|
104
|
+
end
|
105
|
+
|
106
|
+
def forward_port
|
107
|
+
@store[:forward_port]
|
108
|
+
end
|
109
|
+
|
110
|
+
def forward_addr
|
111
|
+
@store[:forward_addr]
|
112
|
+
end
|
113
|
+
|
114
|
+
def forward_port=(value)
|
115
|
+
@store[:forward_port] = value.to_i
|
116
|
+
end
|
117
|
+
|
118
|
+
def forward_addr=(value)
|
119
|
+
@store[:forward_addr] = value.to_s
|
120
|
+
end
|
97
121
|
end
|
98
122
|
end
|
@@ -53,6 +53,16 @@ module RSocks
|
|
53
53
|
|
54
54
|
return unless @state_machine.start?
|
55
55
|
|
56
|
+
if @config.forward_server? && @config.proxy_type == :http
|
57
|
+
@target = EventMachine.connect(@config.forward_addr,
|
58
|
+
@config.forward_port,
|
59
|
+
RSocks::TargetConnectionHandler,
|
60
|
+
self,
|
61
|
+
@config,
|
62
|
+
data)
|
63
|
+
@target.assign_user_and_password(@username, @password)
|
64
|
+
end
|
65
|
+
|
56
66
|
@username = @parser.username
|
57
67
|
@password = @parser.password
|
58
68
|
if @target.nil?
|
@@ -81,6 +91,11 @@ module RSocks
|
|
81
91
|
|
82
92
|
private
|
83
93
|
|
94
|
+
def forward_request
|
95
|
+
@port = @config.forward_port
|
96
|
+
@addr = @config.forward_addr
|
97
|
+
end
|
98
|
+
|
84
99
|
def create_proxy_parser
|
85
100
|
if @config.proxy_type == :http
|
86
101
|
return RSocks::HttpProxyParser.new(@state_machine, @config)
|
@@ -4,9 +4,12 @@ require 'r_socks/http_proxy_response_codes'
|
|
4
4
|
module RSocks
|
5
5
|
class TargetConnectionHandler < EM::Connection
|
6
6
|
|
7
|
-
def initialize(client, config)
|
7
|
+
def initialize(client, config, connect_data = nil)
|
8
8
|
@client = client
|
9
9
|
@config = config
|
10
|
+
@connect_data = connect_data
|
11
|
+
@forward_connection = !@connect_data.nil?
|
12
|
+
@forward_success = false
|
10
13
|
end
|
11
14
|
|
12
15
|
def assign_user_and_password(username, password)
|
@@ -15,15 +18,20 @@ module RSocks
|
|
15
18
|
end
|
16
19
|
|
17
20
|
def connection_completed
|
18
|
-
if @
|
19
|
-
|
21
|
+
if @connect_data
|
22
|
+
send_data(@connect_data)
|
23
|
+
else
|
24
|
+
response_proxy_connect_ready
|
20
25
|
end
|
21
|
-
@client.proxy_incoming_to(self, @config.proxy_buffer_size)
|
22
|
-
proxy_incoming_to(@client, @config.proxy_buffer_size)
|
23
26
|
end
|
24
27
|
|
25
28
|
def receive_data(data)
|
26
|
-
@
|
29
|
+
if @forward_connection && !@forward_success
|
30
|
+
if data == RSocks::HttpProxyResponseCodes::SUCCESS
|
31
|
+
@forward_success = true
|
32
|
+
response_proxy_connect_ready
|
33
|
+
end
|
34
|
+
end
|
27
35
|
end
|
28
36
|
|
29
37
|
def proxy_target_unbound
|
@@ -36,5 +44,15 @@ module RSocks
|
|
36
44
|
@config.unbind_handler.call(get_proxied_bytes, @username, @password)
|
37
45
|
end
|
38
46
|
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def response_proxy_connect_ready
|
51
|
+
if @config.proxy_type == :http
|
52
|
+
@client.send_data(RSocks::HttpProxyResponseCodes::SUCCESS)
|
53
|
+
end
|
54
|
+
@client.proxy_incoming_to(self, @config.proxy_buffer_size)
|
55
|
+
proxy_incoming_to(@client, @config.proxy_buffer_size)
|
56
|
+
end
|
39
57
|
end
|
40
58
|
end
|
data/lib/r_socks/version.rb
CHANGED
data/r_socks.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.licenses = ['Apache-2.0']
|
9
9
|
|
10
10
|
spec.summary = %q{socks5 proxy server}
|
11
|
-
spec.description = %q{ruby
|
11
|
+
spec.description = %q{ruby socks5 and http proxy}
|
12
12
|
spec.homepage = "https://github.com/nickoan/r_socks"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
14
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r_socks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick An
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.2.7
|
33
|
-
description: ruby
|
33
|
+
description: ruby socks5 and http proxy
|
34
34
|
email:
|
35
35
|
- anning0322@gmail.com
|
36
36
|
executables: []
|