Merge bitcoin/bitcoin#34458: net: Don't log own ips during discover

a49f97ff4a net: Don't log own ips during discover (sedited)

Pull request description:

  The -logips option seems to imply that ip addresses are only logged when it is set. This seems like an obvious case for not logging these by default. There might be prior discussion around this, but I was unable to find why these might be exempt. There are also a few issues (both open and closed) where printing these lines was useful.

ACKs for top commit:
  l0rinc:
    tested ACK a49f97ff4a
  achow101:
    ACK a49f97ff4a
  willcl-ark:
    tACK a49f97ff4a
  danielabrozzoni:
    tACK a49f97ff4a

Tree-SHA512: 177911c5607b794965facf568fec71eb22fc8e9d16f4fee5088745e8aba51cb4ce839876c456470dc52839ebc36976dc6b81a50f546941aebb8db538d8fd4554
This commit is contained in:
Ava Chow
2026-03-26 11:27:06 -07:00

View File

@@ -287,7 +287,9 @@ bool AddLocal(const CService& addr_, int nScore)
if (!g_reachable_nets.Contains(addr))
return false;
LogInfo("AddLocal(%s,%i)\n", addr.ToStringAddrPort(), nScore);
if (fLogIPs) {
LogInfo("AddLocal(%s,%i)\n", addr.ToStringAddrPort(), nScore);
}
{
LOCK(g_maplocalhost_mutex);
@@ -310,7 +312,10 @@ bool AddLocal(const CNetAddr &addr, int nScore)
void RemoveLocal(const CService& addr)
{
LOCK(g_maplocalhost_mutex);
LogInfo("RemoveLocal(%s)\n", addr.ToStringAddrPort());
if (fLogIPs) {
LogInfo("RemoveLocal(%s)\n", addr.ToStringAddrPort());
}
mapLocalHost.erase(addr);
}
@@ -3349,8 +3354,9 @@ void Discover()
return;
for (const CNetAddr &addr: GetLocalAddresses()) {
if (AddLocal(addr, LOCAL_IF))
if (AddLocal(addr, LOCAL_IF) && fLogIPs) {
LogInfo("%s: %s\n", __func__, addr.ToStringAddr());
}
}
}