mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
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,8 +1099,14 @@ func normalizeAddresses(addrs []string, defaultPort string) []string {
|
||||
seen := map[string]struct{}{}
|
||||
for _, addr := range addrs {
|
||||
if _, _, err := net.SplitHostPort(addr); err != nil {
|
||||
// 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 {
|
||||
result = append(result, addr)
|
||||
seen[addr] = struct{}{}
|
||||
|
Loading…
Reference in New Issue
Block a user