Skip to content

Commit 3eb49aa

Browse files
authored
Add mieru support (2dust#7828)
1 parent 45c987f commit 3eb49aa

5 files changed

Lines changed: 34 additions & 6 deletions

File tree

v2rayN/ServiceLib/Enums/ECoreType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ public enum ECoreType
1515
brook = 27,
1616
overtls = 28,
1717
shadowquic = 29,
18+
mieru = 30,
1819
v2rayN = 99
1920
}

v2rayN/ServiceLib/Global.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ public class Global
560560
{ ECoreType.brook, "txthinking/brook" },
561561
{ ECoreType.overtls, "ShadowsocksR-Live/overtls" },
562562
{ ECoreType.shadowquic, "spongebob888/shadowquic" },
563+
{ ECoreType.mieru, "enfein/mieru" },
563564
{ ECoreType.v2rayN, "2dust/v2rayN" },
564565
};
565566

v2rayN/ServiceLib/Manager/CoreInfoManager.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ private void InitCoreInfo()
8080
Url = GetCoreUrl(ECoreType.v2fly),
8181
Match = "V2Ray",
8282
VersionArg = "-version",
83+
Environment = new Dictionary<string, string?>()
84+
{
85+
{ Global.V2RayLocalAsset, Utils.GetBinPath("") },
86+
},
8387
},
8488

8589
new CoreInfo
@@ -90,6 +94,10 @@ private void InitCoreInfo()
9094
Url = GetCoreUrl(ECoreType.v2fly_v5),
9195
Match = "V2Ray",
9296
VersionArg = "version",
97+
Environment = new Dictionary<string, string?>()
98+
{
99+
{ Global.V2RayLocalAsset, Utils.GetBinPath("") },
100+
},
93101
},
94102

95103
new CoreInfo
@@ -107,6 +115,11 @@ private void InitCoreInfo()
107115
DownloadUrlOSXArm64 = urlXray + "/download/{0}/Xray-macos-arm64-v8a.zip",
108116
Match = "Xray",
109117
VersionArg = "-version",
118+
Environment = new Dictionary<string, string?>()
119+
{
120+
{ Global.XrayLocalAsset, Utils.GetBinPath("") },
121+
{ Global.XrayLocalCert, Utils.GetBinPath("") },
122+
},
110123
},
111124

112125
new CoreInfo
@@ -205,12 +218,24 @@ private void InitCoreInfo()
205218
new CoreInfo
206219
{
207220
CoreType = ECoreType.shadowquic,
208-
CoreExes = [ "shadowquic", "shadowquic"],
221+
CoreExes = [ "shadowquic" ],
209222
Arguments = "-c {0}",
210223
Url = GetCoreUrl(ECoreType.shadowquic),
211224
AbsolutePath = false,
212-
}
225+
},
213226

227+
new CoreInfo
228+
{
229+
CoreType = ECoreType.mieru,
230+
CoreExes = [ "mieru" ],
231+
Arguments = "run",
232+
Url = GetCoreUrl(ECoreType.mieru),
233+
AbsolutePath = false,
234+
Environment = new Dictionary<string, string?>()
235+
{
236+
{ "MIERU_CONFIG_JSON_FILE", "{0}" },
237+
},
238+
},
214239
];
215240
}
216241

v2rayN/ServiceLib/Manager/CoreManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ public async Task Init(Config config, Action<bool, string> updateFunc)
2222
_config = config;
2323
_updateFunc = updateFunc;
2424

25-
Environment.SetEnvironmentVariable(Global.V2RayLocalAsset, Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
26-
Environment.SetEnvironmentVariable(Global.XrayLocalAsset, Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
27-
Environment.SetEnvironmentVariable(Global.XrayLocalCert, Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
28-
2925
//Copy the bin folder to the storage location (for init)
3026
if (Environment.GetEnvironmentVariable(Global.LocalAppData) == "1")
3127
{
@@ -277,6 +273,10 @@ private void UpdateFunc(bool notify, string msg)
277273
StandardErrorEncoding = displayLog ? Encoding.UTF8 : null,
278274
}
279275
};
276+
foreach (var kv in coreInfo.Environment)
277+
{
278+
proc.StartInfo.Environment[kv.Key] = string.Format(kv.Value, coreInfo.AbsolutePath ? Utils.GetBinConfigPath(configPath).AppendQuotes() : configPath);
279+
}
280280

281281
if (displayLog)
282282
{

v2rayN/ServiceLib/Models/CoreInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ public class CoreInfo
1717
public string? Match { get; set; }
1818
public string? VersionArg { get; set; }
1919
public bool AbsolutePath { get; set; }
20+
public IDictionary<string, string?> Environment { get; set; } = new Dictionary<string, string?>();
2021
}

0 commit comments

Comments
 (0)