diff --git a/FastGithub.Core/DomainConfig.cs b/FastGithub.Core/DomainConfig.cs index aba77b3..5c6ab09 100644 --- a/FastGithub.Core/DomainConfig.cs +++ b/FastGithub.Core/DomainConfig.cs @@ -8,9 +8,9 @@ namespace FastGithub public class DomainConfig { /// - /// 是否不发送SNI + /// 是否发送SNI /// - public bool NoSni { get; set; } = true; + public bool TlsSni { get; set; } /// /// 目的地 diff --git a/FastGithub.Core/FastGithubConfig.cs b/FastGithub.Core/FastGithubConfig.cs index eb04efb..003b7b3 100644 --- a/FastGithub.Core/FastGithubConfig.cs +++ b/FastGithub.Core/FastGithubConfig.cs @@ -20,16 +20,16 @@ namespace FastGithub /// - /// 获取信任dns + /// 未污染的dns /// [AllowNull] - public IPEndPoint TrustedDns { get; private set; } + public IPEndPoint PureDns { get; private set; } /// - /// 获取非信任dns + /// 速度快的dns /// [AllowNull] - public IPEndPoint UnTrustedDns { get; private set; } + public IPEndPoint FastDns { get; private set; } /// /// 获取域名配置 @@ -54,8 +54,8 @@ namespace FastGithub private void Init(FastGithubOptions options) { this.domainConfigCache = new ConcurrentDictionary(); - this.TrustedDns = options.TrustedDns.ToIPEndPoint(); - this.UnTrustedDns = options.UntrustedDns.ToIPEndPoint(); + this.PureDns = options.PureDns.ToIPEndPoint(); + this.FastDns = options.FastDns.ToIPEndPoint(); this.DomainConfigs = options.DomainConfigs.ToDictionary(kv => new DomainMatch(kv.Key), kv => kv.Value); } diff --git a/FastGithub.Core/FastGithubOptions.cs b/FastGithub.Core/FastGithubOptions.cs index ef78563..e132be2 100644 --- a/FastGithub.Core/FastGithubOptions.cs +++ b/FastGithub.Core/FastGithubOptions.cs @@ -8,14 +8,14 @@ namespace FastGithub public class FastGithubOptions { /// - /// 受信任的dns服务 + /// 未污染的dns /// - public DnsConfig TrustedDns { get; set; } = new DnsConfig { IPAddress = "127.0.0.1", Port = 5533 }; + public DnsConfig PureDns { get; set; } = new DnsConfig { IPAddress = "127.0.0.1", Port = 5533 }; /// - /// 不受信任的dns服务 + /// 速度快的dns /// - public DnsConfig UntrustedDns { get; set; } = new DnsConfig { IPAddress = "114.114.114.114", Port = 53 }; + public DnsConfig FastDns { get; set; } = new DnsConfig { IPAddress = "114.114.114.114", Port = 53 }; /// /// 代理的域名配置 diff --git a/FastGithub.Dns/DnsServerHostedService.cs b/FastGithub.Dns/DnsServerHostedService.cs index 10b10f4..cf0ed96 100644 --- a/FastGithub.Dns/DnsServerHostedService.cs +++ b/FastGithub.Dns/DnsServerHostedService.cs @@ -82,7 +82,7 @@ namespace FastGithub.Dns } this.logger.LogInformation("dns服务启动成功"); - var secondary = this.fastGithubConfig.UnTrustedDns.Address; + var secondary = this.fastGithubConfig.FastDns.Address; this.dnsAddresses = this.SetNameServers(IPAddress.Loopback, secondary); FlushResolverCache(); diff --git a/FastGithub.Dns/RequestResolver.cs b/FastGithub.Dns/RequestResolver.cs index e2ea448..42f28af 100644 --- a/FastGithub.Dns/RequestResolver.cs +++ b/FastGithub.Dns/RequestResolver.cs @@ -36,12 +36,12 @@ namespace FastGithub.Dns this.fastGithubConfig = fastGithubConfig; this.logger = logger; - this.requestResolver = new UdpRequestResolver(fastGithubConfig.UnTrustedDns); - options.OnChange(opt => DnsConfigChanged(opt.UntrustedDns)); + this.requestResolver = new UdpRequestResolver(fastGithubConfig.FastDns); + options.OnChange(opt => OptionsChanged(opt)); - void DnsConfigChanged(DnsConfig config) + void OptionsChanged(FastGithubOptions opt) { - var dns = config.ToIPEndPoint(); + var dns = opt.FastDns.ToIPEndPoint(); this.requestResolver = new UdpRequestResolver(dns); } } diff --git a/FastGithub.ReverseProxy/DomainResolver.cs b/FastGithub.ReverseProxy/DomainResolver.cs index 7b442ee..448dd57 100644 --- a/FastGithub.ReverseProxy/DomainResolver.cs +++ b/FastGithub.ReverseProxy/DomainResolver.cs @@ -57,7 +57,7 @@ namespace FastGithub.ReverseProxy { try { - var dns = this.fastGithubConfig.TrustedDns; + var dns = this.fastGithubConfig.PureDns; var dnsClient = new DnsClient(dns); var addresses = await dnsClient.Lookup(domain, DNS.Protocol.RecordType.A, cancellationToken); var address = addresses?.FirstOrDefault(); @@ -80,7 +80,7 @@ namespace FastGithub.ReverseProxy } catch (Exception ex) { - var dns = this.fastGithubConfig.TrustedDns; + var dns = this.fastGithubConfig.PureDns; throw new FastGithubException($"dns({dns}):{ex.Message}", ex); } } diff --git a/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs b/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs index 851bcc6..fd974b4 100644 --- a/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs +++ b/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs @@ -47,9 +47,9 @@ namespace FastGithub.ReverseProxy } var destinationPrefix = GetDestinationPrefix(host, domainConfig.Destination); - var httpClient = domainConfig.NoSni - ? new HttpMessageInvoker(this.noSniHttpClientHanlder, disposeHandler: false) - : new HttpMessageInvoker(this.sniHttpClientHanlder, disposeHandler: false); + var httpClient = domainConfig.TlsSni + ? new HttpMessageInvoker(this.sniHttpClientHanlder, disposeHandler: false) + : new HttpMessageInvoker(this.noSniHttpClientHanlder, disposeHandler: false); var error = await httpForwarder.SendAsync(context, destinationPrefix, httpClient); await ResponseErrorAsync(context, error); diff --git a/FastGithub/appsettings.json b/FastGithub/appsettings.json index e61a0d3..c13e35a 100644 --- a/FastGithub/appsettings.json +++ b/FastGithub/appsettings.json @@ -1,68 +1,68 @@ { "FastGithub": { - "TrustedDns": { // ڽDomainConfigs׼ȷ + "PureDns": { // ڽDomainConfigs "IPAddress": "127.0.0.1", "Port": 5533 // 5533ָdnscrypt-proxy }, - "UnTrustedDns": { // ڽDomainConfigsٶȿ + "FastDns": { // ڽDomainConfigs "IPAddress": "114.114.114.114", "Port": 53 }, "DomainConfigs": { // *ʾ0ַ "github.com": { - "NoSni": true, + "TlsSni": false, "Destination": null }, "githubstatus.com": { - "NoSni": true, + "TlsSni": false, "Destination": null }, "*.github.com": { - "NoSni": true, + "TlsSni": false, "Destination": null }, "*.github.io": { - "NoSni": true, + "TlsSni": false, "Destination": null }, "*.githubapp.com": { - "NoSni": true, + "TlsSni": false, "Destination": null }, "*.githubassets.com": { - "NoSni": true, + "TlsSni": false, "Destination": null }, "*.githubusercontent.com": { - "NoSni": true, + "TlsSni": false, "Destination": null }, "*github*.s3.amazonaws.com": { - "NoSni": true, + "TlsSni": false, "Destination": null }, "ajax.googleapis.com": { - "NoSni": false, + "TlsSni": true, "Destination": "https://gapis.geekzu.org/ajax/" }, "fonts.googleapis.com": { - "NoSni": false, + "TlsSni": true, "Destination": "https://fonts.geekzu.org/" }, "themes.googleusercontent.com": { - "NoSni": false, + "TlsSni": true, "Destination": "https://gapis.geekzu.org/g-themes/" }, "fonts.gstatic.com": { - "NoSni": false, + "TlsSni": true, "Destination": "https://gapis.geekzu.org/g-fonts/" }, "secure.gravatar.com": { - "NoSni": false, + "TlsSni": true, "Destination": "https://sdn.geekzu.org/" }, "*.gravatar.com": { - "NoSni": false, + "TlsSni": true, "Destination": "https://fdn.geekzu.org/" } }