diff --git a/FastGithub/Controllers/HomeController.cs b/FastGithub/Controllers/HomeController.cs new file mode 100644 index 0000000..dc5fafd --- /dev/null +++ b/FastGithub/Controllers/HomeController.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Threading.Tasks; + +namespace FastGithub.Controllers +{ + public class HomeController : Controller + { + /// + /// 首页 + /// + /// + public IActionResult Index() + { + return View(); + } + + /// + /// 下载CA证书 + /// + /// + public async Task Cert() + { + var certFile = $"CACert/{Environment.MachineName}.cer"; + this.Response.ContentType = "application/x-x509-ca-cert"; + this.Response.Headers.Add("Content-Disposition", $"attachment;filename={nameof(FastGithub)}.cer"); + await this.Response.SendFileAsync(certFile); + return new EmptyResult(); + } + } +} diff --git a/FastGithub/FastGithub.csproj b/FastGithub/FastGithub.csproj index 8dae23c..a17c3ac 100644 --- a/FastGithub/FastGithub.csproj +++ b/FastGithub/FastGithub.csproj @@ -25,10 +25,7 @@ PreserveNewest - - - PreserveNewest - + diff --git a/FastGithub/Program.cs b/FastGithub/Program.cs index e9c6707..d297bdf 100644 --- a/FastGithub/Program.cs +++ b/FastGithub/Program.cs @@ -1,8 +1,5 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using System.IO; @@ -41,30 +38,10 @@ namespace FastGithub c.AddJsonFile(Path.GetFileName(jsonFile), true, true); } }) - .ConfigureServices((ctx, services) => + .ConfigureWebHostDefaults(webBuilder => { - services.AddDnsServer(); - services.AddDomainResolve(); - services.AddHttpClient(); - services.AddReverseProxy(); - services.AddAppUpgrade(); - services.AddSingleton(); - services.Configure(ctx.Configuration.GetSection(nameof(FastGithub))); - }) - .ConfigureWebHostDefaults(web => - { - web.Configure(app => - { - app.UseRequestLogging(); - app.UseHttpsReverseProxy(); - app.UseRouting(); - app.UseEndpoints(endpoints => endpoints.Map("/", async context => - { - context.Response.ContentType = "text/html"; - await context.Response.SendFileAsync("README.html"); - })); - }); - web.UseKestrel(kestrel => kestrel.ListenHttpsReverseProxy()); + webBuilder.UseStartup(); + webBuilder.UseKestrel(kestrel => kestrel.ListenHttpsReverseProxy()); }); } } diff --git a/FastGithub/README.MD b/FastGithub/README.MD deleted file mode 100644 index 3d7b188..0000000 --- a/FastGithub/README.MD +++ /dev/null @@ -1,36 +0,0 @@ -# FastGithub -github加速神器 - -### 运行方式 -#### windows本机 -* 双击运行FastGithub.exe程序 -* 程序自动设置网络适配器的主DNS为127.0.0.1 -* 程序自动安装CA证书到`将所有的证书都放入下载存储\受信任的根证书颁发机构` -* FastGithub.exe start // 作为windows服务安装并启动 -* FastGithub.exe stop // 作为windows服务卸载并删除 - -#### linux本机 -* 执行./FastGithub运行程序 -* 手工将你的电脑的主DNS设置为127.0.0.1 -* 手工在你的电脑安装CA证书到系统根证书存储区 - -#### 局域网服务器 -* 在局域网服务器运行FastGithub程序 -* 手工将你的电脑的主DNS设置为局域网服务器的ip -* 手工在你的电脑安装CA证书到系统根证书存储区 - - -### 证书验证 -#### git ssl验证不通过 -使用FastGithub之后,git请求时会遇到SSL certificate problem: unable to get local issuer certificate -需要关闭git的证书验证: -``` -git config --global http.sslverify false -``` - -### 配置文件 -#### 主配置文件 -appsettings.json为主配置文件,里面有dns配置和域名的配置示例。 - -#### 子配置文件 -appsettings.*.json为子配置文件,默认有github和stackoverflow的配置,新增子配置文件后需要重启FastGithub才生效。 \ No newline at end of file diff --git a/FastGithub/README.html b/FastGithub/README.html deleted file mode 100644 index 8e75f7d..0000000 --- a/FastGithub/README.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - FastGithub--github加速神器 - - - -
- -

FastGithub

- -

github加速神器

- -

运行方式

- -

windows本机

- -
    -
  • 双击运行FastGithub.exe程序
  • -
  • 程序自动设置网络适配器的主DNS为127.0.0.1
  • -
  • 程序自动安装CA证书到将所有的证书都放入下载存储\受信任的根证书颁发机构
  • -
  • FastGithub.exe start // 作为windows服务安装并启动
  • -
  • FastGithub.exe stop // 作为windows服务卸载并删除
  • -
- -

linux本机

- -
    -
  • 执行./FastGithub运行程序
  • -
  • 手工将你的电脑的主DNS设置为127.0.0.1
  • -
  • 手工在你的电脑安装CA证书到系统根证书存储区
  • -
- -

局域网服务器

- -
    -
  • 在局域网服务器运行FastGithub程序
  • -
  • 手工将你的电脑的主DNS设置为局域网服务器的ip
  • -
  • 手工在你的电脑安装CA证书到系统根证书存储区
  • -
- -

证书验证

- -

git ssl验证不通过

- -

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

- -

配置文件

- -

主配置文件

- -

appsettings.json为主配置文件,里面有dns配置和域名的配置示例。

- -

子配置文件

- -

appsettings.*.json为子配置文件,默认有github和stackoverflow的配置,新增子配置文件后需要重启FastGithub才生效。

- -
- - \ No newline at end of file diff --git a/FastGithub/Startup.cs b/FastGithub/Startup.cs new file mode 100644 index 0000000..012c8dd --- /dev/null +++ b/FastGithub/Startup.cs @@ -0,0 +1,58 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace FastGithub +{ + /// + /// + /// + public class Startup + { + public IConfiguration Configuration { get; } + + /// + /// + /// + /// + public Startup(IConfiguration configuration) + { + this.Configuration = configuration; + } + + /// + /// ÷ + /// + /// + public void ConfigureServices(IServiceCollection services) + { + services.AddDnsServer(); + services.AddDomainResolve(); + services.AddHttpClient(); + services.AddReverseProxy(); + services.AddAppUpgrade(); + services.AddSingleton(); + services.Configure(this.Configuration.GetSection(nameof(FastGithub))); + + services.AddControllersWithViews(); + services.AddRouting(c => c.LowercaseUrls = true); + } + + /// + /// м + /// + /// + public void Configure(IApplicationBuilder app) + { + app.UseRequestLogging(); + app.UseHttpsReverseProxy(); + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllerRoute( + name: "default", + pattern: "{controller=Home}/{action=Index}/{id?}"); + }); + } + } +} diff --git a/FastGithub/Views/Home/Index.cshtml b/FastGithub/Views/Home/Index.cshtml new file mode 100644 index 0000000..b307f77 --- /dev/null +++ b/FastGithub/Views/Home/Index.cshtml @@ -0,0 +1,97 @@ + +@{ + Layout = null; +} + + + + + + + + + FastGithub--github加速神器 + + + + + +
+ +

FastGithub

+

github加速神器

+ +

CA证书

+

+ 你可能需要下载FastGithub自颁发的CA证书,根据设备所使用的平台要求,导入到受信任的受信任的根证书颁发机构或浏览器 +

+ +

运行方式

+
+
+
+
windows本机
+
+

x64系统

+

双击运行FastGithub.exe程序

+

FastGithub.exe start // 以windows服务安装并启动

+

FastGithub.exe stop // 以windows服务卸载并删除

+
+
+
+ +
+
+
linux本机
+
+

x64系统

+

执行./FastGithub

+

手工修改resolv.conf的第一条记录为127.0.0.1

+

手工安装CA证书到受信任的根证书颁发机构

+
+
+
+ +
+
+
局域网服务器
+
+

x64系统

+

在局域网服务器运行FastGithub程序

+

手工将你电脑的主DNS设置为局域网服务器的ip

+

手工在你电脑安装CA证书到受信任的根证书颁发机构

+
+
+
+
+ +

证书验证

+
+
+
+
git ssl验证
+
+

+ git pull或push时会遇到SSL certificate problem: unable to get local issuer certificate +

+

+ 需要关闭git的证书验证: + git config --global http.sslverify false +

+
+
+
+ +
+ +
+ + diff --git a/FastGithub/Views/_ViewImports.cshtml b/FastGithub/Views/_ViewImports.cshtml new file mode 100644 index 0000000..7390d10 --- /dev/null +++ b/FastGithub/Views/_ViewImports.cshtml @@ -0,0 +1,2 @@ +@using FastGithub +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers \ No newline at end of file diff --git a/FastGithub/Views/_ViewStart.cshtml b/FastGithub/Views/_ViewStart.cshtml new file mode 100644 index 0000000..a5f1004 --- /dev/null +++ b/FastGithub/Views/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "_Layout"; +}