From 68209a7b5c0326e14508d9cf749771605bd6ffe7 Mon Sep 17 00:00:00 2001 From: Martin Zumsande Date: Thu, 1 Sep 2022 18:26:55 -0400 Subject: [PATCH] rpc: make addpeeraddress work with cjdns addresses This allows us to add cjdns addresses to addrman for testing and debug purposes (if -cjdnsreachable is true) --- src/net.h | 1 + src/rpc/net.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/net.h b/src/net.h index 66a228b3ec8..044701a339d 100644 --- a/src/net.h +++ b/src/net.h @@ -164,6 +164,7 @@ bool SeenLocal(const CService& addr); bool IsLocal(const CService& addr); bool GetLocal(CService &addr, const CNetAddr *paddrPeer = nullptr); CService GetLocalAddress(const CNetAddr& addrPeer); +CService MaybeFlipIPv6toCJDNS(const CService& service); extern bool fDiscover; diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index e221b3462d0..d701a180abd 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -947,7 +947,8 @@ static RPCHelpMan addpeeraddress() bool success{false}; if (LookupHost(addr_string, net_addr, false)) { - CAddress address{{net_addr, port}, ServiceFlags{NODE_NETWORK | NODE_WITNESS}}; + CService service{net_addr, port}; + CAddress address{MaybeFlipIPv6toCJDNS(service), ServiceFlags{NODE_NETWORK | NODE_WITNESS}}; address.nTime = Now(); // The source address is set equal to the address. This is equivalent to the peer // announcing itself.