From 519556203c48e19d4081b01a69b4409235853e0e Mon Sep 17 00:00:00 2001 From: xljiulang <366193849@qq.com> Date: Sun, 18 Jul 2021 01:37:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B6=85=E6=97=B6=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.Core/DomainConfig.cs | 5 ++++ .../ReverseProxyMiddleware.cs | 4 ++- FastGithub/appsettings.json | 28 ++++++++----------- README.md | 3 +- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/FastGithub.Core/DomainConfig.cs b/FastGithub.Core/DomainConfig.cs index 5c6ab09..7127059 100644 --- a/FastGithub.Core/DomainConfig.cs +++ b/FastGithub.Core/DomainConfig.cs @@ -12,6 +12,11 @@ namespace FastGithub /// public bool TlsSni { get; set; } + /// + /// 请求超时时长 + /// + public TimeSpan? Timeout { get; set; } + /// /// 目的地 /// 格式为相对或绝对uri diff --git a/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs b/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs index fd974b4..6e52e51 100644 --- a/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs +++ b/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs @@ -47,11 +47,13 @@ namespace FastGithub.ReverseProxy } var destinationPrefix = GetDestinationPrefix(host, domainConfig.Destination); + var requestConfig = new ForwarderRequestConfig { Timeout = domainConfig.Timeout }; + var httpClient = domainConfig.TlsSni ? new HttpMessageInvoker(this.sniHttpClientHanlder, disposeHandler: false) : new HttpMessageInvoker(this.noSniHttpClientHanlder, disposeHandler: false); - var error = await httpForwarder.SendAsync(context, destinationPrefix, httpClient); + var error = await httpForwarder.SendAsync(context, destinationPrefix, httpClient, requestConfig); await ResponseErrorAsync(context, error); } diff --git a/FastGithub/appsettings.json b/FastGithub/appsettings.json index c13e35a..0020d7f 100644 --- a/FastGithub/appsettings.json +++ b/FastGithub/appsettings.json @@ -8,38 +8,32 @@ "IPAddress": "114.114.114.114", "Port": 53 }, - "DomainConfigs": { // *ʾ0ַ + "DomainConfigs": { // *ʾ0ַ "github.com": { - "TlsSni": false, - "Destination": null + "TlsSni": false, // ָʾtlsʱǷSNIĬΪfalse, + "Timeout": null, // ʱʱʽΪ"00:02:00"ĬΪnull + "Destination": null // ĿĵأʽΪԻUriĬnull }, "githubstatus.com": { - "TlsSni": false, - "Destination": null + "TlsSni": false }, "*.github.com": { - "TlsSni": false, - "Destination": null + "TlsSni": false }, "*.github.io": { - "TlsSni": false, - "Destination": null + "TlsSni": false }, "*.githubapp.com": { - "TlsSni": false, - "Destination": null + "TlsSni": false }, "*.githubassets.com": { - "TlsSni": false, - "Destination": null + "TlsSni": false }, "*.githubusercontent.com": { - "TlsSni": false, - "Destination": null + "TlsSni": false }, "*github*.s3.amazonaws.com": { - "TlsSni": false, - "Destination": null + "TlsSni": false }, "ajax.googleapis.com": { "TlsSni": true, diff --git a/README.md b/README.md index 8d97cfa..e214a1a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ github加速神器 ### 加速原理 * 修改本机的dns服务指向FastGithub自身 * 解析匹配的域名为FastGithub自身的ip -* 请求信任的dns服务(dnscrypt-proxy)获取域名的ip并进行无SNI的https反向代理 +* 请求不受污染的dns服务(dnscrypt-proxy)获取域名的ip +* 使用得到的ip进行无或有SNI的https反向代理 ### 程序下载 [下载最新发布版本](https://gitee.com/jiulang/fast-github)