增加更多域名

This commit is contained in:
xljiulang 2021-07-16 20:37:16 +08:00
parent a3ff984c5c
commit c00430d6f4
3 changed files with 13 additions and 10 deletions

View File

@ -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<NoSniHttpClientHanlder> logger;
/// <summary>
/// 不发送NoSni的HttpClientHandler
/// </summary>
/// <param name="trustedDomainResolver"></param>
public NoSniHttpClientHanlder(TrustedResolver trustedDomainResolver)
public NoSniHttpClientHanlder(
TrustedResolver trustedDomainResolver,
ILogger<NoSniHttpClientHanlder> 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,

View File

@ -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<FastGithubOptions> options;
private readonly ILogger<TrustedResolver> logger;
/// <summary>
/// 受信任的域名解析器
@ -26,12 +24,10 @@ namespace FastGithub.ReverseProxy
/// <param name="options"></param>
public TrustedResolver(
IMemoryCache memoryCache,
IOptionsMonitor<FastGithubOptions> options,
ILogger<TrustedResolver> logger)
IOptionsMonitor<FastGithubOptions> options)
{
this.memoryCache = memoryCache;
this.options = options;
this.logger = logger;
}
/// <summary>
@ -48,8 +44,6 @@ namespace FastGithub.ReverseProxy
e.SetAbsoluteExpiration(this.cacheTimeSpan);
return this.LookupAsync(domain, cancellationToken);
});
this.logger.LogInformation($"[{address}->{domain}]");
return address;
}

View File

@ -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": {