network: prevent putting duplicate addresses into pool from peer's data

It can't be trusted.
This commit is contained in:
Roman Khimov 2021-03-26 12:31:07 +03:00
parent d0634a7829
commit fa4380c9da

View file

@ -916,9 +916,11 @@ func (s *Server) handleAddrCmd(p Peer, addrs *payload.AddressList) error {
if !p.CanProcessAddr() {
return errors.New("unexpected addr received")
}
dups := make(map[string]bool)
for _, a := range addrs.Addrs {
addr, err := a.GetTCPAddress()
if err == nil {
if err == nil && !dups[addr] {
dups[addr] = true
s.discovery.BackFill(addr)
}
}