2
0
xljiulang 4 жил өмнө
parent
commit
e0d4d13621

+ 3 - 2
FastGithub.ReverseProxy/ReverseProxyApplicationBuilderExtensions.cs

@@ -13,11 +13,12 @@ namespace FastGithub
         /// 使用https反向代理中间件
         /// </summary>
         /// <param name="app"></param>
+        /// <param name="fallbackFile"></param>
         /// <returns></returns>
-        public static IApplicationBuilder UseHttpsReverseProxy(this IApplicationBuilder app)
+        public static IApplicationBuilder UseHttpsReverseProxy(this IApplicationBuilder app, string fallbackFile)
         {
             var middleware = app.ApplicationServices.GetRequiredService<ReverseProxyMiddleware>();
-            return app.Use(next => context => middleware.InvokeAsync(context));
+            return app.Use(next => context => middleware.InvokeAsync(context, fallbackFile));
         }
     }
 }

+ 4 - 6
FastGithub.ReverseProxy/ReverseProxyMiddleware.cs

@@ -36,17 +36,15 @@ namespace FastGithub.ReverseProxy
         /// 处理请求
         /// </summary>
         /// <param name="context"></param>
+        /// <param name="fallbackFile"></param>
         /// <returns></returns>
-        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
             {

+ 4 - 1
FastGithub/FastGithub.csproj

@@ -38,7 +38,10 @@
 		<None Update="FastGithub.key">
 			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
 		</None>
-		<None Update="使用说明.MD">
+		<None Update="README.html">
+		  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+		</None>
+		<None Update="README.md">
 			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
 		</None>
 	</ItemGroup>

+ 1 - 1
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"));
                 });
         }

+ 4 - 5
FastGithub/使用说明.MD → 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

+ 40 - 0
FastGithub/README.html

@@ -0,0 +1,40 @@
+<!doctype html>
+<html lang="zh-CN">
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <link rel="stylesheet" href=" https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.10/dist/css/bootstrap.min.css">
+    <title>FastGithub--github加速神器</title>
+</head>
+
+<body>
+    <div class="container">
+        <h1>FastGithub</h1>
+
+        <p>github加速神器</p>
+
+        <h3>本机使用[推荐]</h3>
+
+        <ul><li>运行FastGithub程序,自动本机的网络适配器的dns会为127.0.0.1和安装FastGithub.cer</li><li>如果网络适配器的dns没有变成127.0.0.1,请手工修改网络适配器的dns</li><li>如果浏览器提示无效的证书,请手工安装FastGithub.cer到<code>将所有的证书都放入下载存储\受信任的根证书颁发机构</code></li></ul>
+
+        <h3>局域网服务器使用</h3>
+
+        <ul><li>在局域网服务器运行FastGithub程序</li><li>手工修改你电脑的网络适配器的dns,值为局域网服务器的ip</li><li>在你的电脑安装FastGithub.cer到<code>将所有的证书都放入下载存储\受信任的根证书颁发机构</code></li></ul>
+
+        <h3>以windows服务运行</h3>
+
+        <ul><li>FastGithub.exe start // 安装并启动服务</li><li>FastGithub.exe stop  // 卸载并删除服务</li></ul>
+
+        <h3>git ssl验证不通过</h3>
+
+        <p>
+            使用FastGithub之后,git请求时会遇到SSL certificate problem: unable to get local issuer certificate
+            需要关闭git的证书验证:
+            <code>
+                git config --global http.sslverify false
+            </code>
+        </p>
+    </div>
+</body>
+</html>