p2p: add validation check for initial self-announcement

The direct send path for the initial self-announcement was bypassing
IsAddrCompatible() check that PushAddress() performs
This commit is contained in:
frankomosh
2026-01-15 11:17:18 +03:00
parent 9d2b8fddad
commit 6a8dbf9b93

View File

@@ -5521,11 +5521,13 @@ void PeerManagerImpl::MaybeSendAddr(CNode& node, Peer& peer, std::chrono::micros
// Send the initial self-announcement in its own message. This makes sure // Send the initial self-announcement in its own message. This makes sure
// rate-limiting with limited start-tokens doesn't ignore it if the first // rate-limiting with limited start-tokens doesn't ignore it if the first
// message ends up containing multiple addresses. // message ends up containing multiple addresses.
std::vector<CAddress> self_announcement {local_addr}; if (IsAddrCompatible(peer, local_addr)) {
if (peer.m_wants_addrv2) { std::vector<CAddress> self_announcement{local_addr};
MakeAndPushMessage(node, NetMsgType::ADDRV2, CAddress::V2_NETWORK(self_announcement)); if (peer.m_wants_addrv2) {
} else { MakeAndPushMessage(node, NetMsgType::ADDRV2, CAddress::V2_NETWORK(self_announcement));
MakeAndPushMessage(node, NetMsgType::ADDR, CAddress::V1_NETWORK(self_announcement)); } else {
MakeAndPushMessage(node, NetMsgType::ADDR, CAddress::V1_NETWORK(self_announcement));
}
} }
} else { } else {
// All later self-announcements are sent together with the other addresses. // All later self-announcements are sent together with the other addresses.