forked from TrueCloudLab/neoneo-go
network: prevent putting duplicate addresses into pool from peer's data
It can't be trusted.
This commit is contained in:
parent
d0634a7829
commit
fa4380c9da
1 changed files with 3 additions and 1 deletions
|
@ -916,9 +916,11 @@ func (s *Server) handleAddrCmd(p Peer, addrs *payload.AddressList) error {
|
||||||
if !p.CanProcessAddr() {
|
if !p.CanProcessAddr() {
|
||||||
return errors.New("unexpected addr received")
|
return errors.New("unexpected addr received")
|
||||||
}
|
}
|
||||||
|
dups := make(map[string]bool)
|
||||||
for _, a := range addrs.Addrs {
|
for _, a := range addrs.Addrs {
|
||||||
addr, err := a.GetTCPAddress()
|
addr, err := a.GetTCPAddress()
|
||||||
if err == nil {
|
if err == nil && !dups[addr] {
|
||||||
|
dups[addr] = true
|
||||||
s.discovery.BackFill(addr)
|
s.discovery.BackFill(addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue