mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
cmd/ctrld: do not try random local ip if IP is v4/v6 zero
This commit is contained in:
committed by
Cuong Manh Le
parent
dc61fd2554
commit
e65a71b2ae
@@ -1253,6 +1253,7 @@ func updateListenerConfig() {
|
||||
check := lcc[strconv.Itoa(n)]
|
||||
oldIP := listener.IP
|
||||
oldPort := listener.Port
|
||||
isZeroIP := listener.IP == "0.0.0.0" || listener.IP == "::"
|
||||
|
||||
// Check if we could listen on the current IP + Port, if not, try following thing, pick first one success:
|
||||
// - Try 127.0.0.1:53
|
||||
@@ -1331,7 +1332,7 @@ func updateListenerConfig() {
|
||||
mainLog.Warn().Msgf("could not listen on address: %s, trying 0.0.0.0:5354", addr)
|
||||
continue
|
||||
}
|
||||
if check.IP {
|
||||
if check.IP && !isZeroIP { // for "0.0.0.0" or "::", we only need to try new port.
|
||||
listener.IP = randomLocalIP()
|
||||
} else {
|
||||
listener.IP = oldIP
|
||||
|
||||
Reference in New Issue
Block a user