From 9e9f459c0e780a931274b53889f361421af972f7 Mon Sep 17 00:00:00 2001 From: Skyxim Date: Thu, 2 Jun 2022 20:57:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96proxy=20server=20?= =?UTF-8?q?nameserver,=20=E5=BD=93=E8=8A=82=E7=82=B9=E4=B8=93=E7=94=A8dns?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E6=9F=A5=E8=AF=A2=E5=A4=B1=E8=B4=A5=E4=BC=9A?= =?UTF-8?q?=E5=9B=9E=E8=90=BD=E5=88=B0=E6=AD=A3=E5=B8=B8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/resolver/resolver.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/component/resolver/resolver.go b/component/resolver/resolver.go index 9fe6309f..bd1b262b 100644 --- a/component/resolver/resolver.go +++ b/component/resolver/resolver.go @@ -89,24 +89,39 @@ func ResolveIP(host string) (netip.Addr, error) { // ResolveIPv4ProxyServerHost proxies server host only func ResolveIPv4ProxyServerHost(host string) (netip.Addr, error) { if ProxyServerHostResolver != nil { - return ResolveIPv4WithResolver(host, ProxyServerHostResolver) + if ip, err := ResolveIPv4WithResolver(host, ProxyServerHostResolver); err != nil { + return ResolveIPv4(host) + } else { + return ip, nil + } } + return ResolveIPv4(host) } // ResolveIPv6ProxyServerHost proxies server host only func ResolveIPv6ProxyServerHost(host string) (netip.Addr, error) { if ProxyServerHostResolver != nil { - return ResolveIPv6WithResolver(host, ProxyServerHostResolver) + if ip, err := ResolveIPv6WithResolver(host, ProxyServerHostResolver); err != nil { + return ResolveIPv6(host) + } else { + return ip, nil + } } + return ResolveIPv6(host) } // ResolveProxyServerHost proxies server host only func ResolveProxyServerHost(host string) (netip.Addr, error) { if ProxyServerHostResolver != nil { - return ResolveIPWithResolver(host, ProxyServerHostResolver) + if ip, err := ResolveIPWithResolver(host, ProxyServerHostResolver); err != nil { + return ResolveIP(host) + } else { + return ip, err + } } + return ResolveIP(host) }