diff --git a/FastGithub.Dns/DnsOptions.cs b/FastGithub.Dns/DnsOptions.cs
index 1b6ee60..45d5eea 100644
--- a/FastGithub.Dns/DnsOptions.cs
+++ b/FastGithub.Dns/DnsOptions.cs
@@ -23,5 +23,10 @@ namespace FastGithub.Dns
/// 是否设置本机使用此dns
///
public bool SetToLocalMachine { get; set; } = true;
+
+ ///
+ /// 是否启用反向代理
+ ///
+ public bool UseReverseProxy { get; set; } = true;
}
}
diff --git a/FastGithub.Dns/GithubRequestResolver.cs b/FastGithub.Dns/GithubRequestResolver.cs
index 9c15d20..8420874 100644
--- a/FastGithub.Dns/GithubRequestResolver.cs
+++ b/FastGithub.Dns/GithubRequestResolver.cs
@@ -6,7 +6,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Linq;
-using System.Net;
+using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
@@ -44,7 +44,7 @@ namespace FastGithub.Dns
///
///
///
- public Task Resolve(IRequest request, CancellationToken cancellationToken = default)
+ public async Task Resolve(IRequest request, CancellationToken cancellationToken = default)
{
var response = Response.FromRequest(request);
var question = request.Questions.FirstOrDefault();
@@ -56,15 +56,31 @@ namespace FastGithub.Dns
if (address != null)
{
- address = IPAddress.Loopback;
var ttl = this.options.CurrentValue.GithubTTL;
- var record = new IPAddressResourceRecord(question.Name, address, ttl);
- response.AnswerRecords.Add(record);
- this.logger.LogInformation(record.ToString());
+ if (this.options.CurrentValue.UseReverseProxy == false)
+ {
+ var record = new IPAddressResourceRecord(question.Name, address, ttl);
+ response.AnswerRecords.Add(record);
+ this.logger.LogInformation(record.ToString());
+ }
+ else
+ {
+ var hostName = System.Net.Dns.GetHostName();
+ var addresses = await System.Net.Dns.GetHostAddressesAsync(hostName);
+ foreach (var item in addresses)
+ {
+ if (item.AddressFamily == AddressFamily.InterNetwork)
+ {
+ var record = new IPAddressResourceRecord(question.Name, item, ttl);
+ response.AnswerRecords.Add(record);
+ this.logger.LogInformation(record.ToString());
+ }
+ }
+ }
}
}
- return Task.FromResult(response);
+ return response;
}
}
}
diff --git a/FastGithub.ReverseProxy/CertGenerator.cs b/FastGithub.ReverseProxy/CertGenerator.cs
index 9b3eebc..ab57a2e 100644
--- a/FastGithub.ReverseProxy/CertGenerator.cs
+++ b/FastGithub.ReverseProxy/CertGenerator.cs
@@ -38,7 +38,7 @@ namespace FastGithub.ReverseProxy
///
///
///
- public static X509Certificate2 Generate(IEnumerable domains, int keySizeBits, DateTime validFrom, DateTime validTo, string caPublicCerPath, string caPrivateKeyPath)
+ public static X509Certificate2 Generate(IEnumerable domains, int keySizeBits, DateTime validFrom, DateTime validTo, string caPublicCerPath, string caPrivateKeyPath, string? password = default)
{
if (File.Exists(caPublicCerPath) == false)
{
@@ -61,7 +61,7 @@ namespace FastGithub.ReverseProxy
var keys = GenerateRsaKeyPair(keySizeBits);
var cert = GenerateCertificate(domains, keys.Public, validFrom, validTo, caSubjectName, caCert.GetPublicKey(), caPrivateKey, null);
- return GeneratePfx(cert, keys.Private, password: null);
+ return GeneratePfx(cert, keys.Private, password);
}
///
diff --git a/FastGithub.ReverseProxy/GithubDnsHttpHandler.cs b/FastGithub.ReverseProxy/GithubDnsHttpHandler.cs
index 64c29da..e042e3d 100644
--- a/FastGithub.ReverseProxy/GithubDnsHttpHandler.cs
+++ b/FastGithub.ReverseProxy/GithubDnsHttpHandler.cs
@@ -1,5 +1,4 @@
using FastGithub.Scanner;
-using Microsoft.Extensions.DependencyInjection;
using System;
using System.Net.Http;
using System.Threading;
@@ -10,7 +9,7 @@ namespace FastGithub.ReverseProxy
///
/// Github的dns解析的httpHandler
/// 使扫描索结果作为github的https请求的域名解析
- ///
+ ///
sealed class GithubDnsHttpHandler : DelegatingHandler
{
private readonly IGithubScanResults scanResults;
@@ -19,9 +18,9 @@ namespace FastGithub.ReverseProxy
/// Github的dns解析的httpHandler
///
///
- ///
- public GithubDnsHttpHandler(IGithubScanResults scanResults, HttpMessageHandler handler)
- : base(handler)
+ ///
+ public GithubDnsHttpHandler(IGithubScanResults scanResults, HttpMessageHandler innerHandler)
+ : base(innerHandler)
{
this.scanResults = scanResults;
}
diff --git a/FastGithub.ReverseProxy/LifetimeHttpHandler.cs b/FastGithub.ReverseProxy/LifetimeHttpHandler.cs
new file mode 100644
index 0000000..14837cb
--- /dev/null
+++ b/FastGithub.ReverseProxy/LifetimeHttpHandler.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Diagnostics;
+using System.Net.Http;
+using System.Threading;
+
+namespace FastGithub.ReverseProxy
+{
+ ///
+ /// 表示自主管理生命周期的的HttpMessageHandler
+ ///
+ [DebuggerDisplay("LifeTime = {lifeTime}")]
+ sealed class LifetimeHttpHandler : DelegatingHandler
+ {
+ ///
+ /// 生命周期
+ ///
+ private readonly TimeSpan lifeTime;
+
+ ///
+ /// Token取消源
+ ///
+ private readonly CancellationTokenSource tokenSource = new CancellationTokenSource();
+
+ ///
+ /// 具有生命周期的HttpHandler
+ ///
+ /// HttpHandler
+ /// 拦截器的生命周期
+ /// 失效回调
+ ///
+ public LifetimeHttpHandler(HttpMessageHandler handler, TimeSpan lifeTime, Action deactivateAction)
+ : base(handler)
+ {
+ if (deactivateAction == null)
+ {
+ throw new ArgumentNullException(nameof(deactivateAction));
+ }
+
+ this.lifeTime = lifeTime;
+
+ this.tokenSource.Token.Register(() =>
+ {
+ this.tokenSource.Dispose();
+ deactivateAction.Invoke(this);
+ }, useSynchronizationContext: false);
+
+ this.tokenSource.CancelAfter(lifeTime);
+ }
+
+ ///
+ /// 这里不释放资源
+ ///
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ }
+ }
+}
diff --git a/FastGithub.ReverseProxy/LifetimeHttpHandlerCleaner.cs b/FastGithub.ReverseProxy/LifetimeHttpHandlerCleaner.cs
new file mode 100644
index 0000000..35c01cb
--- /dev/null
+++ b/FastGithub.ReverseProxy/LifetimeHttpHandlerCleaner.cs
@@ -0,0 +1,144 @@
+using System;
+using System.Collections.Concurrent;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace FastGithub.ReverseProxy
+{
+ ///
+ /// 表示LifetimeHttpHandler清理器
+ ///
+ sealed class LifetimeHttpHandlerCleaner
+ {
+ ///
+ /// 当前监视生命周期的记录的数量
+ ///
+ private int trackingEntryCount = 0;
+
+ ///
+ /// 监视生命周期的记录队列
+ ///
+ private readonly ConcurrentQueue trackingEntries = new();
+
+ ///
+ /// 获取或设置清理的时间间隔
+ /// 默认10s
+ ///
+ public TimeSpan CleanupInterval { get; set; } = TimeSpan.FromSeconds(10d);
+
+ ///
+ /// 添加要清除的httpHandler
+ ///
+ /// httpHandler
+ public void Add(LifetimeHttpHandler handler)
+ {
+ var entry = new TrackingEntry(handler);
+ this.trackingEntries.Enqueue(entry);
+
+ // 从0变为1,要启动清理作业
+ if (Interlocked.Increment(ref this.trackingEntryCount) == 1)
+ {
+ this.StartCleanup();
+ }
+ }
+
+ ///
+ /// 启动清理作业
+ ///
+ private async void StartCleanup()
+ {
+ try
+ {
+ while (true)
+ {
+ await Task
+ .Delay(this.CleanupInterval)
+ .ConfigureAwait(false);
+
+ if (this.Cleanup() == true)
+ {
+ break;
+ }
+ }
+ }
+ catch (Exception)
+ {
+ // 这是应该不可能发生的
+ }
+ }
+
+ ///
+ /// 清理失效的拦截器
+ /// 返回是否完全清理
+ ///
+ ///
+ private bool Cleanup()
+ {
+ var cleanCount = this.trackingEntries.Count;
+ for (var i = 0; i < cleanCount; i++)
+ {
+ this.trackingEntries.TryDequeue(out var entry);
+ Debug.Assert(entry != null);
+
+ if (entry.CanDispose == false)
+ {
+ this.trackingEntries.Enqueue(entry);
+ continue;
+ }
+
+ entry.Dispose();
+ if (Interlocked.Decrement(ref this.trackingEntryCount) == 0)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ ///
+ /// 表示监视生命周期的记录
+ ///
+ private class TrackingEntry : IDisposable
+ {
+ ///
+ /// 用于释放资源的对象
+ ///
+ private readonly IDisposable disposable;
+
+ ///
+ /// 监视对象的弱引用
+ ///
+ private readonly WeakReference weakReference;
+
+ ///
+ /// 获取是否可以释放资源
+ ///
+ ///
+ public bool CanDispose
+ {
+ get => this.weakReference.IsAlive == false;
+ }
+
+ ///
+ /// 监视生命周期的记录
+ ///
+ /// 激活状态的httpHandler
+ public TrackingEntry(LifetimeHttpHandler handler)
+ {
+ this.disposable = handler.InnerHandler!;
+ this.weakReference = new WeakReference(handler);
+ }
+
+ public void Dispose()
+ {
+ try
+ {
+ this.disposable.Dispose();
+ }
+ catch (Exception) { }
+ }
+ }
+ }
+}
diff --git a/FastGithub.ReverseProxy/ListenOptionsHttpsExtensions.cs b/FastGithub.ReverseProxy/ListenOptionsHttpsExtensions.cs
index 40f051e..39cfd8f 100644
--- a/FastGithub.ReverseProxy/ListenOptionsHttpsExtensions.cs
+++ b/FastGithub.ReverseProxy/ListenOptionsHttpsExtensions.cs
@@ -7,6 +7,9 @@ using System.Security.Cryptography.X509Certificates;
namespace FastGithub
{
+ ///
+ /// ListenOptions扩展
+ ///
public static class ListenOptionsHttpsExtensions
{
///
@@ -21,16 +24,16 @@ namespace FastGithub
return listenOptions.UseHttps(https =>
{
var certs = new ConcurrentDictionary();
- https.ServerCertificateSelector = (ctx, domain) =>
- certs.GetOrAdd(domain, d =>
- CertGenerator.Generate(
- new[] { d },
- 2048,
- DateTime.Today.AddYears(-1),
- DateTime.Today.AddYears(1),
- caPublicCerPath,
- caPrivateKeyPath));
+ https.ServerCertificateSelector = (ctx, domain) => certs.GetOrAdd(domain, CreateCert);
});
+
+ X509Certificate2 CreateCert(string domain)
+ {
+ var domains = new[] { domain };
+ var validFrom = DateTime.Today.AddYears(-1);
+ var validTo = DateTime.Today.AddYears(10);
+ return CertGenerator.Generate(domains, 2048, validFrom, validTo, caPublicCerPath, caPrivateKeyPath);
+ }
}
}
}
diff --git a/FastGithub.ReverseProxy/NoneSniHttpClient.cs b/FastGithub.ReverseProxy/NoneSniHttpClient.cs
deleted file mode 100644
index 43f3fe1..0000000
--- a/FastGithub.ReverseProxy/NoneSniHttpClient.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using FastGithub.Scanner;
-using System.IO;
-using System.Net.Http;
-using System.Net.Security;
-using System.Net.Sockets;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace FastGithub.ReverseProxy
-{
- ///
- /// 去掉Sni的HttpClient
- ///
- sealed class NoneSniHttpClient : HttpMessageInvoker
- {
- ///
- /// 去掉Sni的HttpClient
- ///
- ///
- public NoneSniHttpClient(IGithubScanResults githubScanResults)
- : base(CreateNoneSniHttpHandler(githubScanResults), disposeHandler: false)
- {
- }
-
- ///
- /// 去掉Sni的HttpHandler
- ///
- private static HttpMessageHandler CreateNoneSniHttpHandler(IGithubScanResults githubScanResults)
- {
- var httpHandler = new SocketsHttpHandler
- {
- AllowAutoRedirect = false,
- UseCookies = false,
- UseProxy = false,
- ConnectCallback = ConnectCallback
- };
-
- return new GithubDnsHttpHandler(githubScanResults, httpHandler);
- }
-
- ///
- /// 连接回调
- ///
- ///
- ///
- ///
- private static async ValueTask ConnectCallback(SocketsHttpConnectionContext context, CancellationToken cancellationToken)
- {
- var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
- await socket.ConnectAsync(context.DnsEndPoint, cancellationToken);
- var stream = new NetworkStream(socket, ownsSocket: true);
- if (context.InitialRequestMessage.Headers.Host == null)
- {
- return stream;
- }
-
- var sslStream = new SslStream(stream, leaveInnerStreamOpen: false, delegate { return true; });
- await sslStream.AuthenticateAsClientAsync(string.Empty, null, false);
- return sslStream;
- }
- }
-}
diff --git a/FastGithub.ReverseProxy/NoneSniHttpClientFactory.cs b/FastGithub.ReverseProxy/NoneSniHttpClientFactory.cs
new file mode 100644
index 0000000..fd44d17
--- /dev/null
+++ b/FastGithub.ReverseProxy/NoneSniHttpClientFactory.cs
@@ -0,0 +1,96 @@
+using FastGithub.Scanner;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Net.Http;
+using System.Net.Security;
+using System.Net.Sockets;
+
+namespace FastGithub.ReverseProxy
+{
+ ///
+ /// 禁用tls sni的HttpClient工厂
+ ///
+ [Service(ServiceLifetime.Singleton)]
+ sealed class NoneSniHttpClientFactory
+ {
+ private readonly IGithubScanResults githubScanResults;
+
+ ///
+ /// 生命周期
+ ///
+ private readonly TimeSpan lifeTime = TimeSpan.FromMinutes(2d);
+
+ ///
+ /// 具有生命周期的httpHandler延时创建对象
+ ///
+ private Lazy lifeTimeHttpHandlerLazy;
+
+ ///
+ /// HttpHandler清理器
+ ///
+ private readonly LifetimeHttpHandlerCleaner httpHandlerCleaner = new LifetimeHttpHandlerCleaner();
+
+
+ ///
+ /// 禁用tls sni的HttpClient工厂
+ ///
+ ///
+ public NoneSniHttpClientFactory(IGithubScanResults githubScanResults)
+ {
+ this.githubScanResults = githubScanResults;
+ this.lifeTimeHttpHandlerLazy = new Lazy(this.CreateHttpHandler, true);
+ }
+
+ ///
+ /// 创建HttpClient
+ ///
+ ///
+ public HttpMessageInvoker CreateHttpClient()
+ {
+ var handler = this.lifeTimeHttpHandlerLazy.Value;
+ return new HttpMessageInvoker(handler, disposeHandler: false);
+ }
+
+ ///
+ /// 创建具有生命周期控制的httpHandler
+ ///
+ ///
+ private LifetimeHttpHandler CreateHttpHandler()
+ {
+ var noneSniHandler = new SocketsHttpHandler
+ {
+ Proxy = null,
+ UseProxy = false,
+ AllowAutoRedirect = false,
+ ConnectCallback = async (ctx, ct) =>
+ {
+ var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
+ await socket.ConnectAsync(ctx.DnsEndPoint, ct);
+ var stream = new NetworkStream(socket, ownsSocket: true);
+ if (ctx.InitialRequestMessage.Headers.Host == null)
+ {
+ return stream;
+ }
+
+ var sslStream = new SslStream(stream, leaveInnerStreamOpen: false, delegate { return true; });
+ await sslStream.AuthenticateAsClientAsync(string.Empty, null, false);
+ return sslStream;
+ }
+ };
+
+ var dnsHandler = new GithubDnsHttpHandler(this.githubScanResults, noneSniHandler);
+ return new LifetimeHttpHandler(dnsHandler, this.lifeTime, this.OnHttpHandlerDeactivate);
+ }
+
+ ///
+ /// 当有httpHandler失效时
+ ///
+ /// httpHandler
+ private void OnHttpHandlerDeactivate(LifetimeHttpHandler handler)
+ {
+ // 切换激活状态的记录的实例
+ this.lifeTimeHttpHandlerLazy = new Lazy(this.CreateHttpHandler, true);
+ this.httpHandlerCleaner.Add(handler);
+ }
+ }
+}
diff --git a/FastGithub.ReverseProxy/ReverseProxyApplicationBuilderExtensions.cs b/FastGithub.ReverseProxy/ReverseProxyApplicationBuilderExtensions.cs
index 01ac291..885c50b 100644
--- a/FastGithub.ReverseProxy/ReverseProxyApplicationBuilderExtensions.cs
+++ b/FastGithub.ReverseProxy/ReverseProxyApplicationBuilderExtensions.cs
@@ -18,13 +18,15 @@ namespace FastGithub
public static IApplicationBuilder UseGithubReverseProxy(this IApplicationBuilder app)
{
var httpForwarder = app.ApplicationServices.GetRequiredService();
- var httpClient = app.ApplicationServices.GetRequiredService();
+ var httpClientFactory = app.ApplicationServices.GetRequiredService();
app.Use(next => async context =>
{
var hostString = context.Request.Host;
var port = hostString.Port ?? 443;
var destinationPrefix = $"http://{hostString.Host}:{port}/";
+
+ var httpClient = httpClientFactory.CreateHttpClient();
await httpForwarder.SendAsync(context, destinationPrefix, httpClient);
});
diff --git a/FastGithub.ReverseProxy/ReverseProxyServiceCollectionExtensions.cs b/FastGithub.ReverseProxy/ReverseProxyServiceCollectionExtensions.cs
index f9e658a..df95e9e 100644
--- a/FastGithub.ReverseProxy/ReverseProxyServiceCollectionExtensions.cs
+++ b/FastGithub.ReverseProxy/ReverseProxyServiceCollectionExtensions.cs
@@ -1,5 +1,4 @@
-using FastGithub.ReverseProxy;
-using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace FastGithub
@@ -12,13 +11,15 @@ namespace FastGithub
///
/// gitub反向代理
///
- ///
+ ///
+ ///
///
- public static IServiceCollection AddGithubReverseProxy(this IServiceCollection services)
+ public static IServiceCollection AddGithubReverseProxy(this IServiceCollection services, IConfiguration configuration)
{
- services.AddHttpForwarder();
- services.AddSingleton();
- return services;
+ var assembly = typeof(ReverseProxyServiceCollectionExtensions).Assembly;
+ return services
+ .AddServiceAndOptions(assembly, configuration)
+ .AddHttpForwarder();
}
}
}
diff --git a/FastGithub.Scanner/LookupProviders/GithubMetaProvider.cs b/FastGithub.Scanner/LookupProviders/GithubMetaProvider.cs
index 94b0d5b..5191e96 100644
--- a/FastGithub.Scanner/LookupProviders/GithubMetaProvider.cs
+++ b/FastGithub.Scanner/LookupProviders/GithubMetaProvider.cs
@@ -60,7 +60,7 @@ namespace FastGithub.Scanner.LookupProviders
try
{
- var httpClient = this.httpClientFactory.CreateClient(nameof(FastGithub));
+ var httpClient = this.httpClientFactory.CreateClient(nameof(Scanner));
var meta = await GetMetaAsync(httpClient, setting.MetaUri, cancellationToken);
if (meta != null)
{
diff --git a/FastGithub.Scanner/LookupProviders/IPAddressComProvider.cs b/FastGithub.Scanner/LookupProviders/IPAddressComProvider.cs
index 7c4a5b6..82bb46d 100644
--- a/FastGithub.Scanner/LookupProviders/IPAddressComProvider.cs
+++ b/FastGithub.Scanner/LookupProviders/IPAddressComProvider.cs
@@ -57,7 +57,7 @@ namespace FastGithub.Scanner.LookupProviders
return Enumerable.Empty();
}
- var httpClient = this.httpClientFactory.CreateClient(nameof(FastGithub));
+ var httpClient = this.httpClientFactory.CreateClient(nameof(Scanner));
var result = new HashSet();
foreach (var domain in domains)
{
diff --git a/FastGithub.Scanner/ScanMiddlewares/HttpsScanMiddleware.cs b/FastGithub.Scanner/ScanMiddlewares/HttpsScanMiddleware.cs
index 6afe932..8055546 100644
--- a/FastGithub.Scanner/ScanMiddlewares/HttpsScanMiddleware.cs
+++ b/FastGithub.Scanner/ScanMiddlewares/HttpsScanMiddleware.cs
@@ -64,7 +64,7 @@ namespace FastGithub.Scanner.ScanMiddlewares
using var timeoutTokenSource = new CancellationTokenSource(timeout);
using var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(timeoutTokenSource.Token, context.CancellationToken);
- var httpClient = this.httpClientFactory.CreateClient(nameof(FastGithub));
+ var httpClient = this.httpClientFactory.CreateClient(nameof(Scanner));
using var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, linkedTokenSource.Token);
VerifyHttpsResponse(context.Domain, response);
diff --git a/FastGithub.Scanner/ScannerServiceCollectionExtensions.cs b/FastGithub.Scanner/ScannerServiceCollectionExtensions.cs
index e90efb3..5ef2164 100644
--- a/FastGithub.Scanner/ScannerServiceCollectionExtensions.cs
+++ b/FastGithub.Scanner/ScannerServiceCollectionExtensions.cs
@@ -26,8 +26,9 @@ namespace FastGithub
var defaultUserAgent = new ProductInfoHeaderValue(assembly.GetName().Name ?? nameof(FastGithub), assembly.GetName().Version?.ToString());
services
- .AddHttpClient(nameof(FastGithub))
+ .AddHttpClient(nameof(Scanner))
.SetHandlerLifetime(TimeSpan.FromMinutes(5d))
+ .AddHttpMessageHandler()
.ConfigureHttpClient(httpClient =>
{
httpClient.Timeout = TimeSpan.FromSeconds(10d);
@@ -53,8 +54,7 @@ namespace FastGithub
await sslStream.AuthenticateAsClientAsync(string.Empty, null, false);
return sslStream;
}
- })
- .AddHttpMessageHandler();
+ });
return services
.AddMemoryCache()
diff --git a/FastGithub/Program.cs b/FastGithub/Program.cs
index 967a73d..44e844a 100644
--- a/FastGithub/Program.cs
+++ b/FastGithub/Program.cs
@@ -38,7 +38,7 @@ namespace FastGithub
{
services.AddAppUpgrade();
services.AddGithubDns(ctx.Configuration);
- services.AddGithubReverseProxy();
+ services.AddGithubReverseProxy(ctx.Configuration);
services.AddGithubScanner(ctx.Configuration);
})
.ConfigureWebHostDefaults(web =>
@@ -50,9 +50,7 @@ namespace FastGithub
web.UseKestrel(kestrel =>
{
- const string caPublicCerPath = "FastGithub_CA.cer";
- const string caPrivateKeyPath = "FastGithub_CA.key";
- kestrel.ListenLocalhost(443, listen => listen.UseGithubHttps(caPublicCerPath, caPrivateKeyPath));
+ kestrel.ListenAnyIP(443, listen => listen.UseGithubHttps("FastGithub_CA.cer", "FastGithub_CA.key"));
});
});
}
diff --git a/FastGithub/appsettings.json b/FastGithub/appsettings.json
index ee92ffe..1e4debe 100644
--- a/FastGithub/appsettings.json
+++ b/FastGithub/appsettings.json
@@ -2,7 +2,8 @@
"Dns": {
"UpStream": "114.114.114.114", // dns
"GithubTTL": "00:10:00", // githubĴʱ
- "SetToLocalMachine": true // Ƿñʹôdns(֧windows)
+ "SetToLocalMachine": true, // Ƿñʹôdns(֧windows)
+ "UseReverseProxy": true // Ƿʹ÷github
},
"Lookup": { // ip
"IPAddressComProvider": {