Skip to content

Commit af3b0df

Browse files
committed
net: fix output of peer address in version message
If `-logips -debug=net` is specified then we print the contents of the version message we send to the peer, including his address. Because the addresses in the version message use pre-BIP155 encoding they cannot represent a Tor v3 address and we would actually send 16 `0`s instead (a dummy IPv6 address). However we would print the full address in the log message. Before this fix: ``` 2020-10-21T12:24:17Z send version message: version 70016, blocks=653500, us=[::]:0, them=xwjtp3mj427zdp4tljiiivg2l5ijfvmt5lcsfaygtpp6cw254kykvpyd.onion:8333, peer=0 ``` This is confusing because we pretend to send one thing while we actually send another. Adjust the printout to reflect what we are sending. After this fix: ``` 2020-10-21T12:26:54Z send version message: version 70016, blocks=653500, us=[::]:0, them=[::]:0, peer=0 ```
1 parent 0f86e7f commit af3b0df

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,9 @@ static void PushNodeVersion(CNode& pnode, CConnman& connman, int64_t nTime)
498498
NodeId nodeid = pnode.GetId();
499499
CAddress addr = pnode.addr;
500500

501-
CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService(), addr.nServices));
501+
CAddress addrYou = addr.IsRoutable() && !IsProxy(addr) && addr.IsAddrV1Compatible() ?
502+
addr :
503+
CAddress(CService(), addr.nServices);
502504
CAddress addrMe = CAddress(CService(), nLocalNodeServices);
503505

504506
connman.PushMessage(&pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::VERSION, PROTOCOL_VERSION, (uint64_t)nLocalNodeServices, nTime, addrYou, addrMe,

0 commit comments

Comments
 (0)