diff --git a/v2rayN/ServiceLib/Enums/ECoreType.cs b/v2rayN/ServiceLib/Enums/ECoreType.cs index e164a2ab..9310a0a9 100644 --- a/v2rayN/ServiceLib/Enums/ECoreType.cs +++ b/v2rayN/ServiceLib/Enums/ECoreType.cs @@ -15,5 +15,6 @@ public enum ECoreType brook = 27, overtls = 28, shadowquic = 29, + mieru = 30, v2rayN = 99 } diff --git a/v2rayN/ServiceLib/Global.cs b/v2rayN/ServiceLib/Global.cs index 733c569d..a7c74c08 100644 --- a/v2rayN/ServiceLib/Global.cs +++ b/v2rayN/ServiceLib/Global.cs @@ -560,6 +560,7 @@ public class Global { ECoreType.brook, "txthinking/brook" }, { ECoreType.overtls, "ShadowsocksR-Live/overtls" }, { ECoreType.shadowquic, "spongebob888/shadowquic" }, + { ECoreType.mieru, "enfein/mieru" }, { ECoreType.v2rayN, "2dust/v2rayN" }, }; diff --git a/v2rayN/ServiceLib/Manager/CoreInfoManager.cs b/v2rayN/ServiceLib/Manager/CoreInfoManager.cs index 12345499..790e8839 100644 --- a/v2rayN/ServiceLib/Manager/CoreInfoManager.cs +++ b/v2rayN/ServiceLib/Manager/CoreInfoManager.cs @@ -80,6 +80,10 @@ public sealed class CoreInfoManager Url = GetCoreUrl(ECoreType.v2fly), Match = "V2Ray", VersionArg = "-version", + Environment = new Dictionary() + { + { Global.V2RayLocalAsset, Utils.GetBinPath("") }, + }, }, new CoreInfo @@ -90,6 +94,10 @@ public sealed class CoreInfoManager Url = GetCoreUrl(ECoreType.v2fly_v5), Match = "V2Ray", VersionArg = "version", + Environment = new Dictionary() + { + { Global.V2RayLocalAsset, Utils.GetBinPath("") }, + }, }, new CoreInfo @@ -107,6 +115,11 @@ public sealed class CoreInfoManager DownloadUrlOSXArm64 = urlXray + "/download/{0}/Xray-macos-arm64-v8a.zip", Match = "Xray", VersionArg = "-version", + Environment = new Dictionary() + { + { Global.XrayLocalAsset, Utils.GetBinPath("") }, + { Global.XrayLocalCert, Utils.GetBinPath("") }, + }, }, new CoreInfo @@ -205,12 +218,24 @@ public sealed class CoreInfoManager new CoreInfo { CoreType = ECoreType.shadowquic, - CoreExes = [ "shadowquic", "shadowquic"], + CoreExes = [ "shadowquic" ], Arguments = "-c {0}", Url = GetCoreUrl(ECoreType.shadowquic), AbsolutePath = false, - } + }, + new CoreInfo + { + CoreType = ECoreType.mieru, + CoreExes = [ "mieru" ], + Arguments = "run", + Url = GetCoreUrl(ECoreType.mieru), + AbsolutePath = false, + Environment = new Dictionary() + { + { "MIERU_CONFIG_JSON_FILE", "{0}" }, + }, + }, ]; } diff --git a/v2rayN/ServiceLib/Manager/CoreManager.cs b/v2rayN/ServiceLib/Manager/CoreManager.cs index d0fcc0fa..74cdaf91 100644 --- a/v2rayN/ServiceLib/Manager/CoreManager.cs +++ b/v2rayN/ServiceLib/Manager/CoreManager.cs @@ -22,10 +22,6 @@ public class CoreManager _config = config; _updateFunc = updateFunc; - Environment.SetEnvironmentVariable(Global.V2RayLocalAsset, Utils.GetBinPath(""), EnvironmentVariableTarget.Process); - Environment.SetEnvironmentVariable(Global.XrayLocalAsset, Utils.GetBinPath(""), EnvironmentVariableTarget.Process); - Environment.SetEnvironmentVariable(Global.XrayLocalCert, Utils.GetBinPath(""), EnvironmentVariableTarget.Process); - //Copy the bin folder to the storage location (for init) if (Environment.GetEnvironmentVariable(Global.LocalAppData) == "1") { @@ -277,6 +273,10 @@ public class CoreManager StandardErrorEncoding = displayLog ? Encoding.UTF8 : null, } }; + foreach (var kv in coreInfo.Environment) + { + proc.StartInfo.Environment[kv.Key] = string.Format(kv.Value, coreInfo.AbsolutePath ? Utils.GetBinConfigPath(configPath).AppendQuotes() : configPath); + } if (displayLog) { diff --git a/v2rayN/ServiceLib/Models/CoreInfo.cs b/v2rayN/ServiceLib/Models/CoreInfo.cs index faf899a9..eb4404cb 100644 --- a/v2rayN/ServiceLib/Models/CoreInfo.cs +++ b/v2rayN/ServiceLib/Models/CoreInfo.cs @@ -17,4 +17,5 @@ public class CoreInfo public string? Match { get; set; } public string? VersionArg { get; set; } public bool AbsolutePath { get; set; } + public IDictionary Environment { get; set; } = new Dictionary(); }