diff options
| author | bitflash-maintainer <noreply@bitflash.invalid> | 2026-08-26 22:44:31 +0000 |
|---|---|---|
| committer | bitflash-maintainer <noreply@bitflash.invalid> | 2026-08-26 22:44:31 +0000 |
| commit | 9b0535312a77a97b06837bbef51c1fe4b7f3b0da (patch) | |
| tree | 09eaa472699c1f2320f618697a1613e74517cc6a | |
| parent | 3fe9280fc11bc4ceaff3bb21533224b7b3e88da7 (diff) | |
net: bind INADDR_ANY only when this node advertises an onion endpoint
Upstream 1.2.19 made the P2P listener wildcard-bind unconditionally because
managed Tor forwards hidden-service traffic to 127.0.0.1, which a LAN-only
bind cannot receive. That also widened every non-Tor node to listen on VPN
tunnels, docker bridges and secondary NICs. The onion endpoint is always
configured (or the managed-Tor hidden service established) before StartNode,
so the predicate is ready when the bind happens.
| -rw-r--r-- | src/net.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/net.cpp b/src/net.cpp index 35baf21..fed6123 100644 --- a/src/net.cpp +++ b/src/net.cpp | |||
| @@ -2038,11 +2038,14 @@ bool StartNode(string& strError) | |||
| 2038 | // IP address, and port for the socket that is being bound | 2038 | // IP address, and port for the socket that is being bound |
| 2039 | int nRetryLimit = 15; | 2039 | int nRetryLimit = 15; |
| 2040 | struct sockaddr_in sockaddr = addrLocalHost.GetSockAddr(); | 2040 | struct sockaddr_in sockaddr = addrLocalHost.GetSockAddr(); |
| 2041 | // Keep addrLocalHost as this node's advertised address, but listen on all | 2041 | // Managed Tor forwards hidden-service traffic to 127.0.0.1:<port>, which a |
| 2042 | // local interfaces. Managed Tor forwards hidden-service traffic to | 2042 | // LAN-only bind cannot receive -- so a node that advertises an onion |
| 2043 | // 127.0.0.1:<port>, and binding only to the LAN address made that onion | 2043 | // endpoint must listen on all local interfaces. Upstream 1.2.19 bound |
| 2044 | // endpoint unreachable even though the P2P listener was running. | 2044 | // INADDR_ANY unconditionally, which also widened the P2P listener of every |
| 2045 | sockaddr.sin_addr.s_addr = INADDR_ANY; | 2045 | // non-Tor node to VPN tunnels, docker bridges and secondary NICs. Keep the |
| 2046 | // wildcard bind conditional on actually having an onion endpoint. | ||
| 2047 | if (!BtfLocalOnionEndpoint().empty()) | ||
| 2048 | sockaddr.sin_addr.s_addr = INADDR_ANY; | ||
| 2046 | if (bind(hListenSocket, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) == SOCKET_ERROR) | 2049 | if (bind(hListenSocket, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) == SOCKET_ERROR) |
| 2047 | { | 2050 | { |
| 2048 | int nErr = WSAGetLastError(); | 2051 | int nErr = WSAGetLastError(); |