net: log connections failures via SOCKS5 with less severity

It is expected to have some Bitcoin nodes unreachable some of the time.
A failure to connect to an IPv4 or IPv6 node is already properly logged
under category=net/severity=debug. Do the same when a connection fails
when using a SOCKS5 proxy. This could be either to an .onion address or
to an IPv4 or IPv6 address (via a Tor exit node).

Related: https://github.com/bitcoin/bitcoin/issues/29759
This commit is contained in:
Vasil Dimov 2024-05-08 16:42:00 +02:00
parent 43a66c55ec
commit f3cfbd65f5
No known key found for this signature in database
GPG key ID: 54DF06F64B55CBBF

View file

@ -443,7 +443,8 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
}
if (pchRet2[1] != SOCKS5Reply::SUCCEEDED) {
// Failures to connect to a peer that are not proxy errors
LogPrintf("Socks5() connect to %s:%d failed: %s\n", strDest, port, Socks5ErrorString(pchRet2[1]));
LogPrintLevel(BCLog::NET, BCLog::Level::Debug,
"Socks5() connect to %s:%d failed: %s\n", strDest, port, Socks5ErrorString(pchRet2[1]));
return false;
}
if (pchRet2[2] != 0x00) { // Reserved field must be 0
@ -569,7 +570,7 @@ static bool ConnectToSocket(const Sock& sock, struct sockaddr* sockaddr, socklen
NetworkErrorString(WSAGetLastError()));
return false;
} else if (occurred == 0) {
LogPrint(BCLog::NET, "connection attempt to %s timed out\n", dest_str);
LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "connection attempt to %s timed out\n", dest_str);
return false;
}