mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-24 23:12:31 +00:00

* [NOD-386] Extract net parsing functionality to a shared place. * [NOD-386] Add extract ActiveNetParams to cmdconfig * [NOD-386] Adding comments so go-vet won't shout at me * [NOD-386] Rename package name to config * [NOD-386] Rename commandConfig to configFlags * [NOD-386] Rename function to ResolveNetwork * [NOD-386] Fix renaming errors * [NOD-386] Refactor network config to btcd level so APIserver and btcd could use it * [NOD-386] Refactor network config to config package * [NOD-386] Move ActiveNetParams to network section * [NOD-386] Explictly return nil * [NOD-386] Reuse activeNetParams from netwrok config * [NOD-386] Set ActiveNetworkFlags instance to be global * [NOD-386] Remove redundant newline * [NOD-386] Init ActiveNetParams in address manager test * [NOD-386] Add dnsseeder network config * [NOD-386] Use ActiveConfig() method to access configuration
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package p2p
|
|
|
|
import (
|
|
"github.com/daglabs/btcd/config"
|
|
"github.com/daglabs/btcd/peer"
|
|
"github.com/daglabs/btcd/wire"
|
|
)
|
|
|
|
// OnGetAddr is invoked when a peer receives a getaddr bitcoin message
|
|
// and is used to provide the peer with known addresses from the address
|
|
// manager.
|
|
func (sp *Peer) OnGetAddr(_ *peer.Peer, msg *wire.MsgGetAddr) {
|
|
// Don't return any addresses when running on the simulation test
|
|
// network. This helps prevent the network from becoming another
|
|
// public test network since it will not be able to learn about other
|
|
// peers that have not specifically been provided.
|
|
if config.ActiveConfig().SimNet {
|
|
return
|
|
}
|
|
|
|
// Do not accept getaddr requests from outbound peers. This reduces
|
|
// fingerprinting attacks.
|
|
if !sp.Inbound() {
|
|
peerLog.Debugf("Ignoring getaddr request from outbound peer ",
|
|
"%s", 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 ",
|
|
"%s", sp)
|
|
return
|
|
}
|
|
sp.sentAddrs = true
|
|
|
|
// Get the current known addresses from the address manager.
|
|
addrCache := sp.server.addrManager.AddressCache(msg.IncludeAllSubnetworks, msg.SubnetworkID)
|
|
|
|
// Push the addresses.
|
|
sp.pushAddrMsg(addrCache, sp.SubnetworkID())
|
|
}
|