Skip to content

Commit 9d7c7e3

Browse files
committed
Adjust the experimental and mux of sing-box
1 parent 855fd4f commit 9d7c7e3

File tree

3 files changed

+13
-55
lines changed

3 files changed

+13
-55
lines changed

v2rayN/v2rayN/Handler/ConfigHandler.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public static int LoadConfig(ref Config? config)
5151
logEnabled = false,
5252
loglevel = "warning",
5353
muxEnabled = false,
54-
enableCacheFile4Sbox = false,
5554
};
5655
}
5756

@@ -180,7 +179,7 @@ public static int LoadConfig(ref Config? config)
180179
config.mux4SboxItem = new()
181180
{
182181
protocol = Global.SingboxMuxs[0],
183-
max_connections = 4
182+
max_connections = 8
184183
};
185184
}
186185

@@ -305,7 +304,6 @@ public static int ImportOldGuiConfig(Config config, string fileName)
305304
logEnabled = configOld.logEnabled,
306305
loglevel = configOld.loglevel,
307306
muxEnabled = configOld.muxEnabled,
308-
enableCacheFile4Sbox = false,
309307
};
310308
}
311309

v2rayN/v2rayN/Handler/CoreConfigSingbox.cs

Lines changed: 11 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,16 @@ private int GenOutboundMux(ProfileItem node, Outbound4Sbox outbound)
337337
{
338338
try
339339
{
340-
//if (_config.coreBasicItem.muxEnabled)
341-
//{
342-
// var mux = new Multiplex4Sbox()
343-
// {
344-
// enabled = true,
345-
// protocol = _config.mux4SboxItem.protocol,
346-
// max_connections = _config.mux4SboxItem.max_connections,
347-
// };
348-
// outbound.multiplex = mux;
349-
//}
340+
if (_config.coreBasicItem.muxEnabled && !Utils.IsNullOrEmpty(_config.mux4SboxItem.protocol))
341+
{
342+
var mux = new Multiplex4Sbox()
343+
{
344+
enabled = true,
345+
protocol = _config.mux4SboxItem.protocol,
346+
max_connections = _config.mux4SboxItem.max_connections,
347+
};
348+
outbound.multiplex = mux;
349+
}
350350
}
351351
catch (Exception ex)
352352
{
@@ -822,7 +822,7 @@ private int GenDns(ProfileItem node, SingboxConfig singboxConfig)
822822
return 0;
823823
}
824824

825-
private int GenExperimentalStatistic(SingboxConfig singboxConfig)
825+
private int GenExperimental(SingboxConfig singboxConfig)
826826
{
827827
if (_config.guiItem.enableStatistics)
828828
{
@@ -831,39 +831,8 @@ private int GenExperimentalStatistic(SingboxConfig singboxConfig)
831831
{
832832
external_controller = $"{Global.Loopback}:{LazyConfig.Instance.StatePort}",
833833
};
834-
// singboxConfig.experimental.v2ray_api = new V2ray_Api4Sbox()
835-
// {
836-
// listen = $"{Global.Loopback}:{Global.StatePort}",
837-
// stats = new Stats4Sbox()
838-
// {
839-
// enabled = true,
840-
// }
841-
// };
842-
// singboxConfig.experimental = new Experimental4Sbox()
843-
// {
844-
// cache_file = new CacheFile4Sbox()
845-
// {
846-
// enabled = true
847-
// },
848-
// //v2ray_api = new V2ray_Api4Sbox()
849-
// //{
850-
// // listen = $"{Global.Loopback}:{Global.StatePort}",
851-
// // stats = new Stats4Sbox()
852-
// // {
853-
// // enabled = true,
854-
// // }
855-
// //},
856-
// clash_api = new Clash_Api4Sbox()
857-
// {
858-
// external_controller = $"{Global.Loopback}:{LazyConfig.Instance.StatePort}",
859-
// }
860-
// };
861834
}
862-
return 0;
863-
}
864835

865-
private int GenExperimentalCacheFile(SingboxConfig singboxConfig)
866-
{
867836
if (_config.coreBasicItem.enableCacheFile4Sbox)
868837
{
869838
singboxConfig.experimental ??= new Experimental4Sbox();
@@ -876,15 +845,6 @@ private int GenExperimentalCacheFile(SingboxConfig singboxConfig)
876845
return 0;
877846
}
878847

879-
private int GenExperimental(SingboxConfig singboxConfig)
880-
{
881-
var r = GenExperimentalStatistic(singboxConfig);
882-
if (r != 0) return r;
883-
r = GenExperimentalCacheFile(singboxConfig);
884-
if (r != 0) return r;
885-
return 0;
886-
}
887-
888848
private int ConvertGeo2Ruleset(SingboxConfig singboxConfig)
889849
{
890850
var geosite = "geosite";

v2rayN/v2rayN/Models/ConfigItems.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class CoreBasicItem
3434

3535
public bool enableFragment { get; set; }
3636

37-
public bool enableCacheFile4Sbox { get; set; }
37+
public bool enableCacheFile4Sbox { get; set; } = true;
3838
}
3939

4040
[Serializable]

0 commit comments

Comments
 (0)