From e1c61428516af80aea98255cfad5389a77e50398 Mon Sep 17 00:00:00 2001 From: Skyxim Date: Wed, 20 Jul 2022 22:59:04 +0800 Subject: [PATCH] fix: pure ip resolve --- component/resolver/resolver.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/component/resolver/resolver.go b/component/resolver/resolver.go index d2c036d5..38412562 100644 --- a/component/resolver/resolver.go +++ b/component/resolver/resolver.go @@ -209,6 +209,11 @@ func ResolveAllIPWithResolver(host string, r Resolver) ([]netip.Addr, error) { return []netip.Addr{node.Data}, nil } + ip, err := netip.ParseAddr(host) + if err == nil { + return []netip.Addr{ip}, nil + } + if r != nil { if DisableIPv6 { return r.ResolveAllIPv4(host) @@ -219,11 +224,6 @@ func ResolveAllIPWithResolver(host string, r Resolver) ([]netip.Addr, error) { return ResolveAllIPv4(host) } - ip, err := netip.ParseAddr(host) - if err == nil { - return []netip.Addr{ip}, nil - } - if DefaultResolver == nil { ipAddr, err := net.ResolveIPAddr("ip", host) if err != nil { @@ -241,6 +241,11 @@ func ResolveAllIPPrimaryIPv4WithResolver(host string, r Resolver) ([]netip.Addr, return []netip.Addr{node.Data}, nil } + ip, err := netip.ParseAddr(host) + if err == nil { + return []netip.Addr{ip}, nil + } + if r != nil { if DisableIPv6 { return r.ResolveAllIPv4(host) @@ -251,11 +256,6 @@ func ResolveAllIPPrimaryIPv4WithResolver(host string, r Resolver) ([]netip.Addr, return ResolveAllIPv4(host) } - ip, err := netip.ParseAddr(host) - if err == nil { - return []netip.Addr{ip}, nil - } - if DefaultResolver == nil { ipAddr, err := net.ResolveIPAddr("ip", host) if err != nil {