From c00430d6f453113dd8af3a9319a54383ba050839 Mon Sep 17 00:00:00 2001 From: xljiulang <366193849@qq.com> Date: Fri, 16 Jul 2021 20:37:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9B=B4=E5=A4=9A=E5=9F=9F?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.ReverseProxy/NoSniHttpClientHanlder.cs | 11 +++++++++-- FastGithub.ReverseProxy/TrustedResolver.cs | 8 +------- FastGithub/appsettings.json | 4 +++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/FastGithub.ReverseProxy/NoSniHttpClientHanlder.cs b/FastGithub.ReverseProxy/NoSniHttpClientHanlder.cs index fc23c62..6d2bf0d 100644 --- a/FastGithub.ReverseProxy/NoSniHttpClientHanlder.cs +++ b/FastGithub.ReverseProxy/NoSniHttpClientHanlder.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.Extensions.Logging; +using System; using System.Net.Http; using System.Net.Security; using System.Net.Sockets; @@ -13,14 +14,18 @@ namespace FastGithub.ReverseProxy class NoSniHttpClientHanlder : DelegatingHandler { private readonly TrustedResolver trustedDomainResolver; + private readonly ILogger logger; /// /// 不发送NoSni的HttpClientHandler /// /// - public NoSniHttpClientHanlder(TrustedResolver trustedDomainResolver) + public NoSniHttpClientHanlder( + TrustedResolver trustedDomainResolver, + ILogger logger) { this.trustedDomainResolver = trustedDomainResolver; + this.logger = logger; this.InnerHandler = CreateNoneSniHttpHandler(); } @@ -69,6 +74,8 @@ namespace FastGithub.ReverseProxy if (uri != null && uri.HostNameType == UriHostNameType.Dns) { var address = await this.trustedDomainResolver.ResolveAsync(uri.Host, cancellationToken); + this.logger.LogInformation($"[{address}--NoSni->{uri.Host}]"); + var builder = new UriBuilder(uri) { Scheme = Uri.UriSchemeHttp, diff --git a/FastGithub.ReverseProxy/TrustedResolver.cs b/FastGithub.ReverseProxy/TrustedResolver.cs index 8bd57d5..d050e47 100644 --- a/FastGithub.ReverseProxy/TrustedResolver.cs +++ b/FastGithub.ReverseProxy/TrustedResolver.cs @@ -1,6 +1,5 @@ using DNS.Client; using Microsoft.Extensions.Caching.Memory; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using System; using System.Linq; @@ -18,7 +17,6 @@ namespace FastGithub.ReverseProxy private readonly IMemoryCache memoryCache; private readonly TimeSpan cacheTimeSpan = TimeSpan.FromSeconds(10d); private readonly IOptionsMonitor options; - private readonly ILogger logger; /// /// 受信任的域名解析器 @@ -26,12 +24,10 @@ namespace FastGithub.ReverseProxy /// public TrustedResolver( IMemoryCache memoryCache, - IOptionsMonitor options, - ILogger logger) + IOptionsMonitor options) { this.memoryCache = memoryCache; this.options = options; - this.logger = logger; } /// @@ -48,8 +44,6 @@ namespace FastGithub.ReverseProxy e.SetAbsoluteExpiration(this.cacheTimeSpan); return this.LookupAsync(domain, cancellationToken); }); - - this.logger.LogInformation($"[{address}->{domain}]"); return address; } diff --git a/FastGithub/appsettings.json b/FastGithub/appsettings.json index 251f6fb..0cb14bb 100644 --- a/FastGithub/appsettings.json +++ b/FastGithub/appsettings.json @@ -10,11 +10,13 @@ }, "DomainMatches": [ // *ʾ0nַ "github.com", + "githubstatus.com", "*.github.com", "*.github.io", "*.githubapp.com", "*.githubassets.com", - "*.githubusercontent.com" + "*.githubusercontent.com", + "*github*.s3.amazonaws.com" ] }, "Logging": {