From e65a71b2ae1405e784e5c3979fedb2e9d5fe1e20 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Fri, 14 Jul 2023 00:06:25 +0000 Subject: [PATCH] cmd/ctrld: do not try random local ip if IP is v4/v6 zero --- cmd/ctrld/cli.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/ctrld/cli.go b/cmd/ctrld/cli.go index 6876fc2..8a362f7 100644 --- a/cmd/ctrld/cli.go +++ b/cmd/ctrld/cli.go @@ -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