fix ip config

This commit is contained in:
陈国伟 2021-07-15 13:53:49 +08:00
parent 6fb855f06f
commit 4ce79fa5d6
3 changed files with 8 additions and 12 deletions

View File

@ -40,7 +40,7 @@ namespace FastGithub.Dns
{
this.options = options;
this.logger = logger;
this.requestResolver = new CompositeRequestResolver(options.Value.UpStream, githubRequestResolver);
this.requestResolver = new CompositeRequestResolver(IPAddress.Parse(options.Value.UpStream), githubRequestResolver);
}
/// <summary>
@ -57,7 +57,7 @@ namespace FastGithub.Dns
}
this.logger.LogInformation("dns服务启动成功");
this.dnsAddresses = this.SetNameServers(IPAddress.Loopback, this.options.Value.UpStream);
this.dnsAddresses = this.SetNameServers(IPAddress.Loopback, IPAddress.Parse(this.options.Value.UpStream));
return base.StartAsync(cancellationToken);
}

View File

@ -12,7 +12,7 @@ namespace FastGithub.Dns
/// <summary>
/// 获取或设置上游ip地址
/// </summary>
public IPAddress UpStream { get; set; } = IPAddress.Parse("114.114.114.114");
public string UpStream { get; set; } = "114.114.114.114";
/// <summary>
/// 获取或设置github相关域名的ip存活时长
@ -27,11 +27,11 @@ namespace FastGithub.Dns
/// <summary>
/// 是否使用反向代理访问github
/// </summary>
public bool UseGithubReverseProxy { get; set; }
public bool UseGithubReverseProxy { get; set; } = true;
/// <summary>
/// dns响应的反向代理服务的ip
/// </summary>
public IPAddress GithubReverseProxyIPAddress { get; set; } = IPAddress.Loopback;
public string GithubReverseProxyIPAddress { get; set; } = IPAddress.Loopback.ToString();
}
}

View File

@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
@ -73,16 +74,11 @@ namespace FastGithub.Dns
}
else
{
var address = this.options.CurrentValue.GithubReverseProxyIPAddress;
var address = IPAddress.Parse(this.options.CurrentValue.GithubReverseProxyIPAddress);
var record = new IPAddressResourceRecord(question.Name, address, TimeSpan.FromMinutes(1));
response.AnswerRecords.Add(record);
this.logger.LogInformation($"[{domain}->{address}]");
}
if (response.AnswerRecords.Count == 0)
{
this.logger.LogWarning($"无法获得{domain}的最快ip");
}
return Task.FromResult(response);
}
}