Compare commits

..

2 commits

Author SHA1 Message Date
DHR60
9a01b086e7
Merge 1121e4fed5 into b5800f7dfc 2026-02-23 13:16:30 +00:00
DHR60
1121e4fed5 Fix 2026-02-23 21:16:18 +08:00
3 changed files with 17 additions and 13 deletions

View file

@ -23,7 +23,7 @@ public partial class CoreConfigSingboxService
}
// Process outbounds
var customOutboundsNode = fullConfigTemplateNode["outbounds"] is JsonArray outbounds ? outbounds : new JsonArray();
var customOutboundsNode = fullConfigTemplateNode["outbounds"] is JsonArray outbounds ? outbounds : [];
foreach (var outbound in _coreConfig.outbounds)
{
if (outbound.type.ToLower() is "direct" or "block")
@ -44,7 +44,7 @@ public partial class CoreConfigSingboxService
// Process endpoints
if (_coreConfig.endpoints != null && _coreConfig.endpoints.Count > 0)
{
var customEndpointsNode = fullConfigTemplateNode["endpoints"] is JsonArray endpoints ? endpoints : new JsonArray();
var customEndpointsNode = fullConfigTemplateNode["endpoints"] is JsonArray endpoints ? endpoints : [];
foreach (var endpoint in _coreConfig.endpoints)
{
if (endpoint.detour.IsNullOrEmpty() && !fullConfigTemplate.ProxyDetour.IsNullOrEmpty())

View file

@ -19,9 +19,12 @@ public partial class CoreConfigV2rayService
// Handle balancer and rules modifications (for multiple load scenarios)
if (_coreConfig.routing?.balancers?.Count > 0)
{
var balancer = _coreConfig.routing.balancers.First();
var balancer =
_coreConfig.routing.balancers.FirstOrDefault(b => b.tag == Global.ProxyTag + Global.BalancerTagSuffix, null);
// Modify existing rules in custom config
if (balancer != null)
{
var rulesNode = fullConfigTemplateNode["routing"]?["rules"];
if (rulesNode != null)
{
@ -34,6 +37,7 @@ public partial class CoreConfigV2rayService
}
}
}
}
// Ensure routing node exists
if (fullConfigTemplateNode["routing"] == null)
@ -97,8 +101,8 @@ public partial class CoreConfigV2rayService
continue;
}
}
else if ((!fullConfigTemplate.ProxyDetour.IsNullOrEmpty())
&& ((outbound.streamSettings?.sockopt?.dialerProxy.IsNullOrEmpty() ?? true) == true))
else if (!fullConfigTemplate.ProxyDetour.IsNullOrEmpty()
&& (outbound.streamSettings?.sockopt?.dialerProxy.IsNullOrEmpty() ?? true))
{
var outboundAddress = outbound.settings?.servers?.FirstOrDefault()?.address
?? outbound.settings?.vnext?.FirstOrDefault()?.address

View file

@ -39,9 +39,9 @@ public partial class CoreConfigV2rayService
.ToList() ?? [];
if (balancerTagList.Count > 0)
{
foreach (var rulesItem in _coreConfig.routing.rules.Where(r => balancerTagList.Contains(r.outboundTag)))
foreach (var rulesItem in _coreConfig.routing.rules.Where(r => balancerTagList.Contains(r.outboundTag + Global.BalancerTagSuffix)))
{
rulesItem.balancerTag = rulesItem.outboundTag;
rulesItem.balancerTag = rulesItem.outboundTag + Global.BalancerTagSuffix;
rulesItem.outboundTag = null;
}
}