swarm/network: Add error log on invalid enode in uaddr

This commit is contained in:
lash 2019-03-01 13:54:40 +01:00
parent e489d77d4b
commit a4df8a56a7

View file

@ -225,10 +225,12 @@ func (b *Bzz) performHandshake(p *protocols.Peer, handshake *HandshakeMsg) error
// it modifies the passed bzzaddr in place, and returns the same pointer // it modifies the passed bzzaddr in place, and returns the same pointer
func sanitizeEnodeRemote(paddr *enode.Node, baddr *BzzAddr) { func sanitizeEnodeRemote(paddr *enode.Node, baddr *BzzAddr) {
enod, err := enode.ParseV4(string(baddr.UAddr)) enod, err := enode.ParseV4(string(baddr.UAddr))
if err == nil { if err != nil {
if enod.IP().IsLoopback() { log.Error("invalid bzz address", "addr", baddr)
baddr.UAddr = []byte(paddr.String()) return
} }
if enod.IP().IsLoopback() {
baddr.UAddr = []byte(paddr.String())
} }
} }