Skip to content

Commit

Permalink
server: Only respond to getaddr once per conn.
Browse files Browse the repository at this point in the history
This modifies the OnGetAddr handler to prevent the server from
responding to getaddr messages more than once per connection which helps
reduce unhelpful traffic and fingerprinting attacks.
  • Loading branch information
davecgh committed Jun 4, 2018
1 parent b730f98 commit 5f3a150
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ type serverPeer struct {
banScore connmgr.DynamicBanScore
quit chan struct{}

// addrsSent tracks whether or not the peer has responded to a getaddr
// request. It is used to prevent more than one response per connection.
addrsSent bool

// The following chans are used to sync blockmanager and server.
txProcessed chan struct{}
blockProcessed chan struct{}
Expand Down Expand Up @@ -1015,6 +1019,14 @@ func (sp *serverPeer) OnGetAddr(p *peer.Peer, msg *wire.MsgGetAddr) {
return
}

// Only respond with addresses once per connection. This helps reduce
// traffic and further reduces fingerprinting attacks.
if sp.addrsSent {
peerLog.Tracef("Ignoring getaddr from %v - already sent", sp.Peer)
return
}
sp.addrsSent = true

// Get the current known addresses from the address manager.
addrCache := sp.server.addrManager.AddressCache()

Expand Down

0 comments on commit 5f3a150

Please sign in to comment.