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)
This commit is contained in:
Martin Zumsande 2022-09-01 18:26:55 -04:00
parent a8a9ed67cc
commit 68209a7b5c
2 changed files with 3 additions and 1 deletions

View File

@ -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;

View File

@ -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<NodeSeconds>();
// The source address is set equal to the address. This is equivalent to the peer
// announcing itself.