From: Matt Joiner Date: Sat, 29 Apr 2023 04:53:03 +0000 (+1000) Subject: Don't dial out TCP from the listen port X-Git-Tag: v1.51.0~30 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=9624f6ff9ce2261a3f4b4bff25cea69b0c541a5f;p=btrtrc.git Don't dial out TCP from the listen port --- diff --git a/socket.go b/socket.go index 22809e17..c1fb97fd 100644 --- a/socket.go +++ b/socket.go @@ -59,11 +59,10 @@ func listenTcp(network, address string) (s socket, err error) { NetworkDialer: NetworkDialer{ Network: network, Dialer: &net.Dialer{ - // My hope is that dialling out from a consistent port will improve the - // hole-punching behaviour. It might also prevent duplicate connections to the same - // peer if the peer does the same thing. There should probably be a fallback dialer - // if we fail to configure the socket to reuse ports for whatever reason. - LocalAddr: l.Addr(), + // Dialling TCP from a local port limits us to a single outgoing TCP connection to + // each remote client. Instead this should be a last resort if we need to use holepunching, and only then to connect to other clients that actually try to holepunch TCP. + //LocalAddr: l.Addr(), + // We don't want fallback, as we explicitly manage the IPv4/IPv6 distinction // ourselves, although it's probably not triggered as I think the network is already // constrained to tcp4 or tcp6 at this point.