p2p: use proper comparison in URLv4 generation

This commit is contained in:
Lucas Vasconcelos 2024-12-04 15:27:53 +01:00
parent da4e59d392
commit ca438bd2e2

View file

@ -207,7 +207,7 @@ func (n *Node) URLv4() string {
nodeid = fmt.Sprintf("%s.%x", scheme, n.id[:])
}
u := url.URL{Scheme: "enode"}
if n.NeedResolve() {
if n.Hostname() != "" {
// For DNS nodes: include DNS name, TCP port, and optional UDP port
u.User = url.User(nodeid)
u.Host = fmt.Sprintf("%s:%d", n.Hostname(), n.TCP())