增加更多域名
This commit is contained in:
parent
a3ff984c5c
commit
c00430d6f4
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
@ -13,14 +14,18 @@ namespace FastGithub.ReverseProxy
|
|||||||
class NoSniHttpClientHanlder : DelegatingHandler
|
class NoSniHttpClientHanlder : DelegatingHandler
|
||||||
{
|
{
|
||||||
private readonly TrustedResolver trustedDomainResolver;
|
private readonly TrustedResolver trustedDomainResolver;
|
||||||
|
private readonly ILogger<NoSniHttpClientHanlder> logger;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 不发送NoSni的HttpClientHandler
|
/// 不发送NoSni的HttpClientHandler
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="trustedDomainResolver"></param>
|
/// <param name="trustedDomainResolver"></param>
|
||||||
public NoSniHttpClientHanlder(TrustedResolver trustedDomainResolver)
|
public NoSniHttpClientHanlder(
|
||||||
|
TrustedResolver trustedDomainResolver,
|
||||||
|
ILogger<NoSniHttpClientHanlder> logger)
|
||||||
{
|
{
|
||||||
this.trustedDomainResolver = trustedDomainResolver;
|
this.trustedDomainResolver = trustedDomainResolver;
|
||||||
|
this.logger = logger;
|
||||||
this.InnerHandler = CreateNoneSniHttpHandler();
|
this.InnerHandler = CreateNoneSniHttpHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +74,8 @@ namespace FastGithub.ReverseProxy
|
|||||||
if (uri != null && uri.HostNameType == UriHostNameType.Dns)
|
if (uri != null && uri.HostNameType == UriHostNameType.Dns)
|
||||||
{
|
{
|
||||||
var address = await this.trustedDomainResolver.ResolveAsync(uri.Host, cancellationToken);
|
var address = await this.trustedDomainResolver.ResolveAsync(uri.Host, cancellationToken);
|
||||||
|
this.logger.LogInformation($"[{address}--NoSni->{uri.Host}]");
|
||||||
|
|
||||||
var builder = new UriBuilder(uri)
|
var builder = new UriBuilder(uri)
|
||||||
{
|
{
|
||||||
Scheme = Uri.UriSchemeHttp,
|
Scheme = Uri.UriSchemeHttp,
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
using DNS.Client;
|
using DNS.Client;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -18,7 +17,6 @@ namespace FastGithub.ReverseProxy
|
|||||||
private readonly IMemoryCache memoryCache;
|
private readonly IMemoryCache memoryCache;
|
||||||
private readonly TimeSpan cacheTimeSpan = TimeSpan.FromSeconds(10d);
|
private readonly TimeSpan cacheTimeSpan = TimeSpan.FromSeconds(10d);
|
||||||
private readonly IOptionsMonitor<FastGithubOptions> options;
|
private readonly IOptionsMonitor<FastGithubOptions> options;
|
||||||
private readonly ILogger<TrustedResolver> logger;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 受信任的域名解析器
|
/// 受信任的域名解析器
|
||||||
@ -26,12 +24,10 @@ namespace FastGithub.ReverseProxy
|
|||||||
/// <param name="options"></param>
|
/// <param name="options"></param>
|
||||||
public TrustedResolver(
|
public TrustedResolver(
|
||||||
IMemoryCache memoryCache,
|
IMemoryCache memoryCache,
|
||||||
IOptionsMonitor<FastGithubOptions> options,
|
IOptionsMonitor<FastGithubOptions> options)
|
||||||
ILogger<TrustedResolver> logger)
|
|
||||||
{
|
{
|
||||||
this.memoryCache = memoryCache;
|
this.memoryCache = memoryCache;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.logger = logger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -48,8 +44,6 @@ namespace FastGithub.ReverseProxy
|
|||||||
e.SetAbsoluteExpiration(this.cacheTimeSpan);
|
e.SetAbsoluteExpiration(this.cacheTimeSpan);
|
||||||
return this.LookupAsync(domain, cancellationToken);
|
return this.LookupAsync(domain, cancellationToken);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.logger.LogInformation($"[{address}->{domain}]");
|
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,11 +10,13 @@
|
|||||||
},
|
},
|
||||||
"DomainMatches": [ // *表示0到n个任意字符
|
"DomainMatches": [ // *表示0到n个任意字符
|
||||||
"github.com",
|
"github.com",
|
||||||
|
"githubstatus.com",
|
||||||
"*.github.com",
|
"*.github.com",
|
||||||
"*.github.io",
|
"*.github.io",
|
||||||
"*.githubapp.com",
|
"*.githubapp.com",
|
||||||
"*.githubassets.com",
|
"*.githubassets.com",
|
||||||
"*.githubusercontent.com"
|
"*.githubusercontent.com",
|
||||||
|
"*github*.s3.amazonaws.com"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user