miniproxy 0.2.1 → 0.3.0

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: ea9741957bdc4bef7bb92c6578011c272b3d0008b6e709a6f28a353fe6e895cb
4
- data.tar.gz: 233289bb7192cde0f0a103309f29161ff49fcce40aa3c7e1b8acda6a98cb5d0a
3
+ metadata.gz: 41e22d9ed52e95e702ec166cbe0a4700b53bd9d57d2ef8692e053a59068f2f37
4
+ data.tar.gz: e440206808935f7fcfcb06df5279605829073b44c3e5e76c4157381d785d51bc
5
5
  SHA512:
6
- metadata.gz: e0319daa2cd385c9a714b287e3dceff33a27a32feabe905e9661a968d75dc301b31ed1ab3107e5215edcee06ec9ed13ce37f5dbc57feaa71989dc4379c12dc9c
7
- data.tar.gz: b810589825cc2a36ce302cfe115c04b78f242239c58cafc4d62a600bb9297f9c04b5e92537d7192bf9a23d8f8f2227c93c0f3f62e21b3e538de02fde4e15749a
6
+ metadata.gz: 61f3e64831a177c3d6951d61384bb3cb2b4213e57eb4e105ccfe257e5e3d95f5a410ac2f2a79e4b2c5e87508dfa504a799a67ae08c2ef632fcb6959c6bf2b947
7
+ data.tar.gz: 509ffcd3f6b1ec80dbf19d22a2ca85efcf8c7588271159ec6857062046056783afb087b4ef37133c82dd38a199d396d018c81b4de1d0542c5018f52aa8e362cf
@@ -18,7 +18,11 @@ module MiniProxy
18
18
  end
19
19
 
20
20
  def self.host
21
- "127.0.0.1"
21
+ @host || "127.0.0.1"
22
+ end
23
+
24
+ def self.host=(host)
25
+ @host = host
22
26
  end
23
27
 
24
28
  def self.ignore_all_requests
@@ -36,7 +40,7 @@ module MiniProxy
36
40
  private_class_method def self.remote
37
41
  Timeout.timeout(DRB_SERVICE_TIMEOUT) do
38
42
  begin
39
- remote = DRbObject.new(nil, Remote.server)
43
+ remote = DRbObject.new(nil, Remote.server(self.host))
40
44
 
41
45
  until remote.started?
42
46
  sleep 0.01
@@ -5,9 +5,9 @@ module MiniProxy
5
5
  # MiniProxy fake SSL enabled server, which receives relayed requests from the ProxyServer
6
6
  #
7
7
  class FakeSSLServer < WEBrick::HTTPServer
8
- ALLOWED_HOSTS = ["127.0.0.1", "localhost"].freeze
9
-
10
8
  def initialize(config = {}, default = WEBrick::Config::HTTP)
9
+ @allowed_hosts = ["127.0.0.1", "localhost", config[:MiniProxyHost]].compact
10
+
11
11
  config = config.merge({
12
12
  Logger: WEBrick::Log.new(nil, 0), # silence logging
13
13
  AccessLog: [], # silence logging
@@ -21,7 +21,7 @@ module MiniProxy
21
21
  end
22
22
 
23
23
  def service(req, res)
24
- if ALLOWED_HOSTS.include?(req.host)
24
+ if @allowed_hosts.include?(req.host)
25
25
  super(req, res)
26
26
  else
27
27
  self.config[:MockHandlerCallback].call(req, res)
@@ -4,11 +4,11 @@ module MiniProxy
4
4
  # MiniProxy server, which boots a WEBrick proxy server
5
5
  #
6
6
  class ProxyServer < WEBrick::HTTPProxyServer
7
- ALLOWED_HOSTS = ["127.0.0.1", "localhost"].freeze
8
-
9
7
  attr_accessor :requests
10
8
 
11
9
  def initialize(config = {}, default = WEBrick::Config::HTTP)
10
+ @allowed_hosts = ["127.0.0.1", "localhost", config[:MiniProxyHost]].compact
11
+
12
12
  config = config.merge({
13
13
  Logger: WEBrick::Log.new(nil, 0), # silence logging
14
14
  AccessLog: [], # silence logging
@@ -36,7 +36,7 @@ module MiniProxy
36
36
  end
37
37
 
38
38
  def service(req, res)
39
- if ALLOWED_HOSTS.include?(req.host)
39
+ if @allowed_hosts.include?(req.host)
40
40
  super(req, res)
41
41
  else
42
42
  if req.request_method == "CONNECT"
@@ -20,7 +20,7 @@ module MiniProxy
20
20
  false
21
21
  end
22
22
 
23
- def self.server
23
+ def self.server(host = "127.0.0.1")
24
24
  @unix_socket_uri ||= begin
25
25
  tempfile = Tempfile.new("mini_proxy")
26
26
  socket_path = tempfile.path
@@ -37,6 +37,7 @@ module MiniProxy
37
37
  begin
38
38
  fake_server_port = SERVER_DYNAMIC_PORT_RANGE.sample
39
39
  fake_server = FakeSSLServer.new(
40
+ MiniProxyHost: host,
40
41
  Port: fake_server_port,
41
42
  MockHandlerCallback: remote.method(:handler),
42
43
  )
@@ -48,6 +49,7 @@ module MiniProxy
48
49
  begin
49
50
  remote.port = ENV["MINI_PROXY_PORT"] || SERVER_DYNAMIC_PORT_RANGE.sample
50
51
  proxy = MiniProxy::ProxyServer.new(
52
+ MiniProxyHost: host,
51
53
  Port: remote.port,
52
54
  FakeServerPort: fake_server_port,
53
55
  MockHandlerCallback: remote.method(:handler),
@@ -1,3 +1,3 @@
1
1
  module MiniProxy
2
- VERSION = "0.2.1".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miniproxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Conversation Dev Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-02 00:00:00.000000000 Z
11
+ date: 2018-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec