配置变化刷新dns缓存
This commit is contained in:
parent
01b2aec329
commit
c066e153be
@ -2,6 +2,7 @@
|
|||||||
using DNS.Protocol.ResourceRecords;
|
using DNS.Protocol.ResourceRecords;
|
||||||
using FastGithub.Configuration;
|
using FastGithub.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
using System;
|
using System;
|
||||||
using System.Buffers.Binary;
|
using System.Buffers.Binary;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -29,18 +30,21 @@ namespace FastGithub.Dns
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DllImport("dnsapi.dll", EntryPoint = "DnsFlushResolverCache", SetLastError = true)]
|
[DllImport("dnsapi.dll", EntryPoint = "DnsFlushResolverCache", SetLastError = true)]
|
||||||
private static extern void DnsFlushResolverCache();
|
private static extern void DnsFlushResolverCache();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// dns投毒后台服务
|
/// dns拦截器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fastGithubConfig"></param>
|
/// <param name="fastGithubConfig"></param>
|
||||||
/// <param name="logger"></param>
|
/// <param name="logger"></param>
|
||||||
|
/// <param name="options"></param>
|
||||||
public DnsInterceptor(
|
public DnsInterceptor(
|
||||||
FastGithubConfig fastGithubConfig,
|
FastGithubConfig fastGithubConfig,
|
||||||
ILogger<DnsInterceptor> logger)
|
ILogger<DnsInterceptor> logger,
|
||||||
|
IOptionsMonitor<FastGithubOptions> options)
|
||||||
{
|
{
|
||||||
this.fastGithubConfig = fastGithubConfig;
|
this.fastGithubConfig = fastGithubConfig;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
|
||||||
|
options.OnChange(_ => DnsFlushResolverCache());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user