config: bind naked ports to localhost
If only a port is given as a config value for a listener we'll default to only binding that port to localhost.
This commit is contained in:
parent
ffb1b65eca
commit
87333ba829
@ -1099,7 +1099,13 @@ func normalizeAddresses(addrs []string, defaultPort string) []string {
|
|||||||
seen := map[string]struct{}{}
|
seen := map[string]struct{}{}
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
if _, _, err := net.SplitHostPort(addr); err != nil {
|
if _, _, err := net.SplitHostPort(addr); err != nil {
|
||||||
addr = net.JoinHostPort(addr, defaultPort)
|
// If the address is an integer, then we assume it is *only* a
|
||||||
|
// port and default to binding to that port on localhost
|
||||||
|
if _, err := strconv.Atoi(addr); err == nil {
|
||||||
|
addr = net.JoinHostPort("localhost", addr)
|
||||||
|
} else {
|
||||||
|
addr = net.JoinHostPort(addr, defaultPort)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if _, ok := seen[addr]; !ok {
|
if _, ok := seen[addr]; !ok {
|
||||||
result = append(result, addr)
|
result = append(result, addr)
|
||||||
|
Loading…
Reference in New Issue
Block a user