Skip to content

Commit

Permalink
net: log connections failures via SOCKS5 with less severity
Browse files Browse the repository at this point in the history
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: #29759
  • Loading branch information
vasild committed May 8, 2024
1 parent 43a66c5 commit 7524aaf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/netbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -544,9 +545,9 @@ template<typename... Args>
static void LogConnectFailure(bool manual_connection, const char* fmt, const Args&... args) {
std::string error_message = tfm::format(fmt, args...);
if (manual_connection) {
LogPrintf("%s\n", error_message);
LogPrintLevel(BCLog::NET, BCLog::Level::Info, "%s\n", error_message);
} else {
LogPrint(BCLog::NET, "%s\n", error_message);
LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "%s\n", error_message);
}
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 7524aaf

Please sign in to comment.