From 9bedd7720c1667e249c6735eb10e49d78ca4c723 Mon Sep 17 00:00:00 2001 From: David Hill Date: Sat, 19 Nov 2016 11:19:51 -0500 Subject: [PATCH] btcd: only allow one getaddr request per peer --- server.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server.go b/server.go index 1bed7e26..7ba594e1 100644 --- a/server.go +++ b/server.go @@ -213,6 +213,7 @@ type serverPeer struct { continueHash *chainhash.Hash relayMtx sync.Mutex disableRelayTx bool + sentAddrs bool requestQueue []*wire.InvVect requestedTxns map[chainhash.Hash]struct{} requestedBlocks map[chainhash.Hash]struct{} @@ -892,9 +893,20 @@ func (sp *serverPeer) OnGetAddr(_ *peer.Peer, msg *wire.MsgGetAddr) { // Do not accept getaddr requests from outbound peers. This reduces // fingerprinting attacks. if !sp.Inbound() { + peerLog.Debugf("Ignoring getaddr request from outbound peer ", + "%v", sp) return } + // Only allow one getaddr request per connection to discourage + // address stamping of inv announcements. + if sp.sentAddrs { + peerLog.Debugf("Ignoring repeated getaddr request from peer ", + "%v", sp) + return + } + sp.sentAddrs = true + // Get the current known addresses from the address manager. addrCache := sp.server.addrManager.AddressCache()