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 <jakob@kastelo.net>
This commit is contained in:
Jakob Borg
2026-05-23 06:37:48 +00:00
committed by GitHub
parent 5464970c5d
commit 6322091462
2 changed files with 5 additions and 4 deletions
+5 -3
View File
@@ -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...)