Skip to content

Commit 7c6f1ab

Browse files
committed
Merge bitcoin/bitcoin#35032: net_processing: don't modify addrman for private broadcast connections
1ed1a12 net_processing: don't modify addrman for private broadcast connections (Vasil Dimov) Pull request description: It is best if the internal addrman database is not modified with information coming from private broadcast connections because that information can potentially later be sent via other connections. instagibbs suggested this change, thank you! ACKs for top commit: l0rinc: code review ACK 1ed1a12 instagibbs: ACK 1ed1a12 achow101: ACK 1ed1a12 andrewtoth: ACK 1ed1a12 danielabrozzoni: tACK 1ed1a12 Tree-SHA512: 13845778445e56e3015a569f3b4165a749011e9dd67dcab38e960a368a0f5d3822173af5e3cb950998326549a021d1c8df644ce6d761cd46dd7597106b9ceec9
2 parents 94f1d35 + 1ed1a12 commit 7c6f1ab

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3600,7 +3600,7 @@ void PeerManagerImpl::ProcessMessage(Peer& peer, CNode& pfrom, const std::string
36003600
}
36013601
vRecv.ignore(8); // Ignore the addrMe service bits sent by the peer
36023602
vRecv >> CNetAddr::V1(addrMe);
3603-
if (!pfrom.IsInboundConn())
3603+
if (!pfrom.IsInboundConn() && !pfrom.IsPrivateBroadcastConn())
36043604
{
36053605
// Overwrites potentially existing services. In contrast to this,
36063606
// unvalidated services received via gossip relay in ADDR/ADDRV2

src/test/net_tests.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#include <addrman.h>
56
#include <chainparams.h>
67
#include <clientversion.h>
78
#include <common/args.h>
@@ -1559,4 +1560,34 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
15591560
}
15601561
}
15611562

1563+
BOOST_AUTO_TEST_CASE(private_broadcast_version_does_not_update_addrman_services)
1564+
{
1565+
LOCK(NetEventsInterface::g_msgproc_mutex);
1566+
1567+
const CNetAddr source{LookupHost("2.3.4.5", /*fAllowLookup=*/false).value()};
1568+
const CAddress addr{Lookup("1.2.3.4", 8333, /*fAllowLookup=*/false).value(), NODE_NONE};
1569+
BOOST_REQUIRE(m_node.addrman->Add({addr}, source));
1570+
CNode node{/*id=*/0,
1571+
/*sock=*/nullptr,
1572+
/*addrIn=*/addr,
1573+
/*nKeyedNetGroupIn=*/0,
1574+
/*nLocalHostNonceIn=*/0,
1575+
/*addrBindIn=*/CService{},
1576+
/*addrNameIn=*/"",
1577+
/*conn_type_in=*/ConnectionType::PRIVATE_BROADCAST,
1578+
/*inbound_onion=*/false,
1579+
/*network_key=*/0};
1580+
1581+
auto& connman = static_cast<ConnmanTestMsg&>(*m_node.connman);
1582+
connman.Handshake(node,
1583+
/*successfully_connected=*/false,
1584+
/*remote_services=*/NODE_NETWORK,
1585+
/*local_services=*/NODE_NONE,
1586+
/*version=*/PROTOCOL_VERSION,
1587+
/*relay_txs=*/true);
1588+
1589+
BOOST_CHECK_EQUAL(m_node.addrman->Select().first.nServices, NODE_NONE);
1590+
m_node.peerman->FinalizeNode(node);
1591+
}
1592+
15621593
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)