forward-proxy 0.6.2 → 0.7.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: a1fe517be17887550c0afe7d8ad757227d79667083ad5530aa714a8e0b2398be
4
- data.tar.gz: 574b65e5fd8bf6e324f0657f8bfc87342481c5f177c87f1e9f2cffe49953db17
3
+ metadata.gz: 3018291ebebbfa87a02ba1409fa3f0c0af9b5d0ffb8917636dd4f8e397d8a4fb
4
+ data.tar.gz: dd3420d19ee1ac89064d7fd965768072cc25ce100555a4dc59881530fc2b6d66
5
5
  SHA512:
6
- metadata.gz: 34d36e4bfc21abaf59a75ecec4fa86b5d9157beb5e7f7437201f15689f584fb92076f6db5095929d52062b6c543a53d65bc81393bc5013204206d8f2c041c4d2
7
- data.tar.gz: 4e7c99b2485929fe9fb93da86256bd642ff56f8f93207b3cdd0eccc6606d4c6f53d64514adbf550831062185390ae5b1327619bfa26dcd2631ca817acab6c36d
6
+ metadata.gz: c1676662f33627745b09c2049957a4232885862bac77ba4f1ecb48b085683ef832825d2a0b15c725bdf6553456bb710c1b847f4027e55e8ed31c1c31aa1b307f
7
+ data.tar.gz: '08652da6a675acfb0c371d571bad140d3a50673d76d2aae74ea6a33f2b4f1e21b07f3378fcaaf74099d6fe93de29cc923108c1d278a9364b885b80a405951643'
@@ -12,7 +12,7 @@ module ForwardProxy
12
12
  class Server
13
13
  attr_reader :bind_address, :bind_port, :logger, :timeout
14
14
 
15
- def initialize(bind_address: "127.0.0.1", bind_port: 9292, threads: 4, timeout: 300, logger: default_logger)
15
+ def initialize(bind_address: "127.0.0.1", bind_port: 9292, threads: 128, timeout: 300, logger: default_logger)
16
16
  @bind_address = bind_address
17
17
  @bind_port = bind_port
18
18
  @logger = logger
@@ -67,14 +67,14 @@ module ForwardProxy
67
67
 
68
68
  attr_reader :socket, :thread_pool
69
69
 
70
- # The following comments are from the IETF document
71
- # "Hypertext Transfer Protocol -- HTTP/1.1: Basic Rules"
72
- # https://datatracker.ietf.org/doc/html/rfc2616#section-2.2
73
-
74
70
  METHOD_CONNECT = "CONNECT"
75
71
  METHOD_GET = "GET"
76
72
  METHOD_POST = "POST"
77
73
 
74
+ # The following comments are from the IETF document
75
+ # "Hypertext Transfer Protocol -- HTTP/1.1: Basic Rules"
76
+ # https://datatracker.ietf.org/doc/html/rfc2616#section-2.2
77
+
78
78
  # HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all
79
79
  # protocol elements except the entity-body.
80
80
  HEADER_EOP = "\r\n"
@@ -1,24 +1,29 @@
1
1
  module ForwardProxy
2
2
  class ThreadPool
3
- attr_reader :queue, :size
3
+ attr_reader :queue, :size, :threads
4
4
 
5
5
  def initialize(size)
6
- @size = size
7
- @queue = Queue.new
6
+ @queue = Queue.new
7
+ @size = size
8
+ @threads = []
8
9
  end
9
10
 
10
11
  def start
11
12
  size.times do
12
- Thread.new do
13
+ thread = Thread.new do
13
14
  loop do
14
15
  job, args = queue.pop
15
16
  job.call(*args)
16
17
  end
17
18
  end
19
+
20
+ threads.push(thread)
18
21
  end
19
22
  end
20
23
 
21
24
  def schedule(*args, &block)
25
+ raise Exception, "no threads" unless threads.any?(&:alive?)
26
+
22
27
  queue.push([block, args])
23
28
  end
24
29
  end
@@ -1,3 +1,3 @@
1
1
  module ForwardProxy
2
- VERSION = "0.6.2"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forward-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Moriarty
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-17 00:00:00.000000000 Z
11
+ date: 2021-07-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Forward proxy using just Ruby standard libraries.
14
14
  email: