Skip to content

Commit dd42a5d

Browse files
committed
Merge bitcoin/bitcoin#30085: p2p: detect addnode cjdns peers in GetAddedNodeInfo()
d0b0474 test: add GetAddedNodeInfo() CJDNS regression unit test (Jon Atack) 684da97 p2p, bugfix: detect addnode cjdns peers in GetAddedNodeInfo() (Jon Atack) Pull request description: Addnode peers connected to us via the cjdns network are currently not detected by `CConnman::GetAddedNodeInfo()`, i.e. `fConnected` is always false. This causes the following issues: - RPC `getaddednodeinfo` incorrectly shows them as not connected - `CConnman::ThreadOpenAddedConnections()` continually retries to connect them Fix the issue and add a unit regression test. Extracted from #28248. Suggest running the test with: `./src/test/test_bitcoin -t net_peer_connection_tests -l test_suite` ACKs for top commit: mzumsande: utACK d0b0474 brunoerg: crACK d0b0474 pinheadmz: ACK d0b0474 Tree-SHA512: a4d81425f79558f5792585611f3fe8ab999b82144daeed5c3ec619861c69add934c2b2afdad24c8488a0ade94f5ce8112f5555d60a1ce913d4f5a1cf5dbba55a
2 parents ae2658c + d0b0474 commit dd42a5d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2831,7 +2831,7 @@ std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo(bool include_connected) co
28312831
}
28322832

28332833
for (const auto& addr : lAddresses) {
2834-
CService service(LookupNumeric(addr.m_added_node, GetDefaultPort(addr.m_added_node)));
2834+
CService service{MaybeFlipIPv6toCJDNS(LookupNumeric(addr.m_added_node, GetDefaultPort(addr.m_added_node)))};
28352835
AddedNodeInfo addedNode{addr, CService(), false, false};
28362836
if (service.IsValid()) {
28372837
// strAddNode is an IP:port

src/test/net_peer_connection_tests.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ BOOST_AUTO_TEST_CASE(test_addnode_getaddednodeinfo_and_connection_detection)
108108
AddPeer(id, nodes, *peerman, *connman, ConnectionType::BLOCK_RELAY, /*onion_peer=*/true);
109109
AddPeer(id, nodes, *peerman, *connman, ConnectionType::INBOUND);
110110

111+
// Add a CJDNS peer connection.
112+
AddPeer(id, nodes, *peerman, *connman, ConnectionType::INBOUND, /*onion_peer=*/false,
113+
/*address=*/"[fc00:3344:5566:7788:9900:aabb:ccdd:eeff]:1234");
114+
BOOST_CHECK(nodes.back()->IsInboundConn());
115+
BOOST_CHECK_EQUAL(nodes.back()->ConnectedThroughNetwork(), Network::NET_CJDNS);
116+
111117
BOOST_TEST_MESSAGE("Call AddNode() for all the peers");
112118
for (auto node : connman->TestNodes()) {
113119
BOOST_CHECK(connman->AddNode({/*m_added_node=*/node->addr.ToStringAddrPort(), /*m_use_v2transport=*/true}));

0 commit comments

Comments
 (0)