diff --git a/FastGithub.Dns/DnsOverUdpHostedService.cs b/FastGithub.Dns/DnsHostedService.cs
similarity index 79%
rename from FastGithub.Dns/DnsOverUdpHostedService.cs
rename to FastGithub.Dns/DnsHostedService.cs
index 13ec6b0..e9beb03 100644
--- a/FastGithub.Dns/DnsOverUdpHostedService.cs
+++ b/FastGithub.Dns/DnsHostedService.cs
@@ -1,7 +1,5 @@
-using FastGithub.Configuration;
-using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Net;
@@ -13,30 +11,26 @@ namespace FastGithub.Dns
///
/// dns后台服务
///
- sealed class DnsOverUdpHostedService : BackgroundService
+ sealed class DnsHostedService : BackgroundService
{
private readonly DnsOverUdpServer dnsOverUdpServer;
private readonly IEnumerable conflictValidators;
- private readonly ILogger logger;
-
+ private readonly ILogger logger;
///
/// dns后台服务
///
///
///
- ///
///
- public DnsOverUdpHostedService(
+ public DnsHostedService(
DnsOverUdpServer dnsOverUdpServer,
IEnumerable conflictValidators,
- IOptionsMonitor options,
- ILogger logger)
+ ILogger logger)
{
this.dnsOverUdpServer = dnsOverUdpServer;
this.conflictValidators = conflictValidators;
- this.logger = logger;
- options.OnChange(opt => SystemDnsUtil.FlushResolverCache());
+ this.logger = logger;
}
///
@@ -54,7 +48,7 @@ namespace FastGithub.Dns
}
catch (Exception ex)
{
- this.logger.LogError($"DNS服务启动失败:{ex.Message}{Environment.NewLine}请配置系统或浏览器使用{nameof(FastGithub)}的DoH,或向系统hosts文件添加github相关域名的ip为127.0.0.1");
+ this.logger.LogError($"DNS服务启动失败:{ex.Message}{Environment.NewLine}请配置系统或浏览器使用{nameof(FastGithub)}的DoH:https://127.0.0.1/dns-query,或向系统hosts文件添加github相关域名的ip为127.0.0.1");
}
foreach (var item in this.conflictValidators)
diff --git a/FastGithub.Dns/DnsOverUdpServer.cs b/FastGithub.Dns/DnsOverUdpServer.cs
index ab121df..2102cbb 100644
--- a/FastGithub.Dns/DnsOverUdpServer.cs
+++ b/FastGithub.Dns/DnsOverUdpServer.cs
@@ -1,6 +1,7 @@
using DNS.Protocol;
using FastGithub.Configuration;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
using System;
using System.Net;
using System.Net.Sockets;
@@ -28,10 +29,13 @@ namespace FastGithub.Dns
///
public DnsOverUdpServer(
RequestResolver requestResolver,
- ILogger logger)
+ ILogger logger,
+ IOptionsMonitor options)
{
this.requestResolver = requestResolver;
this.logger = logger;
+
+ options.OnChange(opt => SystemDnsUtil.FlushResolverCache());
}
///
diff --git a/FastGithub.Dns/ServiceCollectionExtensions.cs b/FastGithub.Dns/ServiceCollectionExtensions.cs
index 1205a86..f3d26d6 100644
--- a/FastGithub.Dns/ServiceCollectionExtensions.cs
+++ b/FastGithub.Dns/ServiceCollectionExtensions.cs
@@ -21,7 +21,7 @@ namespace FastGithub
services.TryAddSingleton();
services.AddSingleton();
services.AddSingleton();
- return services.AddHostedService();
+ return services.AddHostedService();
}
}
}