合并类型
This commit is contained in:
parent
4fb55ba149
commit
ab9cd99c90
@ -3,6 +3,7 @@ using Microsoft.Extensions.Caching.Memory;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
@ -74,18 +75,43 @@ namespace FastGithub.ReverseProxy
|
|||||||
}
|
}
|
||||||
else if (OperatingSystem.IsLinux())
|
else if (OperatingSystem.IsLinux())
|
||||||
{
|
{
|
||||||
this.logger.LogWarning($"不支持自动安装证书{this.CaCerFilePath}:请根据具体linux发行版安装CA证书");
|
this.logger.LogWarning($"请根据具体linux发行版手工安装CA证书{this.CaCerFilePath}");
|
||||||
}
|
}
|
||||||
else if (OperatingSystem.IsMacOS())
|
else if (OperatingSystem.IsMacOS())
|
||||||
{
|
{
|
||||||
this.logger.LogWarning($"不支持自动安装证书{this.CaCerFilePath}:请手工安装CA证书然后设置信任CA证书");
|
this.logger.LogWarning($"请手工安装CA证书然后设置信任CA证书{this.CaCerFilePath}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.logger.LogWarning($"不支持自动安装证书{this.CaCerFilePath}:请根据你的系统平台手工安装和信任CA证书");
|
this.logger.LogWarning($"请根据你的系统平台手工安装和信任CA证书{this.CaCerFilePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
GitUtil.ConfigSslverify(false);
|
GitConfigSslverify(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置ssl验证
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">是否验证</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool GitConfigSslverify(bool value)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = "git",
|
||||||
|
Arguments = $"config --global http.sslverify {value.ToString().ToLower()}",
|
||||||
|
UseShellExecute = true,
|
||||||
|
CreateNoWindow = true,
|
||||||
|
WindowStyle = ProcessWindowStyle.Hidden
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -113,9 +139,9 @@ namespace FastGithub.ReverseProxy
|
|||||||
}
|
}
|
||||||
store.Close();
|
store.Close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
this.logger.LogWarning($"安装证书{this.CaCerFilePath}失败:请手动安装到“将所有的证书都放入下载存储”\\“受信任的根证书颁发机构”", ex);
|
this.logger.LogWarning($"请手工安装CA证书{this.CaCerFilePath}到“将所有的证书都放入下载存储”\\“受信任的根证书颁发机构”");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,36 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
namespace FastGithub.ReverseProxy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// git工具
|
|
||||||
/// </summary>
|
|
||||||
static class GitUtil
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 设置ssl验证
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">是否验证</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool ConfigSslverify(bool value)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Process.Start(new ProcessStartInfo
|
|
||||||
{
|
|
||||||
FileName = "git",
|
|
||||||
Arguments = $"config --global http.sslverify {value.ToString().ToLower()}",
|
|
||||||
UseShellExecute = true,
|
|
||||||
CreateNoWindow = true,
|
|
||||||
WindowStyle = ProcessWindowStyle.Hidden
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -27,17 +27,17 @@ namespace FastGithub.ReverseProxy
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// ssh连接后
|
/// ssh连接后
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="connection"></param>
|
/// <param name="context"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override async Task OnConnectedAsync(ConnectionContext connection)
|
public override async Task OnConnectedAsync(ConnectionContext context)
|
||||||
{
|
{
|
||||||
var address = await this.domainResolver.ResolveAsync(this.githubSshEndPoint);
|
var address = await this.domainResolver.ResolveAsync(this.githubSshEndPoint);
|
||||||
using var socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
using var socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||||
await socket.ConnectAsync(address, this.githubSshEndPoint.Port);
|
await socket.ConnectAsync(address, this.githubSshEndPoint.Port);
|
||||||
var targetStream = new NetworkStream(socket, ownsSocket: false);
|
var targetStream = new NetworkStream(socket, ownsSocket: false);
|
||||||
|
|
||||||
var task1 = targetStream.CopyToAsync(connection.Transport.Output);
|
var task1 = targetStream.CopyToAsync(context.Transport.Output);
|
||||||
var task2 = connection.Transport.Input.CopyToAsync(targetStream);
|
var task2 = context.Transport.Input.CopyToAsync(targetStream);
|
||||||
await Task.WhenAny(task1, task2);
|
await Task.WhenAny(task1, task2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user