From 3f01444f2d811c7d4a31d76ccc1ca0dd1f7b895c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E4=B9=9D?= <366193849@qq.com> Date: Sun, 3 Oct 2021 11:32:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=B8=8D=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E7=9A=84=E9=A2=84=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.DomainResolve/DomainResolver.cs | 13 +------------ FastGithub.DomainResolve/IDomainResolver.cs | 6 ------ FastGithub.PacketIntercept/Dns/DnsInterceptor.cs | 9 +-------- .../FastGithub.PacketIntercept.csproj | 1 - 4 files changed, 2 insertions(+), 27 deletions(-) diff --git a/FastGithub.DomainResolve/DomainResolver.cs b/FastGithub.DomainResolve/DomainResolver.cs index 999b919..23d1fe2 100644 --- a/FastGithub.DomainResolve/DomainResolver.cs +++ b/FastGithub.DomainResolve/DomainResolver.cs @@ -25,18 +25,7 @@ namespace FastGithub.DomainResolve public DomainResolver(DnsClient dnsClient) { this.dnsClient = dnsClient; - } - - /// - /// 预加载 - /// - /// 域名 - public void Prefetch(string domain) - { - const int HTTPS_PORT = 443; - var dnsEndPoint = new DnsEndPoint(domain, HTTPS_PORT); - this.dnsEndPointAddressElapseds.TryAdd(dnsEndPoint, IPAddressElapsedCollection.Empty); - } + } /// /// 解析ip diff --git a/FastGithub.DomainResolve/IDomainResolver.cs b/FastGithub.DomainResolve/IDomainResolver.cs index 45877db..f965210 100644 --- a/FastGithub.DomainResolve/IDomainResolver.cs +++ b/FastGithub.DomainResolve/IDomainResolver.cs @@ -10,12 +10,6 @@ namespace FastGithub.DomainResolve /// public interface IDomainResolver { - /// - /// 预加载 - /// - /// 域名 - void Prefetch(string domain); - /// /// 解析ip /// diff --git a/FastGithub.PacketIntercept/Dns/DnsInterceptor.cs b/FastGithub.PacketIntercept/Dns/DnsInterceptor.cs index da281aa..dfa00a3 100644 --- a/FastGithub.PacketIntercept/Dns/DnsInterceptor.cs +++ b/FastGithub.PacketIntercept/Dns/DnsInterceptor.cs @@ -1,7 +1,6 @@ using DNS.Protocol; using DNS.Protocol.ResourceRecords; using FastGithub.Configuration; -using FastGithub.DomainResolve; using FastGithub.WinDiverts; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -26,7 +25,6 @@ namespace FastGithub.PacketIntercept.Dns private const string DNS_FILTER = "udp.DstPort == 53"; private readonly FastGithubConfig fastGithubConfig; - private readonly IDomainResolver domainResolver; private readonly ILogger logger; private readonly TimeSpan ttl = TimeSpan.FromMinutes(10d); @@ -41,18 +39,16 @@ namespace FastGithub.PacketIntercept.Dns /// dns拦截器 /// /// - /// /// /// public DnsInterceptor( FastGithubConfig fastGithubConfig, - IDomainResolver domainResolver, ILogger logger, IOptionsMonitor options) { this.fastGithubConfig = fastGithubConfig; this.logger = logger; - this.domainResolver = domainResolver; + options.OnChange(_ => DnsFlushResolverCache()); } @@ -135,9 +131,6 @@ namespace FastGithub.PacketIntercept.Dns return; } - // dns预加载 - this.domainResolver.Prefetch(domain.ToString()); - // dns响应数据 var response = Response.FromRequest(request); var record = new IPAddressResourceRecord(domain, IPAddress.Loopback, this.ttl); diff --git a/FastGithub.PacketIntercept/FastGithub.PacketIntercept.csproj b/FastGithub.PacketIntercept/FastGithub.PacketIntercept.csproj index d3fca22..2c8b98c 100644 --- a/FastGithub.PacketIntercept/FastGithub.PacketIntercept.csproj +++ b/FastGithub.PacketIntercept/FastGithub.PacketIntercept.csproj @@ -14,6 +14,5 @@ -