项目重命名
This commit is contained in:
parent
3af5928096
commit
002ad37e3b
@ -1,4 +1,4 @@
|
||||
using FastGithub.ReverseProxy;
|
||||
using FastGithub.HttpServer;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
@ -19,7 +19,7 @@ using System.Net;
|
||||
using System.Text;
|
||||
using X509Certificate2 = System.Security.Cryptography.X509Certificates.X509Certificate2;
|
||||
|
||||
namespace FastGithub.ReverseProxy
|
||||
namespace FastGithub.HttpServer
|
||||
{
|
||||
/// <summary>
|
||||
/// 证书生成器
|
||||
@ -9,14 +9,14 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace FastGithub.ReverseProxy
|
||||
namespace FastGithub.HttpServer
|
||||
{
|
||||
/// <summary>
|
||||
/// 证书服务
|
||||
/// </summary>
|
||||
sealed class CertService
|
||||
{
|
||||
private const string CACert_PATH = "cacert";
|
||||
private const string CACERT_PATH = "cacert";
|
||||
private const int KEY_SIZE_BITS = 2048;
|
||||
private readonly IMemoryCache serverCertCache;
|
||||
private readonly ILogger<CertService> logger;
|
||||
@ -25,12 +25,12 @@ namespace FastGithub.ReverseProxy
|
||||
/// <summary>
|
||||
/// 获取证书文件路径
|
||||
/// </summary>
|
||||
public string CaCerFilePath { get; } = $"{CACert_PATH}/fastgithub.cer";
|
||||
public string CaCerFilePath { get; } = $"{CACERT_PATH}/fastgithub.cer";
|
||||
|
||||
/// <summary>
|
||||
/// 获取私钥文件路径
|
||||
/// </summary>
|
||||
public string CaKeyFilePath { get; } = $"{CACert_PATH}/fastgithub.key";
|
||||
public string CaKeyFilePath { get; } = $"{CACERT_PATH}/fastgithub.key";
|
||||
|
||||
/// <summary>
|
||||
/// 证书服务
|
||||
@ -42,8 +42,7 @@ namespace FastGithub.ReverseProxy
|
||||
{
|
||||
this.serverCertCache = serverCertCache;
|
||||
this.logger = logger;
|
||||
|
||||
Directory.CreateDirectory(CACert_PATH);
|
||||
Directory.CreateDirectory(CACERT_PATH);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -11,7 +11,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yarp.ReverseProxy.Forwarder;
|
||||
|
||||
namespace FastGithub.ReverseProxy
|
||||
namespace FastGithub.HttpServer
|
||||
{
|
||||
/// <summary>
|
||||
/// http代理中间件
|
||||
@ -96,8 +96,9 @@ namespace FastGithub.ReverseProxy
|
||||
/// <returns></returns>
|
||||
private async Task<EndPoint> GetTargetEndPointAsync(HttpRequest request)
|
||||
{
|
||||
const int HTTPS_PORT = 443;
|
||||
var targetHost = request.Host.Host;
|
||||
var targetPort = request.Host.Port ?? 443;
|
||||
var targetPort = request.Host.Port ?? HTTPS_PORT;
|
||||
|
||||
if (IPAddress.TryParse(targetHost, out var address) == true)
|
||||
{
|
||||
@ -110,7 +111,7 @@ namespace FastGithub.ReverseProxy
|
||||
}
|
||||
|
||||
// https,走反向代理中间人
|
||||
if (targetPort == 443)
|
||||
if (targetPort == HTTPS_PORT)
|
||||
{
|
||||
return new IPEndPoint(IPAddress.Loopback, HttpsReverseProxyPort.Value);
|
||||
}
|
||||
@ -6,7 +6,7 @@ using System;
|
||||
using System.Threading.Tasks;
|
||||
using Yarp.ReverseProxy.Forwarder;
|
||||
|
||||
namespace FastGithub.ReverseProxy
|
||||
namespace FastGithub.HttpServer
|
||||
{
|
||||
/// <summary>
|
||||
/// 反向代理中间件
|
||||
@ -2,7 +2,7 @@
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace FastGithub.ReverseProxy
|
||||
namespace FastGithub.HttpServer
|
||||
{
|
||||
/// <summary>
|
||||
/// https反向代理端口
|
||||
@ -1,5 +1,5 @@
|
||||
using FastGithub.Configuration;
|
||||
using FastGithub.ReverseProxy;
|
||||
using FastGithub.HttpServer;
|
||||
using Microsoft.AspNetCore.Connections;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
@ -41,7 +41,7 @@ namespace FastGithub
|
||||
|
||||
var logger = kestrel.GetLogger();
|
||||
kestrel.Listen(IPAddress.Loopback, httpProxyPort);
|
||||
logger.LogInformation($"已监听http://127.0.0.1:{httpProxyPort},http代理服务启动完成");
|
||||
logger.LogInformation($"已监听http://{IPAddress.Loopback}:{httpProxyPort},http代理服务启动完成");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -54,7 +54,7 @@ namespace FastGithub
|
||||
if (LocalMachine.CanListenTcp(SSH_PORT) == true)
|
||||
{
|
||||
kestrel.Listen(IPAddress.Loopback, SSH_PORT, listen => listen.UseConnectionHandler<SshReverseProxyHandler>());
|
||||
kestrel.GetLogger().LogInformation($"已监听ssh://127.0.0.1:{SSH_PORT},github的ssh反向代理服务启动完成");
|
||||
kestrel.GetLogger().LogInformation($"已监听ssh://{IPAddress.Loopback}:{SSH_PORT},github的ssh反向代理服务启动完成");
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ namespace FastGithub
|
||||
if (LocalMachine.CanListenTcp(HTTP_PORT) == true)
|
||||
{
|
||||
kestrel.Listen(IPAddress.Loopback, HTTP_PORT);
|
||||
kestrel.GetLogger().LogInformation($"已监听http://127.0.0.1:{HTTP_PORT},http反向代理服务启动完成");
|
||||
kestrel.GetLogger().LogInformation($"已监听http://{IPAddress.Loopback}:{HTTP_PORT},http反向代理服务启动完成");
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ namespace FastGithub
|
||||
if (httpsPort == 443)
|
||||
{
|
||||
var logger = kestrel.GetLogger();
|
||||
logger.LogInformation($"已监听https://127.0.0.1:{httpsPort},https反向代理服务启动完成");
|
||||
logger.LogInformation($"已监听https://{IPAddress.Loopback}:{httpsPort},https反向代理服务启动完成");
|
||||
}
|
||||
|
||||
return httpsPort;
|
||||
@ -117,7 +117,7 @@ namespace FastGithub
|
||||
private static ILogger GetLogger(this KestrelServerOptions kestrel)
|
||||
{
|
||||
var loggerFactory = kestrel.ApplicationServices.GetRequiredService<ILoggerFactory>();
|
||||
return loggerFactory.CreateLogger($"{nameof(FastGithub)}.{nameof(ReverseProxy)}");
|
||||
return loggerFactory.CreateLogger($"{nameof(FastGithub)}.{nameof(HttpServer)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,7 +8,7 @@ using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FastGithub.ReverseProxy
|
||||
namespace FastGithub.HttpServer
|
||||
{
|
||||
/// <summary>
|
||||
/// 请求日志中间件
|
||||
@ -1,4 +1,4 @@
|
||||
using FastGithub.ReverseProxy;
|
||||
using FastGithub.HttpServer;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace FastGithub
|
||||
@ -5,7 +5,7 @@ using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FastGithub.ReverseProxy
|
||||
namespace FastGithub.HttpServer
|
||||
{
|
||||
/// <summary>
|
||||
/// github的ssh代理处理者
|
||||
@ -6,7 +6,7 @@ using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace FastGithub.ReverseProxy
|
||||
namespace FastGithub.HttpServer
|
||||
{
|
||||
/// <summary>
|
||||
/// windows iphlpapi
|
||||
@ -7,14 +7,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub", "FastGithub\Fa
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub.Dns", "FastGithub.Dns\FastGithub.Dns.csproj", "{43FF9C79-51D5-4037-AA0B-CA3006E2A7E6}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub.ReverseProxy", "FastGithub.ReverseProxy\FastGithub.ReverseProxy.csproj", "{28326D0F-B0FB-4B6B-A65A-C69ACB72CAD8}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub.Http", "FastGithub.Http\FastGithub.Http.csproj", "{B5DCB3E4-5094-4170-B844-6F395002CA42}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub.DomainResolve", "FastGithub.DomainResolve\FastGithub.DomainResolve.csproj", "{5D26ABDD-F341-4EB7-9D08-FCB80F79B4B4}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub.Configuration", "FastGithub.Configuration\FastGithub.Configuration.csproj", "{C63CEBB1-56DA-4AC3-BDC9-52424EC292A0}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub.HttpServer", "FastGithub.HttpServer\FastGithub.HttpServer.csproj", "{C9807DA0-4620-445E-ABBF-57A617B8E773}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -29,10 +29,6 @@ Global
|
||||
{43FF9C79-51D5-4037-AA0B-CA3006E2A7E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{43FF9C79-51D5-4037-AA0B-CA3006E2A7E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{43FF9C79-51D5-4037-AA0B-CA3006E2A7E6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{28326D0F-B0FB-4B6B-A65A-C69ACB72CAD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{28326D0F-B0FB-4B6B-A65A-C69ACB72CAD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{28326D0F-B0FB-4B6B-A65A-C69ACB72CAD8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{28326D0F-B0FB-4B6B-A65A-C69ACB72CAD8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B5DCB3E4-5094-4170-B844-6F395002CA42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B5DCB3E4-5094-4170-B844-6F395002CA42}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B5DCB3E4-5094-4170-B844-6F395002CA42}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@ -45,6 +41,10 @@ Global
|
||||
{C63CEBB1-56DA-4AC3-BDC9-52424EC292A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C63CEBB1-56DA-4AC3-BDC9-52424EC292A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C63CEBB1-56DA-4AC3-BDC9-52424EC292A0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C9807DA0-4620-445E-ABBF-57A617B8E773}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C9807DA0-4620-445E-ABBF-57A617B8E773}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C9807DA0-4620-445E-ABBF-57A617B8E773}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C9807DA0-4620-445E-ABBF-57A617B8E773}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
|
||||
<ProjectReference Include="..\FastGithub.Dns\FastGithub.Dns.csproj" />
|
||||
<ProjectReference Include="..\FastGithub.DomainResolve\FastGithub.DomainResolve.csproj" />
|
||||
<ProjectReference Include="..\FastGithub.ReverseProxy\FastGithub.ReverseProxy.csproj" />
|
||||
<ProjectReference Include="..\FastGithub.HttpServer\FastGithub.HttpServer.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user