|
|
|
@ -21,7 +21,18 @@ func (*Client) Close() error { return nil }
|
|
|
|
|
|
|
|
|
|
// LookupIP implements Client.
|
|
|
|
|
func (*Client) LookupIP(host string) ([]net.IP, error) {
|
|
|
|
|
return net.LookupIP(host)
|
|
|
|
|
ips, err := net.LookupIP(host)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
parsedIPs := make([]net.IP, 0, len(ips))
|
|
|
|
|
for _, ip := range parsedIPs {
|
|
|
|
|
parsed := net.IPAddress(ip)
|
|
|
|
|
if parsed != nil {
|
|
|
|
|
parsedIPs = append(parsedIPs, parsed.IP())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return parsedIPs, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LookupIPv4 implements IPv4Lookup.
|
|
|
|
@ -30,11 +41,10 @@ func (c *Client) LookupIPv4(host string) ([]net.IP, error) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
var ipv4 []net.IP
|
|
|
|
|
ipv4 := make([]net.IP, 0, len(ips))
|
|
|
|
|
for _, ip := range ips {
|
|
|
|
|
parsed := net.IPAddress(ip)
|
|
|
|
|
if parsed.Family().IsIPv4() {
|
|
|
|
|
ipv4 = append(ipv4, parsed.IP())
|
|
|
|
|
if len(ip) == net.IPv4len {
|
|
|
|
|
ipv4 = append(ipv4, ip)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ipv4, nil
|
|
|
|
@ -46,11 +56,10 @@ func (c *Client) LookupIPv6(host string) ([]net.IP, error) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
var ipv6 []net.IP
|
|
|
|
|
ipv6 := make([]net.IP, 0, len(ips))
|
|
|
|
|
for _, ip := range ips {
|
|
|
|
|
parsed := net.IPAddress(ip)
|
|
|
|
|
if parsed.Family().IsIPv6() {
|
|
|
|
|
ipv6 = append(ipv6, parsed.IP())
|
|
|
|
|
if len(ip) == net.IPv6len {
|
|
|
|
|
ipv6 = append(ipv6, ip)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ipv6, nil
|
|
|
|
|