mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-04 09:02:28 +00:00
network: treat unsolicited addr commands as errors
See neo-project/neo#2097.
This commit is contained in:
parent
619b6d4132
commit
2ce3c8b75f
4 changed files with 41 additions and 0 deletions
|
@ -680,6 +680,9 @@ func (s *Server) handleTxCmd(tx *transaction.Transaction) error {
|
|||
|
||||
// handleAddrCmd will process received addresses.
|
||||
func (s *Server) handleAddrCmd(p Peer, addrs *payload.AddressList) error {
|
||||
if !p.CanProcessAddr() {
|
||||
return errors.New("unexpected addr received")
|
||||
}
|
||||
for _, a := range addrs.Addrs {
|
||||
addr, err := a.GetTCPAddress()
|
||||
if err == nil {
|
||||
|
@ -830,6 +833,9 @@ func (s *Server) iteratePeersWithSendMsg(msg *Message, send func(Peer, []byte) e
|
|||
if peerOK != nil && !peerOK(peer) {
|
||||
continue
|
||||
}
|
||||
if msg.Command == CMDGetAddr {
|
||||
peer.AddGetAddrSent()
|
||||
}
|
||||
// Who cares about these messages anyway?
|
||||
_ = send(peer, pkt)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue