1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Explicitly listen on all localhost addresses. Fixes #782

This commit is contained in:
Evan Phoenix 2016-07-18 21:42:29 -07:00
parent 181c472781
commit 9b1de10004

View file

@ -242,7 +242,11 @@ module Puma
# We have to unlink a unix socket path that's not being used
File.unlink key[1] if key[0] == :unix
end
end
def localhost_addresses
addrs = TCPSocket.gethostbyname "localhost"
addrs[3..-1]
end
# Tell the server to listen on host +host+, port +port+.
@ -253,6 +257,13 @@ module Puma
# allow to accumulate before returning connection refused.
#
def add_tcp_listener(host, port, optimize_for_latency=true, backlog=1024)
if host == "localhost"
localhost_addresses.each do |addr|
add_tcp_listener addr, port, optimize_for_latency, backlog
end
return
end
host = host[1..-2] if host and host[0..0] == '['
s = TCPServer.new(host, port)
if optimize_for_latency
@ -285,6 +296,13 @@ module Puma
MiniSSL.check
if host == "localhost"
localhost_addresses.each do |addr|
add_ssl_listener addr, port, optimize_for_latency, backlog
end
return
end
host = host[1..-2] if host[0..0] == '['
s = TCPServer.new(host, port)
if optimize_for_latency