fix: pure ip resolve

This commit is contained in:
Skyxim 2022-07-20 22:59:04 +08:00
parent 6e7002dbd3
commit e1c6142851

View File

@ -209,6 +209,11 @@ func ResolveAllIPWithResolver(host string, r Resolver) ([]netip.Addr, error) {
return []netip.Addr{node.Data}, nil return []netip.Addr{node.Data}, nil
} }
ip, err := netip.ParseAddr(host)
if err == nil {
return []netip.Addr{ip}, nil
}
if r != nil { if r != nil {
if DisableIPv6 { if DisableIPv6 {
return r.ResolveAllIPv4(host) return r.ResolveAllIPv4(host)
@ -219,11 +224,6 @@ func ResolveAllIPWithResolver(host string, r Resolver) ([]netip.Addr, error) {
return ResolveAllIPv4(host) return ResolveAllIPv4(host)
} }
ip, err := netip.ParseAddr(host)
if err == nil {
return []netip.Addr{ip}, nil
}
if DefaultResolver == nil { if DefaultResolver == nil {
ipAddr, err := net.ResolveIPAddr("ip", host) ipAddr, err := net.ResolveIPAddr("ip", host)
if err != nil { if err != nil {
@ -241,6 +241,11 @@ func ResolveAllIPPrimaryIPv4WithResolver(host string, r Resolver) ([]netip.Addr,
return []netip.Addr{node.Data}, nil return []netip.Addr{node.Data}, nil
} }
ip, err := netip.ParseAddr(host)
if err == nil {
return []netip.Addr{ip}, nil
}
if r != nil { if r != nil {
if DisableIPv6 { if DisableIPv6 {
return r.ResolveAllIPv4(host) return r.ResolveAllIPv4(host)
@ -251,11 +256,6 @@ func ResolveAllIPPrimaryIPv4WithResolver(host string, r Resolver) ([]netip.Addr,
return ResolveAllIPv4(host) return ResolveAllIPv4(host)
} }
ip, err := netip.ParseAddr(host)
if err == nil {
return []netip.Addr{ip}, nil
}
if DefaultResolver == nil { if DefaultResolver == nil {
ipAddr, err := net.ResolveIPAddr("ip", host) ipAddr, err := net.ResolveIPAddr("ip", host)
if err != nil { if err != nil {