mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-14 00:30:17 +02:00
net_processing: don't modify addrman for private broadcast connections
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.
Co-authored-by: Greg Sanders <gsanders87@gmail.com>
Co-authored-by: Lőrinc <pap.lorinc@gmail.com>
Github-Pull: #35032
Rebased-From: 1ed1a12402
This commit is contained in:
@@ -3603,7 +3603,7 @@ void PeerManagerImpl::ProcessMessage(Peer& peer, CNode& pfrom, const std::string
|
||||
}
|
||||
vRecv.ignore(8); // Ignore the addrMe service bits sent by the peer
|
||||
vRecv >> CNetAddr::V1(addrMe);
|
||||
if (!pfrom.IsInboundConn())
|
||||
if (!pfrom.IsInboundConn() && !pfrom.IsPrivateBroadcastConn())
|
||||
{
|
||||
// Overwrites potentially existing services. In contrast to this,
|
||||
// unvalidated services received via gossip relay in ADDR/ADDRV2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <addrman.h>
|
||||
#include <chainparams.h>
|
||||
#include <clientversion.h>
|
||||
#include <common/args.h>
|
||||
@@ -1559,4 +1560,34 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(private_broadcast_version_does_not_update_addrman_services)
|
||||
{
|
||||
LOCK(NetEventsInterface::g_msgproc_mutex);
|
||||
|
||||
const CNetAddr source{LookupHost("2.3.4.5", /*fAllowLookup=*/false).value()};
|
||||
const CAddress addr{Lookup("1.2.3.4", 8333, /*fAllowLookup=*/false).value(), NODE_NONE};
|
||||
BOOST_REQUIRE(m_node.addrman->Add({addr}, source));
|
||||
CNode node{/*id=*/0,
|
||||
/*sock=*/nullptr,
|
||||
/*addrIn=*/addr,
|
||||
/*nKeyedNetGroupIn=*/0,
|
||||
/*nLocalHostNonceIn=*/0,
|
||||
/*addrBindIn=*/CService{},
|
||||
/*addrNameIn=*/"",
|
||||
/*conn_type_in=*/ConnectionType::PRIVATE_BROADCAST,
|
||||
/*inbound_onion=*/false,
|
||||
/*network_key=*/0};
|
||||
|
||||
auto& connman = static_cast<ConnmanTestMsg&>(*m_node.connman);
|
||||
connman.Handshake(node,
|
||||
/*successfully_connected=*/false,
|
||||
/*remote_services=*/NODE_NETWORK,
|
||||
/*local_services=*/NODE_NONE,
|
||||
/*version=*/PROTOCOL_VERSION,
|
||||
/*relay_txs=*/true);
|
||||
|
||||
BOOST_CHECK_EQUAL(m_node.addrman->Select().first.nServices, NODE_NONE);
|
||||
m_node.peerman->FinalizeNode(node);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user