Loopback的dns检测

This commit is contained in:
陈国伟 2021-07-16 16:33:10 +08:00
parent c3fefdf4d3
commit a25994f526

View File

@ -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)
{