|
|
|
@ -125,15 +125,17 @@ func parseComplete(rawurl string) (*Node, error) { |
|
|
|
|
return nil, fmt.Errorf("invalid public key (%v)", err) |
|
|
|
|
} |
|
|
|
|
// Parse the IP address.
|
|
|
|
|
host, port, err := net.SplitHostPort(u.Host) |
|
|
|
|
ips, err := net.LookupIP(u.Hostname()) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, fmt.Errorf("invalid host: %v", err) |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
if ip = net.ParseIP(host); ip == nil { |
|
|
|
|
return nil, errors.New("invalid IP address") |
|
|
|
|
ip = ips[0] |
|
|
|
|
// Ensure the IP is 4 bytes long for IPv4 addresses.
|
|
|
|
|
if ipv4 := ip.To4(); ipv4 != nil { |
|
|
|
|
ip = ipv4 |
|
|
|
|
} |
|
|
|
|
// Parse the port numbers.
|
|
|
|
|
if tcpPort, err = strconv.ParseUint(port, 10, 16); err != nil { |
|
|
|
|
if tcpPort, err = strconv.ParseUint(u.Port(), 10, 16); err != nil { |
|
|
|
|
return nil, errors.New("invalid port") |
|
|
|
|
} |
|
|
|
|
udpPort = tcpPort |
|
|
|
|