IPEndPointOptions->DnsConfig
This commit is contained in:
parent
9e798f0c94
commit
6559644c99
@ -5,9 +5,9 @@ using System.Net.NetworkInformation;
|
|||||||
namespace FastGithub
|
namespace FastGithub
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// dns的终节点
|
/// dns配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class IPEndPointOptions
|
public class DnsConfig
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// IP地址
|
/// IP地址
|
||||||
20
FastGithub.Core/DomainConfig.cs
Normal file
20
FastGithub.Core/DomainConfig.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
namespace FastGithub
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 域名配置
|
||||||
|
/// </summary>
|
||||||
|
public class DomainConfig
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 是否不发送SNI
|
||||||
|
/// </summary>
|
||||||
|
public bool NoSni { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 目的地
|
||||||
|
/// 支持ip或域名
|
||||||
|
/// 留空则本域名
|
||||||
|
/// </summary>
|
||||||
|
public string? Destination { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,18 +14,18 @@ namespace FastGithub
|
|||||||
/// 域名
|
/// 域名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private DomainMatch[]? domainMatches;
|
private DomainMatch[]? domainMatches;
|
||||||
private IPEndPoint? trustedDnsEndPoint;
|
private IPEndPoint? trustedDnsIPEndPoint;
|
||||||
private IPEndPoint? unTrustedDnsEndPoint;
|
private IPEndPoint? unTrustedDnsIPEndPoint;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 受信任的dns服务
|
/// 受信任的dns服务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IPEndPointOptions TrustedDns { get; set; } = new IPEndPointOptions { IPAddress = "127.0.0.1", Port = 5533 };
|
public DnsConfig TrustedDns { get; set; } = new DnsConfig { IPAddress = "127.0.0.1", Port = 5533 };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 不受信任的dns服务
|
/// 不受信任的dns服务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IPEndPointOptions UntrustedDns { get; set; } = new IPEndPointOptions { IPAddress = "114.114.114.114", Port = 53 };
|
public DnsConfig UntrustedDns { get; set; } = new DnsConfig { IPAddress = "114.114.114.114", Port = 53 };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 代理的域名表达式
|
/// 代理的域名表达式
|
||||||
@ -38,8 +38,8 @@ namespace FastGithub
|
|||||||
/// <exception cref="FastGithubException"></exception>
|
/// <exception cref="FastGithubException"></exception>
|
||||||
public void Validate()
|
public void Validate()
|
||||||
{
|
{
|
||||||
this.trustedDnsEndPoint = this.TrustedDns.ToIPEndPoint();
|
this.trustedDnsIPEndPoint = this.TrustedDns.ToIPEndPoint();
|
||||||
this.unTrustedDnsEndPoint = this.UntrustedDns.ToIPEndPoint();
|
this.unTrustedDnsIPEndPoint = this.UntrustedDns.ToIPEndPoint();
|
||||||
this.domainMatches = this.DomainPatterns.Select(item => new DomainMatch(item)).ToArray();
|
this.domainMatches = this.DomainPatterns.Select(item => new DomainMatch(item)).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ namespace FastGithub
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IPEndPoint GetTrustedDns()
|
public IPEndPoint GetTrustedDns()
|
||||||
{
|
{
|
||||||
return this.trustedDnsEndPoint ?? throw new InvalidOperationException();
|
return this.trustedDnsIPEndPoint ?? throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -57,7 +57,7 @@ namespace FastGithub
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IPEndPoint GetUnTrustedDns()
|
public IPEndPoint GetUnTrustedDns()
|
||||||
{
|
{
|
||||||
return this.unTrustedDnsEndPoint ?? throw new InvalidOperationException();
|
return this.unTrustedDnsIPEndPoint ?? throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -32,7 +32,7 @@ namespace FastGithub.Dns
|
|||||||
{
|
{
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.untrustedResolver = new UdpRequestResolver(options.CurrentValue.UntrustedDns.ToIPEndPoint());
|
this.untrustedResolver = new UdpRequestResolver(options.CurrentValue.GetTrustedDns());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user