修改dns服务启动时逻辑顺序
This commit is contained in:
parent
4ae101a76f
commit
7bb7da063c
@ -70,6 +70,7 @@ namespace FastGithub.Dns.DnscryptProxy
|
|||||||
if (this.dnscryptProcess != null)
|
if (this.dnscryptProcess != null)
|
||||||
{
|
{
|
||||||
this.dnscryptProcess.Kill();
|
this.dnscryptProcess.Kill();
|
||||||
|
this.logger.LogInformation($"{dnscryptFile}已停止");
|
||||||
}
|
}
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,9 +56,10 @@ namespace FastGithub.Dns
|
|||||||
public override async Task StartAsync(CancellationToken cancellationToken)
|
public override async Task StartAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await this.BindAsync(cancellationToken);
|
await this.BindAsync(cancellationToken);
|
||||||
await this.hostsValidator.ValidateAsync();
|
this.logger.LogInformation("DNS服务启动成功");
|
||||||
|
|
||||||
this.SetAsPrimitiveNameServer();
|
this.SetAsPrimitiveNameServer();
|
||||||
this.logger.LogInformation("dns服务启动成功");
|
await this.hostsValidator.ValidateAsync();
|
||||||
|
|
||||||
await base.StartAsync(cancellationToken);
|
await base.StartAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
@ -113,16 +114,16 @@ namespace FastGithub.Dns
|
|||||||
{
|
{
|
||||||
SystemDnsUtil.DnsSetPrimitive(IPAddress.Loopback);
|
SystemDnsUtil.DnsSetPrimitive(IPAddress.Loopback);
|
||||||
SystemDnsUtil.DnsFlushResolverCache();
|
SystemDnsUtil.DnsFlushResolverCache();
|
||||||
this.logger.LogInformation($"设置为本机dns成功");
|
this.logger.LogInformation($"设置为本机主DNS成功");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
this.logger.LogWarning($"设置为本机dns失败:{ex.Message}");
|
this.logger.LogWarning($"设置为本机主DNS失败:{ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.logger.LogWarning("平台不支持自动设置dns,请手动设置网卡的主dns为127.0.0.1");
|
this.logger.LogWarning("平台不支持自动设置DNS,请手动设置网卡的主DNS为127.0.0.1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +168,7 @@ namespace FastGithub.Dns
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
this.logger.LogTrace($"处理dns异常:{ex.Message}");
|
this.logger.LogTrace($"处理DNS异常:{ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +180,7 @@ namespace FastGithub.Dns
|
|||||||
public override Task StopAsync(CancellationToken cancellationToken)
|
public override Task StopAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
this.socket.Dispose();
|
this.socket.Dispose();
|
||||||
this.logger.LogInformation("dns服务已终止");
|
this.logger.LogInformation("DNS服务已停止");
|
||||||
|
|
||||||
if (OperatingSystem.IsWindows())
|
if (OperatingSystem.IsWindows())
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user