mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +02: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
+2
-1
@@ -1253,6 +1253,7 @@ func updateListenerConfig() {
|
|||||||
check := lcc[strconv.Itoa(n)]
|
check := lcc[strconv.Itoa(n)]
|
||||||
oldIP := listener.IP
|
oldIP := listener.IP
|
||||||
oldPort := listener.Port
|
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:
|
// 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
|
// - 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)
|
mainLog.Warn().Msgf("could not listen on address: %s, trying 0.0.0.0:5354", addr)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if check.IP {
|
if check.IP && !isZeroIP { // for "0.0.0.0" or "::", we only need to try new port.
|
||||||
listener.IP = randomLocalIP()
|
listener.IP = randomLocalIP()
|
||||||
} else {
|
} else {
|
||||||
listener.IP = oldIP
|
listener.IP = oldIP
|
||||||
|
|||||||
Reference in New Issue
Block a user