From 9d7c7e3225fa1122373ae82be07039894a7f1e3e Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 27 Apr 2024 10:05:13 +0800 Subject: [PATCH] Adjust the experimental and mux of sing-box --- v2rayN/v2rayN/Handler/ConfigHandler.cs | 4 +- v2rayN/v2rayN/Handler/CoreConfigSingbox.cs | 62 ++++------------------ v2rayN/v2rayN/Models/ConfigItems.cs | 2 +- 3 files changed, 13 insertions(+), 55 deletions(-) diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index d7dc5c40..5253857f 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -51,7 +51,6 @@ namespace v2rayN.Handler logEnabled = false, loglevel = "warning", muxEnabled = false, - enableCacheFile4Sbox = false, }; } @@ -180,7 +179,7 @@ namespace v2rayN.Handler config.mux4SboxItem = new() { protocol = Global.SingboxMuxs[0], - max_connections = 4 + max_connections = 8 }; } @@ -305,7 +304,6 @@ namespace v2rayN.Handler logEnabled = configOld.logEnabled, loglevel = configOld.loglevel, muxEnabled = configOld.muxEnabled, - enableCacheFile4Sbox = false, }; } diff --git a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs index 195006d7..793f9ef2 100644 --- a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs +++ b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs @@ -337,16 +337,16 @@ namespace v2rayN.Handler { try { - //if (_config.coreBasicItem.muxEnabled) - //{ - // var mux = new Multiplex4Sbox() - // { - // enabled = true, - // protocol = _config.mux4SboxItem.protocol, - // max_connections = _config.mux4SboxItem.max_connections, - // }; - // outbound.multiplex = mux; - //} + if (_config.coreBasicItem.muxEnabled && !Utils.IsNullOrEmpty(_config.mux4SboxItem.protocol)) + { + var mux = new Multiplex4Sbox() + { + enabled = true, + protocol = _config.mux4SboxItem.protocol, + max_connections = _config.mux4SboxItem.max_connections, + }; + outbound.multiplex = mux; + } } catch (Exception ex) { @@ -822,7 +822,7 @@ namespace v2rayN.Handler return 0; } - private int GenExperimentalStatistic(SingboxConfig singboxConfig) + private int GenExperimental(SingboxConfig singboxConfig) { if (_config.guiItem.enableStatistics) { @@ -831,39 +831,8 @@ namespace v2rayN.Handler { external_controller = $"{Global.Loopback}:{LazyConfig.Instance.StatePort}", }; - // singboxConfig.experimental.v2ray_api = new V2ray_Api4Sbox() - // { - // listen = $"{Global.Loopback}:{Global.StatePort}", - // stats = new Stats4Sbox() - // { - // enabled = true, - // } - // }; - // singboxConfig.experimental = new Experimental4Sbox() - // { - // cache_file = new CacheFile4Sbox() - // { - // enabled = true - // }, - // //v2ray_api = new V2ray_Api4Sbox() - // //{ - // // listen = $"{Global.Loopback}:{Global.StatePort}", - // // stats = new Stats4Sbox() - // // { - // // enabled = true, - // // } - // //}, - // clash_api = new Clash_Api4Sbox() - // { - // external_controller = $"{Global.Loopback}:{LazyConfig.Instance.StatePort}", - // } - // }; } - return 0; - } - private int GenExperimentalCacheFile(SingboxConfig singboxConfig) - { if (_config.coreBasicItem.enableCacheFile4Sbox) { singboxConfig.experimental ??= new Experimental4Sbox(); @@ -876,15 +845,6 @@ namespace v2rayN.Handler return 0; } - private int GenExperimental(SingboxConfig singboxConfig) - { - var r = GenExperimentalStatistic(singboxConfig); - if (r != 0) return r; - r = GenExperimentalCacheFile(singboxConfig); - if (r != 0) return r; - return 0; - } - private int ConvertGeo2Ruleset(SingboxConfig singboxConfig) { var geosite = "geosite"; diff --git a/v2rayN/v2rayN/Models/ConfigItems.cs b/v2rayN/v2rayN/Models/ConfigItems.cs index 26e93bd7..098514a1 100644 --- a/v2rayN/v2rayN/Models/ConfigItems.cs +++ b/v2rayN/v2rayN/Models/ConfigItems.cs @@ -34,7 +34,7 @@ namespace v2rayN.Models public bool enableFragment { get; set; } - public bool enableCacheFile4Sbox { get; set; } + public bool enableCacheFile4Sbox { get; set; } = true; } [Serializable]