|
@@ -17,7 +17,7 @@ namespace FastGithub.Dns
|
|
{
|
|
{
|
|
private readonly DnsServer dnsServer;
|
|
private readonly DnsServer dnsServer;
|
|
private readonly IEnumerable<IDnsValidator> dnsValidators;
|
|
private readonly IEnumerable<IDnsValidator> dnsValidators;
|
|
- private readonly IOptions<FastGithubListenOptions> listenOptions;
|
|
|
|
|
|
+ private readonly IOptionsMonitor<FastGithubOptions> options;
|
|
private readonly ILogger<DnsHostedService> logger;
|
|
private readonly ILogger<DnsHostedService> logger;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -25,19 +25,17 @@ namespace FastGithub.Dns
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="dnsServer"></param>
|
|
/// <param name="dnsServer"></param>
|
|
/// <param name="dnsValidators"></param>
|
|
/// <param name="dnsValidators"></param>
|
|
- /// <param name="options"></param>
|
|
|
|
- /// <param name="listenOptions"></param>
|
|
|
|
|
|
+ /// <param name="options"></param>
|
|
/// <param name="logger"></param>
|
|
/// <param name="logger"></param>
|
|
public DnsHostedService(
|
|
public DnsHostedService(
|
|
DnsServer dnsServer,
|
|
DnsServer dnsServer,
|
|
IEnumerable<IDnsValidator> dnsValidators,
|
|
IEnumerable<IDnsValidator> dnsValidators,
|
|
IOptionsMonitor<FastGithubOptions> options,
|
|
IOptionsMonitor<FastGithubOptions> options,
|
|
- IOptions<FastGithubListenOptions> listenOptions,
|
|
|
|
ILogger<DnsHostedService> logger)
|
|
ILogger<DnsHostedService> logger)
|
|
{
|
|
{
|
|
this.dnsServer = dnsServer;
|
|
this.dnsServer = dnsServer;
|
|
this.dnsValidators = dnsValidators;
|
|
this.dnsValidators = dnsValidators;
|
|
- this.listenOptions = listenOptions;
|
|
|
|
|
|
+ this.options = options;
|
|
this.logger = logger;
|
|
this.logger = logger;
|
|
|
|
|
|
options.OnChange(opt =>
|
|
options.OnChange(opt =>
|
|
@@ -56,7 +54,7 @@ namespace FastGithub.Dns
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public override async Task StartAsync(CancellationToken cancellationToken)
|
|
public override async Task StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
- var port = this.listenOptions.Value.DnsPort;
|
|
|
|
|
|
+ var port = this.options.CurrentValue.Listen.DnsPort;
|
|
this.dnsServer.Bind(IPAddress.Any, port);
|
|
this.dnsServer.Bind(IPAddress.Any, port);
|
|
this.logger.LogInformation("DNS服务启动成功");
|
|
this.logger.LogInformation("DNS服务启动成功");
|
|
|
|
|