From a09d052f96f5dc19d014e2ee8243ca87520882b8 Mon Sep 17 00:00:00 2001 From: David Hill Date: Sun, 23 Oct 2016 13:44:34 -0400 Subject: [PATCH] peer: Stop setting AddrMe in the version message. Older nodes previously added the IP and port information to the address manager which proved to be unreliable as an inbound connection from a peer didn't necessarily mean the peer itself accepted inbound connections. This also fixes a bug where the peer package was incorrectly sending the peer's services as its own. --- peer/peer.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/peer/peer.go b/peer/peer.go index cfd0fd41d..158d853b0 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -784,11 +784,17 @@ func (p *Peer) localVersionMsg() (*wire.MsgVersion, error) { } } - // TODO(tuxcanfly): In case BestLocalAddress is nil, ourNA defaults to - // remote NA, which is wrong. Need to fix this. - ourNA := p.na - if p.cfg.BestLocalAddress != nil { - ourNA = p.cfg.BestLocalAddress(p.na) + // Create a wire.NetAddress with only the services set to use as the + // "addrme" in the version message. + // + // Older nodes previously added the IP and port information to the + // address manager which proved to be unreliable as an inbound + // connection from a peer didn't necessarily mean the peer itself + // accepted inbound connections. + // + // Also, the timestamp is unused in the version message. + ourNA := &wire.NetAddress{ + Services: p.cfg.Services, } // Generate a unique nonce for this peer so self connections can be