mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 14:33:52 +00:00
commit
923f0ba54e
1 changed files with 14 additions and 2 deletions
|
|
@ -172,8 +172,20 @@ func ParseForAddEnr(validSchemes enr.IdentityScheme, input string) (*Node, error
|
||||||
var ip6 netip.Addr
|
var ip6 netip.Addr
|
||||||
n.Load((*enr.IPv4Addr)(&ip4))
|
n.Load((*enr.IPv4Addr)(&ip4))
|
||||||
n.Load((*enr.IPv6Addr)(&ip6))
|
n.Load((*enr.IPv6Addr)(&ip6))
|
||||||
n.setIP4(ip4)
|
valid4 := ip4.IsValid()
|
||||||
n.setIP6(ip6)
|
valid6 := ip6.IsValid()
|
||||||
|
switch {
|
||||||
|
case valid4 && valid6:
|
||||||
|
if localityScore(ip4) >= localityScore(ip6) {
|
||||||
|
n.setIP4(ip4)
|
||||||
|
} else {
|
||||||
|
n.setIP6(ip6)
|
||||||
|
}
|
||||||
|
case valid4:
|
||||||
|
n.setIP4(ip4)
|
||||||
|
case valid6:
|
||||||
|
n.setIP6(ip6)
|
||||||
|
}
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue