diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-02-02 15:22:02 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-02-02 15:31:36 -0800 |
commit | 87fd86ef22b6b80fa75dd8e50f53a4e62e8339f7 (patch) | |
tree | e9fe3c0192cccba80b65839cd910270089140ed3 /lib/unicorn/configurator.rb | |
parent | d140e7b1ff44b06bc54c2b790d06e9c7325503fe (diff) | |
download | unicorn-87fd86ef22b6b80fa75dd8e50f53a4e62e8339f7.tar.gz |
This is much like how nginx does it, except we always require a port when explicitly binding to IPv6 using the "listen" directive. This also adds support to listen with an address-only, which can be useful to Rainbows! users.
Diffstat (limited to 'lib/unicorn/configurator.rb')
-rw-r--r-- | lib/unicorn/configurator.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index 9aa84f1..8913928 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -473,10 +473,10 @@ class Unicorn::Configurator File.expand_path(address) when %r{\A(?:\*:)?(\d+)\z} "0.0.0.0:#$1" - when %r{\A(.*):(\d+)\z} - # canonicalize the name - packed = Socket.pack_sockaddr_in($2.to_i, $1) - Socket.unpack_sockaddr_in(packed).reverse!.join(':') + when %r{\A\[([a-fA-F0-9:]+)\]\z}, %r/\A((?:\d+\.){3}\d+)\z/ + canonicalize_tcp($1, 80) + when %r{\A\[([a-fA-F0-9:]+)\]:(\d+)\z}, %r{\A(.*):(\d+)\z} + canonicalize_tcp($1, $2.to_i) else address end @@ -489,6 +489,12 @@ private set[var] = n end + def canonicalize_tcp(addr, port) + packed = Socket.pack_sockaddr_in(port, addr) + port, addr = Socket.unpack_sockaddr_in(packed) + /:/ =~ addr ? "[#{addr}]:#{port}" : "#{addr}:#{port}" + end + def set_path(var, path) #:nodoc: case path when NilClass, String |