From a25994f5263c2e102983009ae4dc2ed76a08b534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com> Date: Fri, 16 Jul 2021 16:33:10 +0800 Subject: [PATCH] =?UTF-8?q?Loopback=E7=9A=84dns=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.ReverseProxy/TrustedResolver.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/FastGithub.ReverseProxy/TrustedResolver.cs b/FastGithub.ReverseProxy/TrustedResolver.cs index 402786f..8bd57d5 100644 --- a/FastGithub.ReverseProxy/TrustedResolver.cs +++ b/FastGithub.ReverseProxy/TrustedResolver.cs @@ -67,7 +67,15 @@ namespace FastGithub.ReverseProxy var dnsClient = new DnsClient(endpoint); var addresses = await dnsClient.Lookup(domain, DNS.Protocol.RecordType.A, cancellationToken); var address = addresses?.FirstOrDefault(); - return address ?? throw new Exception($"解析不到{domain}的ip"); + if (address == null) + { + throw new Exception($"解析不到{domain}的ip"); + } + if (address.Equals(IPAddress.Loopback)) + { + throw new Exception($"dns受干扰,解析{domain}的ip为{IPAddress.Loopback}"); + } + return address; } catch (Exception ex) {