diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index 4cde8589..3494dcf0 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -86,21 +86,16 @@ public class CoreConfigSingboxService ret.Success = true; var customConfig = await AppHandler.Instance.GetCustomConfigItem(ECoreType.sing_box); - if (customConfig.Enabled && (!customConfig.Config.IsNullOrEmpty())) + var customConfigItem = customConfig.Config; + if (_config.TunModeItem.EnableTun) { - //var customConfigObj = JsonUtils.Deserialize(customConfig.Config); - //if (customConfigObj != null) - //{ - // customConfigObj.outbounds = JsonUtils.DeepCopy(singboxConfig.outbounds); - // singboxConfig = customConfigObj; - //} - - // skip deserialize - var customConfigNode = JsonNode.Parse(customConfig.Config); + customConfigItem = customConfig.TunConfig; + } + if (customConfig.Enabled && (!customConfigItem.IsNullOrEmpty())) + { + var customConfigNode = JsonNode.Parse(customConfigItem); if (customConfigNode != null) { - // customConfigNode["outbounds"] = JsonNode.Parse(JsonUtils.Serialize(singboxConfig.outbounds)); - // append outbounds instead of override if (customConfigNode["outbounds"] is JsonArray customOutboundsNode) { if (JsonNode.Parse(JsonUtils.Serialize(singboxConfig.outbounds)) is JsonArray newOutbounds) @@ -111,7 +106,6 @@ public class CoreConfigSingboxService } } } - // endpoints if (customConfigNode["endpoints"] is JsonArray customEndpointsNode) { if (singboxConfig.endpoints != null && JsonNode.Parse(JsonUtils.Serialize(singboxConfig.endpoints)) is JsonArray newEndpoints) @@ -482,20 +476,16 @@ public class CoreConfigSingboxService ret.Success = true; var customConfig = await AppHandler.Instance.GetCustomConfigItem(ECoreType.sing_box); - if (customConfig.Enabled && (!customConfig.Config.IsNullOrEmpty())) + var customConfigItem = customConfig.Config; + if (_config.TunModeItem.EnableTun) { - //var customConfigObj = JsonUtils.Deserialize(customConfig.Config); - //if (customConfigObj != null) - //{ - // customConfigObj.outbounds = JsonUtils.DeepCopy(singboxConfig.outbounds); - // singboxConfig = customConfigObj; - //} - // skip deserialize - var customConfigNode = JsonNode.Parse(customConfig.Config); + customConfigItem = customConfig.TunConfig; + } + if (customConfig.Enabled && (!customConfigItem.IsNullOrEmpty())) + { + var customConfigNode = JsonNode.Parse(customConfigItem); if (customConfigNode != null) { - // customConfigNode["outbounds"] = JsonNode.Parse(JsonUtils.Serialize(singboxConfig.outbounds)); - // append outbounds instead of override if (customConfigNode["outbounds"] is JsonArray customOutboundsNode) { if (JsonNode.Parse(JsonUtils.Serialize(singboxConfig.outbounds)) is JsonArray newOutbounds) @@ -506,7 +496,6 @@ public class CoreConfigSingboxService } } } - // endpoints if (customConfigNode["endpoints"] is JsonArray customEndpointsNode) { if (singboxConfig.endpoints != null && JsonNode.Parse(JsonUtils.Serialize(singboxConfig.endpoints)) is JsonArray newEndpoints) diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index 59b820af..2c0e53d3 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -73,18 +73,9 @@ public class CoreConfigV2rayService var customConfig = await AppHandler.Instance.GetCustomConfigItem(ECoreType.Xray); if (customConfig.Enabled && (!customConfig.Config.IsNullOrEmpty())) { - //var customConfigObj = JsonUtils.Deserialize(customConfig.Config); - //if (customConfigObj != null) - //{ - // customConfigObj.outbounds = JsonUtils.DeepCopy(v2rayConfig.outbounds); - // v2rayConfig = customConfigObj; - //} - // spik deserialize var customConfigNode = JsonNode.Parse(customConfig.Config); if (customConfigNode != null) { - //customConfigNode["outbounds"] = JsonNode.Parse(JsonUtils.Serialize(v2rayConfig.outbounds)); - // append outbounds instead of override if (customConfigNode["outbounds"] is JsonArray customOutboundsNode) { if (JsonNode.Parse(JsonUtils.Serialize(v2rayConfig.outbounds)) is JsonArray newOutbounds) @@ -234,22 +225,6 @@ public class CoreConfigV2rayService var customConfig = await AppHandler.Instance.GetCustomConfigItem(ECoreType.Xray); if (customConfig.Enabled && (!customConfig.Config.IsNullOrEmpty())) { - //var customConfigObj = JsonUtils.Deserialize(customConfig.Config); - //if (customConfigObj != null) - //{ - // foreach (var rule in customConfigObj.routing.rules) - // { - // if (rule.outboundTag == Global.ProxyTag) - // { - // rule.outboundTag = null; - // rule.balancerTag = balancer.tag; - // } - // } - // customConfigObj.routing.balancers = JsonUtils.DeepCopy(v2rayConfig.routing.balancers); - // customConfigObj.outbounds = JsonUtils.DeepCopy(v2rayConfig.outbounds); - // v2rayConfig = customConfigObj; - //} - // skip deserialize var customConfigNode = JsonNode.Parse(customConfig.Config); if (customConfigNode != null) {