From 6322091462f662ab25e7ff3f7255d679dfb2550e Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sat, 23 May 2026 08:37:48 +0200 Subject: [PATCH] fix(discover): only announce wildcard for TCP punching when listening on wildcard address (fixes #10503) (#10691) If we aren't announcing e.g. tcp://0.0.0.0:22000 then also do not announce tcp://0.0.0.0:0. Signed-off-by: Jakob Borg --- lib/connections/tcp_listen.go | 8 +++++--- lib/discover/global.go | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/connections/tcp_listen.go b/lib/connections/tcp_listen.go index dfdf4ff2e..91908d08d 100644 --- a/lib/connections/tcp_listen.go +++ b/lib/connections/tcp_listen.go @@ -13,6 +13,7 @@ import ( "log/slog" "net" "net/url" + "slices" "sync" "time" @@ -185,9 +186,10 @@ func (t *tcpListener) WANAddresses() []*url.URL { t.mut.RUnlock() - // If we support ReusePort, add an unspecified zero port address, which will be resolved by the discovery server - // in hopes that TCP punch through works. - if dialer.SupportsReusePort { + // If we support ReusePort, and we are already announcing an unspecified + // address, add an unspecified zero port address, which will be resolved + // by the discovery server in hopes that TCP punch through works. + if dialer.SupportsReusePort && slices.ContainsFunc(uris, func(u *url.URL) bool { return u.Hostname() == "0.0.0.0" }) { uri := *t.uri uri.Host = "0.0.0.0:0" uris = append([]*url.URL{&uri}, uris...) diff --git a/lib/discover/global.go b/lib/discover/global.go index 850e38aa2..be70e1775 100644 --- a/lib/discover/global.go +++ b/lib/discover/global.go @@ -289,7 +289,6 @@ func (c *globalClient) sendAnnouncement(ctx context.Context, timer *time.Timer) resp.Body.Close() if resp.StatusCode < 200 || resp.StatusCode > 299 { - slog.DebugContext(ctx, "announce POST", "server", c.server, "status", resp.Status) c.setError(errors.New(resp.Status)) if h := resp.Header.Get("Retry-After"); h != "" {