mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-31 10:41:08 +00:00
Merge bitcoin/bitcoin#34297: p2p: add validation checks for initial self-announcement
6a8dbf9b9352db48580cd81c8dac027f3138fedf p2p: add validation check for initial self-announcement (frankomosh)
Pull request description:
This is a follow up to #34146 . Adds validation check to the initial self-announcement code path. `IsAddrCompatible()` check can prevent sending non-routable addresses to peers that don't support addrv2.
ACKs for top commit:
fjahr:
utACK 6a8dbf9b9352db48580cd81c8dac027f3138fedf
Crypt-iQ:
crACK 6a8dbf9b9352db48580cd81c8dac027f3138fedf
stratospher:
ACK 6a8dbf9. preserves the existing behaviour. also learnt that Addr-fetch ADDR processing logic allows receiving a self-announcement with 1 address [without disconnecting](b6c5d1e450) and won't be affected.
sedited:
ACK 6a8dbf9b9352db48580cd81c8dac027f3138fedf
Tree-SHA512: 988110d72fd698634111eb68c0204f42457b9b9b3d7b6ca3e11815cc702f6921266ae8f27f27aa31c3672efdb99478870fc4d1e8f5fa63aceae6f81521b31d8b
This commit is contained in:
commit
9016858282
@ -5523,11 +5523,13 @@ void PeerManagerImpl::MaybeSendAddr(CNode& node, Peer& peer, std::chrono::micros
|
||||
// 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
|
||||
// message ends up containing multiple addresses.
|
||||
std::vector<CAddress> self_announcement {local_addr};
|
||||
if (peer.m_wants_addrv2) {
|
||||
MakeAndPushMessage(node, NetMsgType::ADDRV2, CAddress::V2_NETWORK(self_announcement));
|
||||
} else {
|
||||
MakeAndPushMessage(node, NetMsgType::ADDR, CAddress::V1_NETWORK(self_announcement));
|
||||
if (IsAddrCompatible(peer, local_addr)) {
|
||||
std::vector<CAddress> self_announcement{local_addr};
|
||||
if (peer.m_wants_addrv2) {
|
||||
MakeAndPushMessage(node, NetMsgType::ADDRV2, CAddress::V2_NETWORK(self_announcement));
|
||||
} else {
|
||||
MakeAndPushMessage(node, NetMsgType::ADDR, CAddress::V1_NETWORK(self_announcement));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// All later self-announcements are sent together with the other addresses.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user