puma 5.4.0 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puma might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/History.md +30 -2
- data/README.md +24 -5
- data/docs/systemd.md +1 -0
- data/lib/puma/binder.rb +29 -1
- data/lib/puma/cli.rb +5 -0
- data/lib/puma/client.rb +44 -2
- data/lib/puma/const.rb +4 -2
- data/lib/puma/dsl.rb +13 -3
- data/lib/puma/launcher.rb +2 -0
- data/lib/puma/minissl.rb +5 -20
- data/lib/puma/server.rb +8 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf7876f05ec5908081837654da902bb4e92b7594a36dd37f6a71995c7d84626f
|
4
|
+
data.tar.gz: ba1aa508c1c05e514ae29037f3fb3407e253ce2145552104a982579e7eb75835
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e7057acca8dc5d1289329ab354fc973120c6bd9a3d95da2ab81456f95cacda3d4c8066064461dabd0e90fc8a92789c316e434ca4804be481b7aa36d39304425
|
7
|
+
data.tar.gz: 2708065b37d07c3b6b1a3ba9fa184b36b55647ce5d91cd3fbc7f7df8d561c8bec42e9b97191cd5247b2fcad68877b2c577f11d3ac4934fcf25b31a0d8ce2cfb2
|
data/History.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## 5.5.0 / 2021-09-19
|
2
|
+
|
3
|
+
* Features
|
4
|
+
* Automatic SSL certificate provisioning for localhost, via localhost gem ([#2610], [#2257])
|
5
|
+
* add support for the PROXY protocol (v1 only) ([#2654], [#2651])
|
6
|
+
* Add a semantic CLI option for no config file ([#2689])
|
7
|
+
|
8
|
+
* Bugfixes
|
9
|
+
* More elaborate exception handling - lets some dead pumas die. ([#2700], [#2699])
|
10
|
+
* allow multiple after_worker_fork hooks ([#2690])
|
11
|
+
* Preserve BUNDLE_APP_CONFIG on worker fork ([#2688], [#2687])
|
12
|
+
|
13
|
+
* Performance
|
14
|
+
* Fix performance of server-side SSL connection close. ([#2675])
|
15
|
+
|
1
16
|
## 5.4.0 / 2021-07-28
|
2
17
|
|
3
18
|
* Features
|
@@ -9,6 +24,7 @@
|
|
9
24
|
* `Binder#parse` - allow for symlinked unix path, add create_activated_fds debug ENV ([#2643], [#2638])
|
10
25
|
* Fix deprecation warning: minissl.c - Use Random.bytes if available ([#2642])
|
11
26
|
* Client certificates: set session id context while creating SSLContext ([#2633])
|
27
|
+
* Fix deadlock issue in thread pool ([#2656])
|
12
28
|
|
13
29
|
* Refactor
|
14
30
|
* Replace `IO.select` with `IO#wait_*` when checking a single IO ([#2666])
|
@@ -1768,6 +1784,17 @@ be added back in a future date when a java Puma::MiniSSL is added.
|
|
1768
1784
|
* Bugfixes
|
1769
1785
|
* Your bugfix goes here <Most recent on the top, like GitHub> (#Github Number)
|
1770
1786
|
|
1787
|
+
[#2610]:https://github.com/puma/puma/pull/2610 "PR by @ye-lin-aung, merged 2021-08-18"
|
1788
|
+
[#2257]:https://github.com/puma/puma/issues/2257 "Issue by @nateberkopec, closed 2021-08-18"
|
1789
|
+
[#2654]:https://github.com/puma/puma/pull/2654 "PR by @Roguelazer, merged 2021-09-07"
|
1790
|
+
[#2651]:https://github.com/puma/puma/issues/2651 "Issue by @Roguelazer, closed 2021-09-07"
|
1791
|
+
[#2689]:https://github.com/puma/puma/pull/2689 "PR by @jacobherrington, merged 2021-09-05"
|
1792
|
+
[#2700]:https://github.com/puma/puma/pull/2700 "PR by @ioquatix, merged 2021-09-16"
|
1793
|
+
[#2699]:https://github.com/puma/puma/issues/2699 "Issue by @ioquatix, closed 2021-09-16"
|
1794
|
+
[#2690]:https://github.com/puma/puma/pull/2690 "PR by @doits, merged 2021-09-06"
|
1795
|
+
[#2688]:https://github.com/puma/puma/pull/2688 "PR by @jdelStrother, merged 2021-09-03"
|
1796
|
+
[#2687]:https://github.com/puma/puma/issues/2687 "Issue by @jdelStrother, closed 2021-09-03"
|
1797
|
+
[#2675]:https://github.com/puma/puma/pull/2675 "PR by @devwout, merged 2021-09-08"
|
1771
1798
|
[#2657]:https://github.com/puma/puma/pull/2657 "PR by @olivierbellone, merged 2021-07-13"
|
1772
1799
|
[#2648]:https://github.com/puma/puma/pull/2648 "PR by @MSP-Greg, merged 2021-06-27"
|
1773
1800
|
[#1412]:https://github.com/puma/puma/issues/1412 "Issue by @x-yuri, closed 2021-06-27"
|
@@ -1777,6 +1804,7 @@ be added back in a future date when a java Puma::MiniSSL is added.
|
|
1777
1804
|
[#2638]:https://github.com/puma/puma/issues/2638 "Issue by @gingerlime, closed 2021-06-27"
|
1778
1805
|
[#2642]:https://github.com/puma/puma/pull/2642 "PR by @MSP-Greg, merged 2021-06-16"
|
1779
1806
|
[#2633]:https://github.com/puma/puma/pull/2633 "PR by @onlined, merged 2021-06-04"
|
1807
|
+
[#2656]:https://github.com/puma/puma/pull/2656 "PR by @olivierbellone, merged 2021-07-07"
|
1780
1808
|
[#2666]:https://github.com/puma/puma/pull/2666 "PR by @MSP-Greg, merged 2021-07-25"
|
1781
1809
|
[#2630]:https://github.com/puma/puma/pull/2630 "PR by @seangoedecke, merged 2021-05-20"
|
1782
1810
|
[#2626]:https://github.com/puma/puma/issues/2626 "Issue by @rorymckinley, closed 2021-05-20"
|
@@ -1800,8 +1828,8 @@ be added back in a future date when a java Puma::MiniSSL is added.
|
|
1800
1828
|
[#2552]:https://github.com/puma/puma/issues/2552 "Issue by @feliperaul, closed 2021-05-24"
|
1801
1829
|
[#2606]:https://github.com/puma/puma/pull/2606 "PR by @wjordan, merged 2021-04-20"
|
1802
1830
|
[#2574]:https://github.com/puma/puma/issues/2574 "Issue by @darkhelmet, closed 2021-04-20"
|
1803
|
-
[#2567]:https://github.com/puma/puma/pull/2567 "PR by @
|
1804
|
-
[#2566]:https://github.com/puma/puma/issues/2566 "Issue by @
|
1831
|
+
[#2567]:https://github.com/puma/puma/pull/2567 "PR by @kddnewton, merged 2021-04-19"
|
1832
|
+
[#2566]:https://github.com/puma/puma/issues/2566 "Issue by @kddnewton, closed 2021-04-19"
|
1805
1833
|
[#2596]:https://github.com/puma/puma/pull/2596 "PR by @MSP-Greg, merged 2021-04-18"
|
1806
1834
|
[#2588]:https://github.com/puma/puma/pull/2588 "PR by @dentarg, merged 2021-04-02"
|
1807
1835
|
[#2556]:https://github.com/puma/puma/issues/2556 "Issue by @gamecreature, closed 2021-04-02"
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<img src="https://puma.io/images/logos/puma-logo-large.png">
|
3
3
|
</p>
|
4
4
|
|
5
|
-
# Puma: A Ruby Web Server Built For
|
5
|
+
# Puma: A Ruby Web Server Built For Parallelism
|
6
6
|
|
7
7
|
[![Actions MRI](https://github.com/puma/puma/workflows/MRI/badge.svg?branch=master)](https://github.com/puma/puma/actions?query=workflow%3AMRI)
|
8
8
|
[![Actions non MRI](https://github.com/puma/puma/workflows/non_MRI/badge.svg?branch=master)](https://github.com/puma/puma/actions?query=workflow%3Anon_MRI)
|
@@ -10,11 +10,11 @@
|
|
10
10
|
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=puma&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=puma&package-manager=bundler&version-scheme=semver)
|
11
11
|
[![StackOverflow](https://img.shields.io/badge/stackoverflow-Puma-blue.svg)]( https://stackoverflow.com/questions/tagged/puma )
|
12
12
|
|
13
|
-
Puma is a **simple, fast, multi-threaded, and highly
|
13
|
+
Puma is a **simple, fast, multi-threaded, and highly parallel HTTP 1.1 server for Ruby/Rack applications**.
|
14
14
|
|
15
|
-
## Built For Speed &
|
15
|
+
## Built For Speed & Parallelism
|
16
16
|
|
17
|
-
Puma processes requests using a C-optimized Ragel extension (inherited from Mongrel) that provides fast, accurate HTTP 1.1 protocol parsing in a portable way. Puma then serves the request using a thread pool. Each request is served in a separate thread, so truly
|
17
|
+
Puma processes requests using a C-optimized Ragel extension (inherited from Mongrel) that provides fast, accurate HTTP 1.1 protocol parsing in a portable way. Puma then serves the request using a thread pool. Each request is served in a separate thread, so truly parallel Ruby implementations (JRuby, Rubinius) will use all available CPU cores.
|
18
18
|
|
19
19
|
Originally designed as a server for [Rubinius](https://github.com/rubinius/rubinius), Puma also works well with Ruby (MRI) and JRuby.
|
20
20
|
|
@@ -187,6 +187,21 @@ Need a bit of security? Use SSL sockets:
|
|
187
187
|
```
|
188
188
|
$ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
|
189
189
|
```
|
190
|
+
#### Self-signed SSL certificates (via _localhost_ gem, for development use):
|
191
|
+
|
192
|
+
Puma supports [localhost](https://github.com/socketry/localhost) gem for self-signed certificates. This is particularly useful if you want to use Puma with SSL locally, and self-signed certificates will work for your use-case. Currently, `localhost-authority` can be used only in MRI. To use [localhost](https://github.com/socketry/localhost), you have to `require "localhost/authority"`:
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
# config.ru
|
196
|
+
require './app'
|
197
|
+
require 'localhost/authority'
|
198
|
+
run Sinatra::Application
|
199
|
+
|
200
|
+
...
|
201
|
+
|
202
|
+
$ puma -b 'ssl://localhost:9292' config.ru
|
203
|
+
```
|
204
|
+
|
190
205
|
|
191
206
|
#### Controlling SSL Cipher Suites
|
192
207
|
|
@@ -257,9 +272,13 @@ $ puma -C /path/to/config
|
|
257
272
|
|
258
273
|
If no configuration file is specified, Puma will look for a configuration file at `config/puma.rb`. If an environment is specified, either via the `-e` and `--environment` flags, or through the `RACK_ENV` or the `RAILS_ENV` environment variables, Puma first looks for configuration at `config/puma/<environment_name>.rb`, and then falls back to `config/puma.rb`.
|
259
274
|
|
260
|
-
If you want to prevent Puma from looking for a configuration file in those locations,
|
275
|
+
If you want to prevent Puma from looking for a configuration file in those locations, include the `--no-config` flag:
|
261
276
|
|
262
277
|
```
|
278
|
+
$ puma --no-config
|
279
|
+
|
280
|
+
# or
|
281
|
+
|
263
282
|
$ puma -C "-"
|
264
283
|
```
|
265
284
|
|
data/docs/systemd.md
CHANGED
data/lib/puma/binder.rb
CHANGED
@@ -57,6 +57,7 @@ module Puma
|
|
57
57
|
|
58
58
|
@envs = {}
|
59
59
|
@ios = []
|
60
|
+
localhost_authority
|
60
61
|
end
|
61
62
|
|
62
63
|
attr_reader :ios
|
@@ -227,7 +228,13 @@ module Puma
|
|
227
228
|
raise "Puma compiled without SSL support" unless HAS_SSL
|
228
229
|
|
229
230
|
params = Util.parse_query uri.query
|
230
|
-
|
231
|
+
|
232
|
+
# If key and certs are not defined and localhost gem is required.
|
233
|
+
# localhost gem will be used for self signed
|
234
|
+
# Load localhost authority if not loaded.
|
235
|
+
ctx = localhost_authority && localhost_authority_context if params.empty?
|
236
|
+
|
237
|
+
ctx ||= MiniSSL::ContextBuilder.new(params, @events).context
|
231
238
|
|
232
239
|
if fd = @inherited_fds.delete(str)
|
233
240
|
logger.log "* Inherited #{str}"
|
@@ -285,6 +292,22 @@ module Puma
|
|
285
292
|
end
|
286
293
|
end
|
287
294
|
|
295
|
+
def localhost_authority
|
296
|
+
@localhost_authority ||= Localhost::Authority.fetch if defined?(Localhost::Authority) && !Puma::IS_JRUBY
|
297
|
+
end
|
298
|
+
|
299
|
+
def localhost_authority_context
|
300
|
+
return unless localhost_authority
|
301
|
+
|
302
|
+
key_path, crt_path = if [:key_path, :certificate_path].all? { |m| localhost_authority.respond_to?(m) }
|
303
|
+
[localhost_authority.key_path, localhost_authority.certificate_path]
|
304
|
+
else
|
305
|
+
local_certificates_path = File.expand_path("~/.localhost")
|
306
|
+
[File.join(local_certificates_path, "localhost.key"), File.join(local_certificates_path, "localhost.crt")]
|
307
|
+
end
|
308
|
+
MiniSSL::ContextBuilder.new({ "key" => key_path, "cert" => crt_path }, @events).context
|
309
|
+
end
|
310
|
+
|
288
311
|
# Tell the server to listen on host +host+, port +port+.
|
289
312
|
# If +optimize_for_latency+ is true (the default) then clients connecting
|
290
313
|
# will be optimized for latency over throughput.
|
@@ -302,6 +325,7 @@ module Puma
|
|
302
325
|
|
303
326
|
host = host[1..-2] if host and host[0..0] == '['
|
304
327
|
tcp_server = TCPServer.new(host, port)
|
328
|
+
|
305
329
|
if optimize_for_latency
|
306
330
|
tcp_server.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
307
331
|
end
|
@@ -323,6 +347,8 @@ module Puma
|
|
323
347
|
optimize_for_latency=true, backlog=1024)
|
324
348
|
|
325
349
|
raise "Puma compiled without SSL support" unless HAS_SSL
|
350
|
+
# Puma will try to use local authority context if context is supplied nil
|
351
|
+
ctx ||= localhost_authority_context
|
326
352
|
|
327
353
|
if host == "localhost"
|
328
354
|
loopback_addresses.each do |addr|
|
@@ -350,6 +376,8 @@ module Puma
|
|
350
376
|
|
351
377
|
def inherit_ssl_listener(fd, ctx)
|
352
378
|
raise "Puma compiled without SSL support" unless HAS_SSL
|
379
|
+
# Puma will try to use local authority context if context is supplied nil
|
380
|
+
ctx ||= localhost_authority_context
|
353
381
|
|
354
382
|
s = fd.kind_of?(::TCPServer) ? fd : ::TCPServer.for_fd(fd)
|
355
383
|
|
data/lib/puma/cli.rb
CHANGED
@@ -112,6 +112,11 @@ module Puma
|
|
112
112
|
file_config.load arg
|
113
113
|
end
|
114
114
|
|
115
|
+
# Identical to supplying --config "-", but more semantic
|
116
|
+
o.on "--no-config", "Prevent Puma from searching for a config file" do |arg|
|
117
|
+
file_config.load "-"
|
118
|
+
end
|
119
|
+
|
115
120
|
o.on "--control-url URL", "The bind url to use for the control server. Use 'auto' to use temp unix server" do |arg|
|
116
121
|
configure_control_url(arg)
|
117
122
|
end
|
data/lib/puma/client.rb
CHANGED
@@ -56,6 +56,7 @@ module Puma
|
|
56
56
|
@parser = HttpParser.new
|
57
57
|
@parsed_bytes = 0
|
58
58
|
@read_header = true
|
59
|
+
@read_proxy = false
|
59
60
|
@ready = false
|
60
61
|
|
61
62
|
@body = nil
|
@@ -71,6 +72,7 @@ module Puma
|
|
71
72
|
@peerip = nil
|
72
73
|
@listener = nil
|
73
74
|
@remote_addr_header = nil
|
75
|
+
@expect_proxy_proto = false
|
74
76
|
|
75
77
|
@body_remain = 0
|
76
78
|
|
@@ -106,7 +108,7 @@ module Puma
|
|
106
108
|
|
107
109
|
# @!attribute [r] in_data_phase
|
108
110
|
def in_data_phase
|
109
|
-
|
111
|
+
!(@read_header || @read_proxy)
|
110
112
|
end
|
111
113
|
|
112
114
|
def set_timeout(val)
|
@@ -121,6 +123,7 @@ module Puma
|
|
121
123
|
def reset(fast_check=true)
|
122
124
|
@parser.reset
|
123
125
|
@read_header = true
|
126
|
+
@read_proxy = !!@expect_proxy_proto
|
124
127
|
@env = @proto_env.dup
|
125
128
|
@body = nil
|
126
129
|
@tempfile = nil
|
@@ -131,6 +134,8 @@ module Puma
|
|
131
134
|
@in_last_chunk = false
|
132
135
|
|
133
136
|
if @buffer
|
137
|
+
return false unless try_to_parse_proxy_protocol
|
138
|
+
|
134
139
|
@parsed_bytes = @parser.execute(@env, @buffer, @parsed_bytes)
|
135
140
|
|
136
141
|
if @parser.finished?
|
@@ -161,8 +166,32 @@ module Puma
|
|
161
166
|
end
|
162
167
|
end
|
163
168
|
|
169
|
+
# If necessary, read the PROXY protocol from the buffer. Returns
|
170
|
+
# false if more data is needed.
|
171
|
+
def try_to_parse_proxy_protocol
|
172
|
+
if @read_proxy
|
173
|
+
if @expect_proxy_proto == :v1
|
174
|
+
if @buffer.include? "\r\n"
|
175
|
+
if md = PROXY_PROTOCOL_V1_REGEX.match(@buffer)
|
176
|
+
if md[1]
|
177
|
+
@peerip = md[1].split(" ")[0]
|
178
|
+
end
|
179
|
+
@buffer = md.post_match
|
180
|
+
end
|
181
|
+
# if the buffer has a \r\n but doesn't have a PROXY protocol
|
182
|
+
# request, this is just HTTP from a non-PROXY client; move on
|
183
|
+
@read_proxy = false
|
184
|
+
return @buffer.size > 0
|
185
|
+
else
|
186
|
+
return false
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
true
|
191
|
+
end
|
192
|
+
|
164
193
|
def try_to_finish
|
165
|
-
return read_body
|
194
|
+
return read_body if in_data_phase
|
166
195
|
|
167
196
|
begin
|
168
197
|
data = @io.read_nonblock(CHUNK_SIZE)
|
@@ -187,6 +216,8 @@ module Puma
|
|
187
216
|
@buffer = data
|
188
217
|
end
|
189
218
|
|
219
|
+
return false unless try_to_parse_proxy_protocol
|
220
|
+
|
190
221
|
@parsed_bytes = @parser.execute(@env, @buffer, @parsed_bytes)
|
191
222
|
|
192
223
|
if @parser.finished?
|
@@ -243,6 +274,17 @@ module Puma
|
|
243
274
|
@parsed_bytes == 0
|
244
275
|
end
|
245
276
|
|
277
|
+
def expect_proxy_proto=(val)
|
278
|
+
if val
|
279
|
+
if @read_header
|
280
|
+
@read_proxy = true
|
281
|
+
end
|
282
|
+
else
|
283
|
+
@read_proxy = false
|
284
|
+
end
|
285
|
+
@expect_proxy_proto = val
|
286
|
+
end
|
287
|
+
|
246
288
|
private
|
247
289
|
|
248
290
|
def setup_body
|
data/lib/puma/const.rb
CHANGED
@@ -100,8 +100,8 @@ module Puma
|
|
100
100
|
# too taxing on performance.
|
101
101
|
module Const
|
102
102
|
|
103
|
-
PUMA_VERSION = VERSION = "5.
|
104
|
-
CODE_NAME = "
|
103
|
+
PUMA_VERSION = VERSION = "5.5.0".freeze
|
104
|
+
CODE_NAME = "Zawgyi".freeze
|
105
105
|
|
106
106
|
PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
|
107
107
|
|
@@ -247,5 +247,7 @@ module Puma
|
|
247
247
|
|
248
248
|
# Banned keys of response header
|
249
249
|
BANNED_HEADER_KEY = /\A(rack\.|status\z)/.freeze
|
250
|
+
|
251
|
+
PROXY_PROTOCOL_V1_REGEX = /^PROXY (?:TCP4|TCP6|UNKNOWN) ([^\r]+)\r\n/.freeze
|
250
252
|
end
|
251
253
|
end
|
data/lib/puma/dsl.rb
CHANGED
@@ -585,7 +585,7 @@ module Puma
|
|
585
585
|
# end
|
586
586
|
def after_worker_fork(&block)
|
587
587
|
@options[:after_worker_fork] ||= []
|
588
|
-
@options[:after_worker_fork]
|
588
|
+
@options[:after_worker_fork] << block
|
589
589
|
end
|
590
590
|
|
591
591
|
alias_method :after_worker_boot, :after_worker_fork
|
@@ -818,7 +818,7 @@ module Puma
|
|
818
818
|
# a kernel syscall is required which for very fast rack handlers
|
819
819
|
# slows down the handling significantly.
|
820
820
|
#
|
821
|
-
# There are
|
821
|
+
# There are 5 possible values:
|
822
822
|
#
|
823
823
|
# 1. **:socket** (the default) - read the peername from the socket using the
|
824
824
|
# syscall. This is the normal behavior.
|
@@ -828,7 +828,10 @@ module Puma
|
|
828
828
|
# `set_remote_address header: "X-Real-IP"`.
|
829
829
|
# Only the first word (as separated by spaces or comma) is used, allowing
|
830
830
|
# headers such as X-Forwarded-For to be used as well.
|
831
|
-
# 4.
|
831
|
+
# 4. **proxy_protocol: :v1**- set the remote address to the value read from the
|
832
|
+
# HAproxy PROXY protocol, version 1. If the request does not have the PROXY
|
833
|
+
# protocol attached to it, will fall back to :socket
|
834
|
+
# 5. **\<Any string\>** - this allows you to hardcode remote address to any value
|
832
835
|
# you wish. Because Puma never uses this field anyway, it's format is
|
833
836
|
# entirely in your hands.
|
834
837
|
#
|
@@ -846,6 +849,13 @@ module Puma
|
|
846
849
|
if hdr = val[:header]
|
847
850
|
@options[:remote_address] = :header
|
848
851
|
@options[:remote_address_header] = "HTTP_" + hdr.upcase.tr("-", "_")
|
852
|
+
elsif protocol_version = val[:proxy_protocol]
|
853
|
+
@options[:remote_address] = :proxy_protocol
|
854
|
+
protocol_version = protocol_version.downcase.to_sym
|
855
|
+
unless [:v1].include?(protocol_version)
|
856
|
+
raise "Invalid value for proxy_protocol - #{protocol_version.inspect}"
|
857
|
+
end
|
858
|
+
@options[:remote_address_proxy_protocol] = protocol_version
|
849
859
|
else
|
850
860
|
raise "Invalid value for set_remote_address - #{val.inspect}"
|
851
861
|
end
|
data/lib/puma/launcher.rb
CHANGED
@@ -319,10 +319,12 @@ module Puma
|
|
319
319
|
log '* Pruning Bundler environment'
|
320
320
|
home = ENV['GEM_HOME']
|
321
321
|
bundle_gemfile = Bundler.original_env['BUNDLE_GEMFILE']
|
322
|
+
bundle_app_config = Bundler.original_env['BUNDLE_APP_CONFIG']
|
322
323
|
with_unbundled_env do
|
323
324
|
ENV['GEM_HOME'] = home
|
324
325
|
ENV['BUNDLE_GEMFILE'] = bundle_gemfile
|
325
326
|
ENV['PUMA_BUNDLER_PRUNED'] = '1'
|
327
|
+
ENV["BUNDLE_APP_CONFIG"] = bundle_app_config
|
326
328
|
args = [Gem.ruby, puma_wild_location, '-I', dirs.join(':')] + @original_argv
|
327
329
|
# Ruby 2.0+ defaults to true which breaks socket activation
|
328
330
|
args += [{:close_others => false}]
|
data/lib/puma/minissl.rb
CHANGED
@@ -161,28 +161,13 @@ module Puma
|
|
161
161
|
@socket.flush
|
162
162
|
end
|
163
163
|
|
164
|
-
def read_and_drop(timeout = 1)
|
165
|
-
return :timeout unless @socket.wait_readable(timeout)
|
166
|
-
case @socket.read_nonblock(1024, exception: false)
|
167
|
-
when nil
|
168
|
-
:eof
|
169
|
-
when :wait_readable
|
170
|
-
:eagain
|
171
|
-
else
|
172
|
-
:drop
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
def should_drop_bytes?
|
177
|
-
@engine.init? || !@engine.shutdown
|
178
|
-
end
|
179
|
-
|
180
164
|
def close
|
181
165
|
begin
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
166
|
+
unless @engine.shutdown
|
167
|
+
while alert_data = @engine.extract
|
168
|
+
@socket.write alert_data
|
169
|
+
end
|
170
|
+
end
|
186
171
|
rescue IOError, SystemCallError
|
187
172
|
Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue
|
188
173
|
# nothing
|
data/lib/puma/server.rb
CHANGED
@@ -323,6 +323,8 @@ module Puma
|
|
323
323
|
remote_addr_value = @options[:remote_address_value]
|
324
324
|
when :header
|
325
325
|
remote_addr_header = @options[:remote_address_header]
|
326
|
+
when :proxy_protocol
|
327
|
+
remote_addr_proxy_protocol = @options[:remote_address_proxy_protocol]
|
326
328
|
end
|
327
329
|
|
328
330
|
while @status == :run || (drain && shutting_down?)
|
@@ -348,11 +350,16 @@ module Puma
|
|
348
350
|
client.peerip = remote_addr_value
|
349
351
|
elsif remote_addr_header
|
350
352
|
client.remote_addr_header = remote_addr_header
|
353
|
+
elsif remote_addr_proxy_protocol
|
354
|
+
client.expect_proxy_proto = remote_addr_proxy_protocol
|
351
355
|
end
|
352
356
|
pool << client
|
353
357
|
end
|
354
358
|
end
|
355
|
-
rescue
|
359
|
+
rescue IOError, Errno::EBADF
|
360
|
+
# In the case that any of the sockets are unexpectedly close.
|
361
|
+
raise
|
362
|
+
rescue StandardError => e
|
356
363
|
@events.unknown_error e, nil, "Listen loop"
|
357
364
|
end
|
358
365
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Phoenix
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nio4r
|
@@ -24,9 +24,9 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
-
description: Puma is a simple, fast, threaded, and highly
|
27
|
+
description: Puma is a simple, fast, threaded, and highly parallel HTTP 1.1 server
|
28
28
|
for Ruby/Rack applications. Puma is intended for use in both development and production
|
29
|
-
environments. It's great for highly
|
29
|
+
environments. It's great for highly parallel Ruby implementations such as Rubinius
|
30
30
|
and JRuby as well as as providing process worker support to support CRuby well.
|
31
31
|
email:
|
32
32
|
- evan@phx.io
|
@@ -143,6 +143,6 @@ requirements: []
|
|
143
143
|
rubygems_version: 3.2.3
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
|
-
summary: Puma is a simple, fast, threaded, and highly
|
146
|
+
summary: Puma is a simple, fast, threaded, and highly parallel HTTP 1.1 server for
|
147
147
|
Ruby/Rack applications
|
148
148
|
test_files: []
|