使用MVC
This commit is contained in:
parent
506c141808
commit
02c051511d
32
FastGithub/Controllers/HomeController.cs
Normal file
32
FastGithub/Controllers/HomeController.cs
Normal file
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 首页
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下载CA证书
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IActionResult> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -26,9 +26,6 @@
|
|||||||
<None Update="appsettings.*">
|
<None Update="appsettings.*">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="README.*">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
@ -41,30 +38,10 @@ namespace FastGithub
|
|||||||
c.AddJsonFile(Path.GetFileName(jsonFile), true, true);
|
c.AddJsonFile(Path.GetFileName(jsonFile), true, true);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.ConfigureServices((ctx, services) =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
{
|
{
|
||||||
services.AddDnsServer();
|
webBuilder.UseStartup<Startup>();
|
||||||
services.AddDomainResolve();
|
webBuilder.UseKestrel(kestrel => kestrel.ListenHttpsReverseProxy());
|
||||||
services.AddHttpClient();
|
|
||||||
services.AddReverseProxy();
|
|
||||||
services.AddAppUpgrade();
|
|
||||||
services.AddSingleton<FastGithubConfig>();
|
|
||||||
services.Configure<FastGithubOptions>(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());
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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才生效。
|
|
||||||
@ -1,70 +0,0 @@
|
|||||||
<!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>
|
|
||||||
|
|
||||||
<h4>windows本机</h4>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>双击运行FastGithub.exe程序</li>
|
|
||||||
<li>程序自动设置网络适配器的主DNS为127.0.0.1</li>
|
|
||||||
<li>程序自动安装CA证书到<code>将所有的证书都放入下载存储\受信任的根证书颁发机构</code> </li>
|
|
||||||
<li>FastGithub.exe start // 作为windows服务安装并启动</li>
|
|
||||||
<li>FastGithub.exe stop // 作为windows服务卸载并删除</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h4>linux本机</h4>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>执行./FastGithub运行程序</li>
|
|
||||||
<li>手工将你的电脑的主DNS设置为127.0.0.1</li>
|
|
||||||
<li>手工在你的电脑安装CA证书到系统根证书存储区</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h4>局域网服务器</h4>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>在局域网服务器运行FastGithub程序</li>
|
|
||||||
<li>手工将你的电脑的主DNS设置为局域网服务器的ip</li>
|
|
||||||
<li>手工在你的电脑安装CA证书到系统根证书存储区</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>证书验证</h3>
|
|
||||||
|
|
||||||
<h4>git ssl验证不通过</h4>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
使用FastGithub之后,git请求时会遇到SSL certificate problem: unable to get local issuer certificate
|
|
||||||
需要关闭git的证书验证:
|
|
||||||
<code>
|
|
||||||
git config --global http.sslverify false
|
|
||||||
</code>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h3>配置文件</h3>
|
|
||||||
|
|
||||||
<h4>主配置文件</h4>
|
|
||||||
|
|
||||||
<p>appsettings.json为主配置文件,里面有dns配置和域名的配置示例。</p>
|
|
||||||
|
|
||||||
<h4>子配置文件</h4>
|
|
||||||
|
|
||||||
<p>appsettings.*.json为子配置文件,默认有github和stackoverflow的配置,新增子配置文件后需要重启FastGithub才生效。</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
58
FastGithub/Startup.cs
Normal file
58
FastGithub/Startup.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace FastGithub
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 启动项
|
||||||
|
/// </summary>
|
||||||
|
public class Startup
|
||||||
|
{
|
||||||
|
public IConfiguration Configuration { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启动项
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configuration"></param>
|
||||||
|
public Startup(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
this.Configuration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置服务
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddDnsServer();
|
||||||
|
services.AddDomainResolve();
|
||||||
|
services.AddHttpClient();
|
||||||
|
services.AddReverseProxy();
|
||||||
|
services.AddAppUpgrade();
|
||||||
|
services.AddSingleton<FastGithubConfig>();
|
||||||
|
services.Configure<FastGithubOptions>(this.Configuration.GetSection(nameof(FastGithub)));
|
||||||
|
|
||||||
|
services.AddControllersWithViews();
|
||||||
|
services.AddRouting(c => c.LowercaseUrls = true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置中间件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="app"></param>
|
||||||
|
public void Configure(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
app.UseRequestLogging();
|
||||||
|
app.UseHttpsReverseProxy();
|
||||||
|
app.UseRouting();
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
|
{
|
||||||
|
endpoints.MapControllerRoute(
|
||||||
|
name: "default",
|
||||||
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
97
FastGithub/Views/Home/Index.cshtml
Normal file
97
FastGithub/Views/Home/Index.cshtml
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
|
||||||
|
@{
|
||||||
|
Layout = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
<!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>
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
.os {
|
||||||
|
text-align: center;
|
||||||
|
background-color: #ddd;
|
||||||
|
padding: 20px 0;
|
||||||
|
font-size: 32px;
|
||||||
|
color: #606060;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<h1>FastGithub</h1>
|
||||||
|
<p>github加速神器</p>
|
||||||
|
|
||||||
|
<h3>CA证书</h3>
|
||||||
|
<p>
|
||||||
|
你可能需要<a target="_blank" href="/home/cert">下载FastGithub自颁发的CA证书</a>,根据设备所使用的平台要求,导入到受信任的受信任的根证书颁发机构或浏览器
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h3>运行方式</h3>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6 col-md-4">
|
||||||
|
<div class="thumbnail">
|
||||||
|
<div class="os">windows本机</div>
|
||||||
|
<div class="caption">
|
||||||
|
<h4>x64系统</h4>
|
||||||
|
<p>双击运行FastGithub.exe程序</p>
|
||||||
|
<p><code>FastGithub.exe start</code> // 以windows服务安装并启动</p>
|
||||||
|
<p><code>FastGithub.exe stop</code> // 以windows服务卸载并删除</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-sm-6 col-md-4">
|
||||||
|
<div class="thumbnail">
|
||||||
|
<div class="os">linux本机</div>
|
||||||
|
<div class="caption">
|
||||||
|
<h4>x64系统</h4>
|
||||||
|
<p>执行<code>./FastGithub</code></p>
|
||||||
|
<p>手工修改resolv.conf的第一条记录为127.0.0.1</p>
|
||||||
|
<p>手工安装CA证书到受信任的根证书颁发机构</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-sm-6 col-md-4">
|
||||||
|
<div class="thumbnail">
|
||||||
|
<div class="os">局域网服务器</div>
|
||||||
|
<div class="caption">
|
||||||
|
<h4>x64系统</h4>
|
||||||
|
<p>在局域网服务器运行FastGithub程序</p>
|
||||||
|
<p>手工将你电脑的主DNS设置为局域网服务器的ip</p>
|
||||||
|
<p>手工在你电脑安装CA证书到受信任的根证书颁发机构</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>证书验证</h3>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6 col-md-4">
|
||||||
|
<div class="thumbnail">
|
||||||
|
<div class="os">git ssl验证</div>
|
||||||
|
<div class="caption">
|
||||||
|
<p>
|
||||||
|
git pull或push时会遇到SSL certificate problem: unable to get local issuer certificate
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<span>需要关闭git的证书验证:</span>
|
||||||
|
<code>git config --global http.sslverify false</code>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
2
FastGithub/Views/_ViewImports.cshtml
Normal file
2
FastGithub/Views/_ViewImports.cshtml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@using FastGithub
|
||||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
3
FastGithub/Views/_ViewStart.cshtml
Normal file
3
FastGithub/Views/_ViewStart.cshtml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@{
|
||||||
|
Layout = "_Layout";
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user