类型重命名

This commit is contained in:
老九 2021-09-08 14:28:11 +08:00
parent 0811f175c8
commit 19bd5550ad
3 changed files with 13 additions and 15 deletions

View File

@ -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
/// <summary>
/// dns后台服务
/// </summary>
sealed class DnsOverUdpHostedService : BackgroundService
sealed class DnsHostedService : BackgroundService
{
private readonly DnsOverUdpServer dnsOverUdpServer;
private readonly IEnumerable<IConflictValidator> conflictValidators;
private readonly ILogger<DnsOverUdpHostedService> logger;
private readonly ILogger<DnsHostedService> logger;
/// <summary>
/// dns后台服务
/// </summary>
/// <param name="dnsOverUdpServer"></param>
/// <param name="conflictValidators"></param>
/// <param name="options"></param>
/// <param name="logger"></param>
public DnsOverUdpHostedService(
public DnsHostedService(
DnsOverUdpServer dnsOverUdpServer,
IEnumerable<IConflictValidator> conflictValidators,
IOptionsMonitor<FastGithubOptions> options,
ILogger<DnsOverUdpHostedService> logger)
ILogger<DnsHostedService> logger)
{
this.dnsOverUdpServer = dnsOverUdpServer;
this.conflictValidators = conflictValidators;
this.logger = logger;
options.OnChange(opt => SystemDnsUtil.FlushResolverCache());
this.logger = logger;
}
/// <summary>
@ -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)}的DoHhttps://127.0.0.1/dns-query或向系统hosts文件添加github相关域名的ip为127.0.0.1");
}
foreach (var item in this.conflictValidators)

View File

@ -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
/// <param name="logger"></param>
public DnsOverUdpServer(
RequestResolver requestResolver,
ILogger<DnsOverUdpServer> logger)
ILogger<DnsOverUdpServer> logger,
IOptionsMonitor<FastGithubOptions> options)
{
this.requestResolver = requestResolver;
this.logger = logger;
options.OnChange(opt => SystemDnsUtil.FlushResolverCache());
}
/// <summary>

View File

@ -21,7 +21,7 @@ namespace FastGithub
services.TryAddSingleton<DnsOverHttpsMiddleware>();
services.AddSingleton<IConflictValidator, HostsConflictValidator>();
services.AddSingleton<IConflictValidator, ProxyConflictValidtor>();
return services.AddHostedService<DnsOverUdpHostedService>();
return services.AddHostedService<DnsHostedService>();
}
}
}