Add support for brook custom configuration

https://github.com/txthinking/brook
https://github.com/txthinking/brook/issues/1372
This commit is contained in:
2dust 2025-02-03 15:06:21 +08:00
parent 9d92be99ee
commit 2a0012824a
5 changed files with 20 additions and 17 deletions

View file

@ -1,4 +1,4 @@
namespace ServiceLib.Enums
namespace ServiceLib.Enums
{
public enum ECoreType
{
@ -12,6 +12,7 @@
sing_box = 24,
juicity = 25,
hysteria2 = 26,
brook = 27,
v2rayN = 99
}
}

View file

@ -1,4 +1,4 @@
namespace ServiceLib
namespace ServiceLib
{
public class Global
{
@ -18,6 +18,7 @@
public const string GeoUrl = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/{0}.dat";
public const string SpeedPingTestUrl = @"https://www.google.com/generate_204";
public const string JuicityCoreUrl = "https://github.com/juicity/juicity/releases";
public const string BrookCoreUrl = "https://github.com/txthinking/brook/releases";
public const string SingboxRulesetUrl = @"https://raw.githubusercontent.com/2dust/sing-box-rules/rule-set-{0}/{1}.srs";
public const string IPAPIUrl = "https://api.ip.sb/geoip";

View file

@ -225,7 +225,7 @@ namespace ServiceLib.Handler
StartInfo = new()
{
FileName = fileName,
Arguments = string.Format(coreInfo.Arguments, configPath),
Arguments = string.Format(coreInfo.Arguments, coreInfo.AbsolutePath ? Utils.GetConfigPath(configPath) : configPath),
WorkingDirectory = Utils.GetConfigPath(),
UseShellExecute = false,
RedirectStandardOutput = displayLog,

View file

@ -76,7 +76,6 @@ namespace ServiceLib.Handler
ReleaseApiUrl = Global.V2flyCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
Match = "V2Ray",
VersionArg = "-version",
RedirectInfo = true,
},
new CoreInfo
@ -88,7 +87,6 @@ namespace ServiceLib.Handler
ReleaseApiUrl = Global.V2flyCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
Match = "V2Ray",
VersionArg = "version",
RedirectInfo = true,
},
new CoreInfo
@ -106,7 +104,6 @@ namespace ServiceLib.Handler
DownloadUrlOSXArm64 = Global.XrayCoreUrl + "/download/{0}/Xray-macos-arm64-v8a.zip",
Match = "Xray",
VersionArg = "-version",
RedirectInfo = true,
},
new CoreInfo
@ -124,7 +121,6 @@ namespace ServiceLib.Handler
DownloadUrlOSXArm64 = Global.MihomoCoreUrl + "/download/{0}/mihomo-darwin-arm64-{0}.gz",
Match = "Mihomo",
VersionArg = "-v",
RedirectInfo = true,
},
new CoreInfo
@ -133,7 +129,6 @@ namespace ServiceLib.Handler
CoreExes = ["hysteria-windows-amd64", "hysteria"],
Arguments = "-c {0}",
Url = Global.HysteriaCoreUrl,
RedirectInfo = true,
},
new CoreInfo
@ -142,7 +137,6 @@ namespace ServiceLib.Handler
CoreExes = [ "naive", "naiveproxy"],
Arguments = "{0}",
Url = Global.NaiveproxyCoreUrl,
RedirectInfo = false,
},
new CoreInfo
@ -151,7 +145,6 @@ namespace ServiceLib.Handler
CoreExes = ["tuic-client", "tuic"],
Arguments = "-c {0}",
Url = Global.TuicCoreUrl,
RedirectInfo = true,
},
new CoreInfo
@ -160,7 +153,7 @@ namespace ServiceLib.Handler
CoreExes = ["sing-box-client", "sing-box"],
Arguments = "run -c {0} --disable-color",
Url = Global.SingboxCoreUrl,
RedirectInfo = true,
ReleaseApiUrl = Global.SingboxCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
DownloadUrlWin64 = Global.SingboxCoreUrl + "/download/{0}/sing-box-{1}-windows-amd64.zip",
DownloadUrlWinArm64 = Global.SingboxCoreUrl + "/download/{0}/sing-box-{1}-windows-arm64.zip",
@ -186,7 +179,15 @@ namespace ServiceLib.Handler
CoreExes = ["hysteria-windows-amd64", "hysteria-linux-amd64", "hysteria"],
Arguments = "-c {0}",
Url = Global.HysteriaCoreUrl,
RedirectInfo = true,
},
new CoreInfo
{
CoreType = ECoreType.brook,
CoreExes = ["brook_windows_amd64", "brook_linux_amd64", "brook"],
Arguments = " {0}",
Url = Global.BrookCoreUrl,
AbsolutePath = true,
}
];

View file

@ -1,4 +1,4 @@
namespace ServiceLib.Models
namespace ServiceLib.Models
{
[Serializable]
public class CoreInfo
@ -16,6 +16,6 @@
public string? DownloadUrlOSXArm64 { get; set; }
public string? Match { get; set; }
public string? VersionArg { get; set; }
public bool RedirectInfo { get; set; }
public bool AbsolutePath { get; set; }
}
}