diff --git a/FastGithub.ReverseProxy/CertService.cs b/FastGithub.ReverseProxy/CertService.cs
index d92d84a..4ae16e3 100644
--- a/FastGithub.ReverseProxy/CertService.cs
+++ b/FastGithub.ReverseProxy/CertService.cs
@@ -3,6 +3,7 @@ using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
@@ -74,18 +75,43 @@ namespace FastGithub.ReverseProxy
}
else if (OperatingSystem.IsLinux())
{
- this.logger.LogWarning($"不支持自动安装证书{this.CaCerFilePath}:请根据具体linux发行版安装CA证书");
+ this.logger.LogWarning($"请根据具体linux发行版手工安装CA证书{this.CaCerFilePath}");
}
else if (OperatingSystem.IsMacOS())
{
- this.logger.LogWarning($"不支持自动安装证书{this.CaCerFilePath}:请手工安装CA证书然后设置信任CA证书");
+ this.logger.LogWarning($"请手工安装CA证书然后设置信任CA证书{this.CaCerFilePath}");
}
else
{
- this.logger.LogWarning($"不支持自动安装证书{this.CaCerFilePath}:请根据你的系统平台手工安装和信任CA证书");
+ this.logger.LogWarning($"请根据你的系统平台手工安装和信任CA证书{this.CaCerFilePath}");
}
- GitUtil.ConfigSslverify(false);
+ GitConfigSslverify(false);
+ }
+
+ ///
+ /// 设置ssl验证
+ ///
+ /// 是否验证
+ ///
+ 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;
+ }
}
///
@@ -113,9 +139,9 @@ namespace FastGithub.ReverseProxy
}
store.Close();
}
- catch (Exception ex)
+ catch (Exception)
{
- this.logger.LogWarning($"安装证书{this.CaCerFilePath}失败:请手动安装到“将所有的证书都放入下载存储”\\“受信任的根证书颁发机构”", ex);
+ this.logger.LogWarning($"请手工安装CA证书{this.CaCerFilePath}到“将所有的证书都放入下载存储”\\“受信任的根证书颁发机构”");
}
}
diff --git a/FastGithub.ReverseProxy/GitUtil.cs b/FastGithub.ReverseProxy/GitUtil.cs
deleted file mode 100644
index 63d8076..0000000
--- a/FastGithub.ReverseProxy/GitUtil.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-using System.Diagnostics;
-
-namespace FastGithub.ReverseProxy
-{
- ///
- /// git工具
- ///
- static class GitUtil
- {
- ///
- /// 设置ssl验证
- ///
- /// 是否验证
- ///
- 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;
- }
- }
- }
-}
diff --git a/FastGithub.ReverseProxy/GithubSshProxyHandler.cs b/FastGithub.ReverseProxy/GithubSshProxyHandler.cs
index 7750570..f7b7883 100644
--- a/FastGithub.ReverseProxy/GithubSshProxyHandler.cs
+++ b/FastGithub.ReverseProxy/GithubSshProxyHandler.cs
@@ -27,17 +27,17 @@ namespace FastGithub.ReverseProxy
///
/// ssh连接后
///
- ///
+ ///
///
- public override async Task OnConnectedAsync(ConnectionContext connection)
+ public override async Task OnConnectedAsync(ConnectionContext context)
{
var address = await this.domainResolver.ResolveAsync(this.githubSshEndPoint);
using var socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
await socket.ConnectAsync(address, this.githubSshEndPoint.Port);
var targetStream = new NetworkStream(socket, ownsSocket: false);
- var task1 = targetStream.CopyToAsync(connection.Transport.Output);
- var task2 = connection.Transport.Input.CopyToAsync(targetStream);
+ var task1 = targetStream.CopyToAsync(context.Transport.Output);
+ var task2 = context.Transport.Input.CopyToAsync(targetStream);
await Task.WhenAny(task1, task2);
}
}