mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
p2p/enode: fix ipv6 address used as extip results in 127.0.0.1 being used
This commit is contained in:
parent
6154f87c33
commit
57164d4d8c
1 changed files with 18 additions and 11 deletions
|
|
@ -106,14 +106,21 @@ func (n *Node) IP() net.IP {
|
||||||
ip6 enr.IPv6
|
ip6 enr.IPv6
|
||||||
)
|
)
|
||||||
if n.Load(&ip4) == nil {
|
if n.Load(&ip4) == nil {
|
||||||
return net.IP(ip4)
|
ipv4Addr := net.IP(ip4)
|
||||||
|
if !ipv4Addr.IsLoopback() {
|
||||||
|
return ipv4Addr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if n.Load(&ip6) == nil {
|
if n.Load(&ip6) == nil {
|
||||||
return net.IP(ip6)
|
return net.IP(ip6)
|
||||||
}
|
}
|
||||||
|
if net.IP(ip4).IsLoopback() {
|
||||||
|
return net.IP(ip4)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// UDP returns the UDP port of the node.
|
// UDP returns the UDP port of the node.
|
||||||
func (n *Node) UDP() int {
|
func (n *Node) UDP() int {
|
||||||
var port enr.UDP
|
var port enr.UDP
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue