取消不必要的预加载
This commit is contained in:
parent
d3f5a46753
commit
3f01444f2d
@ -25,18 +25,7 @@ namespace FastGithub.DomainResolve
|
|||||||
public DomainResolver(DnsClient dnsClient)
|
public DomainResolver(DnsClient dnsClient)
|
||||||
{
|
{
|
||||||
this.dnsClient = dnsClient;
|
this.dnsClient = dnsClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 预加载
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="domain">域名</param>
|
|
||||||
public void Prefetch(string domain)
|
|
||||||
{
|
|
||||||
const int HTTPS_PORT = 443;
|
|
||||||
var dnsEndPoint = new DnsEndPoint(domain, HTTPS_PORT);
|
|
||||||
this.dnsEndPointAddressElapseds.TryAdd(dnsEndPoint, IPAddressElapsedCollection.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 解析ip
|
/// 解析ip
|
||||||
|
|||||||
@ -10,12 +10,6 @@ namespace FastGithub.DomainResolve
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IDomainResolver
|
public interface IDomainResolver
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 预加载
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="domain">域名</param>
|
|
||||||
void Prefetch(string domain);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 解析ip
|
/// 解析ip
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
using DNS.Protocol;
|
using DNS.Protocol;
|
||||||
using DNS.Protocol.ResourceRecords;
|
using DNS.Protocol.ResourceRecords;
|
||||||
using FastGithub.Configuration;
|
using FastGithub.Configuration;
|
||||||
using FastGithub.DomainResolve;
|
|
||||||
using FastGithub.WinDiverts;
|
using FastGithub.WinDiverts;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
@ -26,7 +25,6 @@ namespace FastGithub.PacketIntercept.Dns
|
|||||||
private const string DNS_FILTER = "udp.DstPort == 53";
|
private const string DNS_FILTER = "udp.DstPort == 53";
|
||||||
|
|
||||||
private readonly FastGithubConfig fastGithubConfig;
|
private readonly FastGithubConfig fastGithubConfig;
|
||||||
private readonly IDomainResolver domainResolver;
|
|
||||||
private readonly ILogger<DnsInterceptor> logger;
|
private readonly ILogger<DnsInterceptor> logger;
|
||||||
|
|
||||||
private readonly TimeSpan ttl = TimeSpan.FromMinutes(10d);
|
private readonly TimeSpan ttl = TimeSpan.FromMinutes(10d);
|
||||||
@ -41,18 +39,16 @@ namespace FastGithub.PacketIntercept.Dns
|
|||||||
/// dns拦截器
|
/// dns拦截器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fastGithubConfig"></param>
|
/// <param name="fastGithubConfig"></param>
|
||||||
/// <param name="domainResolver"></param>
|
|
||||||
/// <param name="logger"></param>
|
/// <param name="logger"></param>
|
||||||
/// <param name="options"></param>
|
/// <param name="options"></param>
|
||||||
public DnsInterceptor(
|
public DnsInterceptor(
|
||||||
FastGithubConfig fastGithubConfig,
|
FastGithubConfig fastGithubConfig,
|
||||||
IDomainResolver domainResolver,
|
|
||||||
ILogger<DnsInterceptor> logger,
|
ILogger<DnsInterceptor> logger,
|
||||||
IOptionsMonitor<FastGithubOptions> options)
|
IOptionsMonitor<FastGithubOptions> options)
|
||||||
{
|
{
|
||||||
this.fastGithubConfig = fastGithubConfig;
|
this.fastGithubConfig = fastGithubConfig;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.domainResolver = domainResolver;
|
|
||||||
options.OnChange(_ => DnsFlushResolverCache());
|
options.OnChange(_ => DnsFlushResolverCache());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,9 +131,6 @@ namespace FastGithub.PacketIntercept.Dns
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dns预加载
|
|
||||||
this.domainResolver.Prefetch(domain.ToString());
|
|
||||||
|
|
||||||
// dns响应数据
|
// dns响应数据
|
||||||
var response = Response.FromRequest(request);
|
var response = Response.FromRequest(request);
|
||||||
var record = new IPAddressResourceRecord(domain, IPAddress.Loopback, this.ttl);
|
var record = new IPAddressResourceRecord(domain, IPAddress.Loopback, this.ttl);
|
||||||
|
|||||||
@ -14,6 +14,5 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\FastGithub.Configuration\FastGithub.Configuration.csproj" />
|
<ProjectReference Include="..\FastGithub.Configuration\FastGithub.Configuration.csproj" />
|
||||||
<ProjectReference Include="..\FastGithub.DomainResolve\FastGithub.DomainResolve.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user