btcd: only allow one getaddr request per peer
This commit is contained in:
parent
e8b9147ba2
commit
9bedd7720c
1 changed files with 12 additions and 0 deletions
12
server.go
12
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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue