diff --git a/FastGithub.ReverseProxy/ReverseProxyApplicationBuilderExtensions.cs b/FastGithub.ReverseProxy/ReverseProxyApplicationBuilderExtensions.cs index afa3ae4..3ab048c 100644 --- a/FastGithub.ReverseProxy/ReverseProxyApplicationBuilderExtensions.cs +++ b/FastGithub.ReverseProxy/ReverseProxyApplicationBuilderExtensions.cs @@ -13,11 +13,12 @@ namespace FastGithub /// 使用https反向代理中间件 /// /// + /// /// - public static IApplicationBuilder UseHttpsReverseProxy(this IApplicationBuilder app) + public static IApplicationBuilder UseHttpsReverseProxy(this IApplicationBuilder app, string fallbackFile) { var middleware = app.ApplicationServices.GetRequiredService(); - return app.Use(next => context => middleware.InvokeAsync(context)); + return app.Use(next => context => middleware.InvokeAsync(context, fallbackFile)); } } } diff --git a/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs b/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs index 5ab27ec..0aafbf6 100644 --- a/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs +++ b/FastGithub.ReverseProxy/ReverseProxyMiddleware.cs @@ -36,17 +36,15 @@ namespace FastGithub.ReverseProxy /// 处理请求 /// /// + /// /// - public async Task InvokeAsync(HttpContext context) + public async Task InvokeAsync(HttpContext context, string fallbackFile) { var host = context.Request.Host.Host; if (this.fastGithubConfig.TryGetDomainConfig(host, out var domainConfig) == false) { - await context.Response.WriteAsJsonAsync(new - { - error = ForwarderError.NoAvailableDestinations.ToString(), - message = $"不支持https反向代理{host}这个域名" - }); + context.Response.ContentType = "text/html"; + await context.Response.SendFileAsync(fallbackFile); } else { diff --git a/FastGithub/FastGithub.csproj b/FastGithub/FastGithub.csproj index 5ba7031..f28bfe4 100644 --- a/FastGithub/FastGithub.csproj +++ b/FastGithub/FastGithub.csproj @@ -38,7 +38,10 @@ PreserveNewest - + + PreserveNewest + + PreserveNewest diff --git a/FastGithub/Program.cs b/FastGithub/Program.cs index 9e8fe5c..eeca4ab 100644 --- a/FastGithub/Program.cs +++ b/FastGithub/Program.cs @@ -41,7 +41,7 @@ namespace FastGithub }) .ConfigureWebHostDefaults(web => { - web.Configure(app => app.UseHttpsReverseProxy()); + web.Configure(app => app.UseHttpsReverseProxy("README.html")); web.UseKestrel(kestrel => kestrel.ListenHttpsReverseProxy("FastGithub.cer", "FastGithub.key")); }); } diff --git a/FastGithub/使用说明.MD b/FastGithub/README.MD similarity index 69% rename from FastGithub/使用说明.MD rename to FastGithub/README.MD index 68244b2..a9fd2f5 100644 --- a/FastGithub/使用说明.MD +++ b/FastGithub/README.MD @@ -1,5 +1,5 @@ # FastGithub -github定制版的dns服务,解析github最优的ip +github加速神器 ### 本机使用[推荐] * 运行FastGithub程序,自动本机的网络适配器的dns会为127.0.0.1和安装FastGithub.cer @@ -12,12 +12,11 @@ github定制版的dns服务,解析github最优的ip * 在你的电脑安装FastGithub.cer到`将所有的证书都放入下载存储\受信任的根证书颁发机构` ### 以windows服务运行 -运行cmd,键入如下命令,其中D:\Softs为软件实际目录 -* D:\Softs\FastGithub.exe start // 安装并启动服务 -* D:\Softs\FastGithub.exe stop // 卸载并删除服务 +* FastGithub.exe start // 安装并启动服务 +* FastGithub.exe stop // 卸载并删除服务 ### git ssl验证不通过 -使用https反向代理之后,git请求时会遇到SSL certificate problem: unable to get local issuer certificate +使用FastGithub之后,git请求时会遇到SSL certificate problem: unable to get local issuer certificate 需要关闭git的证书验证: ``` git config --global http.sslverify false diff --git a/FastGithub/README.html b/FastGithub/README.html new file mode 100644 index 0000000..660f516 --- /dev/null +++ b/FastGithub/README.html @@ -0,0 +1,40 @@ + + + + + + + + FastGithub--github加速神器 + + + +
+

FastGithub

+ +

github加速神器

+ +

本机使用[推荐]

+ +
  • 运行FastGithub程序,自动本机的网络适配器的dns会为127.0.0.1和安装FastGithub.cer
  • 如果网络适配器的dns没有变成127.0.0.1,请手工修改网络适配器的dns
  • 如果浏览器提示无效的证书,请手工安装FastGithub.cer到将所有的证书都放入下载存储\受信任的根证书颁发机构
+ +

局域网服务器使用

+ +
  • 在局域网服务器运行FastGithub程序
  • 手工修改你电脑的网络适配器的dns,值为局域网服务器的ip
  • 在你的电脑安装FastGithub.cer到将所有的证书都放入下载存储\受信任的根证书颁发机构
+ +

以windows服务运行

+ +
  • FastGithub.exe start // 安装并启动服务
  • FastGithub.exe stop // 卸载并删除服务
+ +

git ssl验证不通过

+ +

+ 使用FastGithub之后,git请求时会遇到SSL certificate problem: unable to get local issuer certificate + 需要关闭git的证书验证: + + git config --global http.sslverify false + +

+
+ + \ No newline at end of file