r_socks 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8aeaa60ff88cdf8c84892a5c95c9613d1bc8726fdaf3a5e8d113eeb47f6fb77a
4
- data.tar.gz: 84ec2ec281d97bf06bfd3838131cb35c11869f85361157088e593f2be03c78cb
3
+ metadata.gz: 33da7f5aaa91a1bdc1dd242c7fe65b3f48a0ac5b1d76c476420abbdb2973e3ee
4
+ data.tar.gz: 659dc9c5000f69d2eed3700324ab3b982885db0080a5550e14390a4001f55c35
5
5
  SHA512:
6
- metadata.gz: 0b2c40a1456321518b5ce51918f34046ddb3f06056b634b08a026bd95cb231fe221c443848bf1dfd4c6d8add73363afcb47864c7de251c42786ce7778d08876e
7
- data.tar.gz: 96df7a1ac2898bf062a8801b49570d351d5110946f309e8c3e74185e3e3f303f3b981d3781127f13971a6cd8a4f76c4dc6f0191c8fcd23f2e33f57cf42c68981
6
+ metadata.gz: c13038163c89bbec6b9eb8768b8ba4e23448ad6006a45fac73587d5a9441f0e1bc66cf62ead2bd78557c98b6adadc925582072b00c619cf5304cad7ef310c236
7
+ data.tar.gz: 123aab47f063182a4cc89d6f08d5de4ad8ee6ab209a78cc96cc00be0e3c341eea99339065b36522a771f116ebaa7d73fba368f0215feba797df480f9792153e6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- r_socks (0.2.0)
4
+ r_socks (0.2.1)
5
5
  eventmachine (~> 1.2, >= 1.2.7)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -40,6 +40,7 @@ require 'r_socks'
40
40
  server = RSocks::TcpServer.new('127.0.0.1', 8081)
41
41
 
42
42
  server.config.auth_method = :password
43
+ server.config.proxy_type = :http # default proxy_type = socks5
43
44
 
44
45
  server.run!
45
46
  ```
@@ -46,5 +46,13 @@ module RSocks
46
46
  def proxy_buffer_size=(value)
47
47
  @store[:proxy_buffer_size] = value.to_i
48
48
  end
49
+
50
+ def health_check_route=(str)
51
+ @store[:health_check_route] = str;
52
+ end
53
+
54
+ def health_check_route
55
+ @store[:health_check_route] || '/health'
56
+ end
49
57
  end
50
58
  end
@@ -39,6 +39,10 @@ module RSocks
39
39
  rescue RSocks::NotSupport
40
40
  send_data(RSocks::FAILED_RESPONSE)
41
41
  close_connection_after_writing
42
+
43
+ rescue RSocks::HealthChecking
44
+ send_data(RSocks::HttpProxyResponseCodes::SUCCESS)
45
+ close_connection_after_writing
42
46
  end
43
47
 
44
48
  return unless @state_machine.start?
@@ -3,4 +3,5 @@ module RSocks
3
3
  class NotSupport < Error; end
4
4
  class HttpNotSupport < Error; end
5
5
  class HttpAuthFailed < Error; end
6
+ class HealthChecking < StandardError; end
6
7
  end
@@ -9,6 +9,7 @@ module RSocks
9
9
  @default_user = ENV['RSOCKS_USER'] || 'default'
10
10
  @default_password = ENV['RSOCKS_PASSWORD'] || 'default'
11
11
  @adaptor = config.auth_adaptor
12
+ @health_check_route = config.health_check_route
12
13
  end
13
14
 
14
15
  def call(data)
@@ -49,6 +50,7 @@ module RSocks
49
50
 
50
51
  def host_format_checking(data)
51
52
  temp = data.split("\s")
53
+ health_check_request(temp)
52
54
  raise RSocks::HttpNotSupport if temp[0] != 'CONNECT'
53
55
  @schema_parse = URI("tcp://#{temp[1]}/")
54
56
  end
@@ -62,6 +64,10 @@ module RSocks
62
64
  end
63
65
  @header = header
64
66
  end
67
+
68
+ def health_check_request(arr_data)
69
+ raise RSocks::HealthChecking if arr_data[0] == 'GET' && @health_check_route == arr_data[1]
70
+ end
65
71
  end
66
72
  end
67
73
 
@@ -1,3 +1,3 @@
1
1
  module RSocks
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
4
+ version: 0.2.1
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-03-26 00:00:00.000000000 Z
11
+ date: 2020-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine