mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +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
1 changed files with 7 additions and 1 deletions
|
@ -1099,7 +1099,13 @@ func normalizeAddresses(addrs []string, defaultPort string) []string {
|
|||
seen := map[string]struct{}{}
|
||||
for _, addr := range addrs {
|
||||
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 {
|
||||
result = append(result, addr)
|
||||
|
|
Loading…
Add table
Reference in a new issue