]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Don't dial out TCP from the listen port
authorMatt Joiner <anacrolix@gmail.com>
Sat, 29 Apr 2023 04:53:03 +0000 (14:53 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 9 May 2023 05:45:52 +0000 (15:45 +1000)
socket.go

index 22809e1741fca097508874ffe9b92fadd16c55df..c1fb97fdbcbee17728d530da76a9fe5a6f5ab094 100644 (file)
--- 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.