diff --git a/.github/workflows/dotnet-core-desktop.yml b/.github/workflows/dotnet-core-desktop.yml
index 4eaf1c7..f9949f7 100644
--- a/.github/workflows/dotnet-core-desktop.yml
+++ b/.github/workflows/dotnet-core-desktop.yml
@@ -27,6 +27,10 @@ jobs:
- run: powershell Expand-Archive -Path .\x86.zip -DestinationPath .\x86
- run: powershell New-Item -ItemType Directory -Force -Path ".\build\x86"
- run: powershell Copy-Item -Path ".\x86\version.dll" -Destination ".\build\x86"
+
+ - run: powershell curl https://github.com/ginuerzh/gost/releases/download/v2.12.0/gost_2.12.0_windows_amd64.zip -o gost.zip
+ - run: powershell Expand-Archive -Path .\gost.zip -DestinationPath .\gost
+ - run: powershell Copy-Item -Path ".\gost\gost.exe" -Destination ".\build"
- run: powershell Copy-Item -Path "$env:GITHUB_WORKSPACE\DiscordProxyStart\bin\Release\net8.0\win-x64\publish\DiscordProxyStart.exe" -Destination ".\build"
- run: powershell Copy-Item -Path "$env:GITHUB_WORKSPACE\DiscordProxyStart\bin\Release\net8.0\win-x64\publish\DiscordProxyStart.pdb" -Destination ".\build"
diff --git a/DiscordProxyStart/DiscordProxyStart.csproj b/DiscordProxyStart/DiscordProxyStart.csproj
index fb2650c..c419a3d 100644
--- a/DiscordProxyStart/DiscordProxyStart.csproj
+++ b/DiscordProxyStart/DiscordProxyStart.csproj
@@ -27,5 +27,10 @@
True
\
+
+ True
+ \
+
+
diff --git a/DiscordProxyStart/Services/GostManager.cs b/DiscordProxyStart/Services/GostManager.cs
new file mode 100644
index 0000000..d1985ad
--- /dev/null
+++ b/DiscordProxyStart/Services/GostManager.cs
@@ -0,0 +1,84 @@
+using DiscordProxyStart.Utils;
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Threading;
+
+
+namespace DiscordProxyStart.Services
+{
+
+ public class GostManager
+ {
+
+ private static GostManager _instance;
+ private static readonly object _lock = new object();
+
+ private readonly string gostPath;
+
+ public static GostManager Instance
+ {
+ get
+ {
+ if (_instance == null)
+ {
+ lock (_lock)
+ {
+ if (_instance == null)
+ {
+ _instance = new GostManager($@"{AppContext.BaseDirectory}gost.exe");
+ }
+ }
+ }
+ return _instance;
+ }
+ }
+
+ public GostManager(string gostPath)
+ {
+ this.gostPath = gostPath;
+ }
+
+ private void KillExistingGostProcess()
+ {
+ var processes = Process.GetProcessesByName("gost");
+ foreach (var process in processes)
+ {
+ try
+ {
+ string processPath = Path.GetFullPath(process.MainModule?.FileName ?? string.Empty);
+
+ if (string.Equals(processPath, gostPath, StringComparison.OrdinalIgnoreCase))
+ {
+ process.Kill();
+ process.WaitForExit();
+ }
+ }
+ catch (Exception ex)
+ {
+ SimpleLogger.Instance.Info(@$"[KillExistingGostProcessError]{ex}");
+ }
+ }
+ }
+
+ public void StartProxy(string socksProxyAddress, int localHttpPort)
+ {
+ KillExistingGostProcess();
+ var startInfo = new ProcessStartInfo
+ {
+ FileName = gostPath,
+ Arguments = $"-L=http://127.0.0.1:{localHttpPort} -F={socksProxyAddress}",
+ UseShellExecute = false,
+ CreateNoWindow = true,
+ };
+
+ Debug.WriteLine(startInfo.Arguments);
+ var currentProcess = new Process { StartInfo = startInfo };
+ currentProcess.Start();
+ //currentProcess.WaitForExit();
+ Thread.Sleep(3000);
+ }
+ }
+
+
+}
diff --git a/DiscordProxyStart/Servers/MacStartManager.cs b/DiscordProxyStart/Services/MacStartManager.cs
similarity index 100%
rename from DiscordProxyStart/Servers/MacStartManager.cs
rename to DiscordProxyStart/Services/MacStartManager.cs
diff --git a/DiscordProxyStart/Servers/WinStartManager.cs b/DiscordProxyStart/Services/WinStartManager.cs
similarity index 96%
rename from DiscordProxyStart/Servers/WinStartManager.cs
rename to DiscordProxyStart/Services/WinStartManager.cs
index 5f25a2b..ba4d371 100644
--- a/DiscordProxyStart/Servers/WinStartManager.cs
+++ b/DiscordProxyStart/Services/WinStartManager.cs
@@ -1,4 +1,5 @@
-using DiscordProxyStart.Utils;
+using DiscordProxyStart.Services;
+using DiscordProxyStart.Utils;
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
@@ -20,6 +21,9 @@ public static void Start()
var iniPath = Path.Combine(AppContext.BaseDirectory, "Config.ini");
+
+
+
//如果配置文件中有配置
var setupPath = SetupPathHelper.GetInstallPath("Discord");
if (File.Exists(iniPath))
@@ -74,6 +78,9 @@ private static void PortableStart(string exePath)
SimpleLogger.Instance.Info("正在准备启动...");
var appPath = GetAppPath(setupPath);
var proxy = GetProxy();
+
+ //
+
var copyResult = CopyVersionDll(setupPath);
//TODO 自动gost转换socks代理?
@@ -202,6 +209,16 @@ private static string GetProxy()
throw new Exception("Config.ini中未设置代理地址");
}
+ //如果代理是socks开头,则启用Gost来中转,同时可支持账号密码
+ if (proxy.ToLower().StartsWith("socks"))
+ {
+ //代理需要转发
+ GostManager.Instance.StartProxy(proxy, 63121);
+ return "http://127.0.0.1:63121";
+ }
+
+
+
return proxy.Replace("\"", "").Trim();
}