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:
@@ -13,6 +13,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -185,9 +186,10 @@ func (t *tcpListener) WANAddresses() []*url.URL {
|
|||||||
|
|
||||||
t.mut.RUnlock()
|
t.mut.RUnlock()
|
||||||
|
|
||||||
// If we support ReusePort, add an unspecified zero port address, which will be resolved by the discovery server
|
// If we support ReusePort, and we are already announcing an unspecified
|
||||||
// in hopes that TCP punch through works.
|
// address, add an unspecified zero port address, which will be resolved
|
||||||
if dialer.SupportsReusePort {
|
// 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 := *t.uri
|
||||||
uri.Host = "0.0.0.0:0"
|
uri.Host = "0.0.0.0:0"
|
||||||
uris = append([]*url.URL{&uri}, uris...)
|
uris = append([]*url.URL{&uri}, uris...)
|
||||||
|
|||||||
@@ -289,7 +289,6 @@ func (c *globalClient) sendAnnouncement(ctx context.Context, timer *time.Timer)
|
|||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||||
slog.DebugContext(ctx, "announce POST", "server", c.server, "status", resp.Status)
|
|
||||||
c.setError(errors.New(resp.Status))
|
c.setError(errors.New(resp.Status))
|
||||||
|
|
||||||
if h := resp.Header.Get("Retry-After"); h != "" {
|
if h := resp.Header.Get("Retry-After"); h != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user