mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 21:23:04 +00:00
Compare commits
1 commit
9a01b086e7
...
990b2b07fa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
990b2b07fa |
3 changed files with 13 additions and 17 deletions
|
|
@ -23,7 +23,7 @@ public partial class CoreConfigSingboxService
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process outbounds
|
// Process outbounds
|
||||||
var customOutboundsNode = fullConfigTemplateNode["outbounds"] is JsonArray outbounds ? outbounds : [];
|
var customOutboundsNode = fullConfigTemplateNode["outbounds"] is JsonArray outbounds ? outbounds : new JsonArray();
|
||||||
foreach (var outbound in _coreConfig.outbounds)
|
foreach (var outbound in _coreConfig.outbounds)
|
||||||
{
|
{
|
||||||
if (outbound.type.ToLower() is "direct" or "block")
|
if (outbound.type.ToLower() is "direct" or "block")
|
||||||
|
|
@ -44,7 +44,7 @@ public partial class CoreConfigSingboxService
|
||||||
// Process endpoints
|
// Process endpoints
|
||||||
if (_coreConfig.endpoints != null && _coreConfig.endpoints.Count > 0)
|
if (_coreConfig.endpoints != null && _coreConfig.endpoints.Count > 0)
|
||||||
{
|
{
|
||||||
var customEndpointsNode = fullConfigTemplateNode["endpoints"] is JsonArray endpoints ? endpoints : [];
|
var customEndpointsNode = fullConfigTemplateNode["endpoints"] is JsonArray endpoints ? endpoints : new JsonArray();
|
||||||
foreach (var endpoint in _coreConfig.endpoints)
|
foreach (var endpoint in _coreConfig.endpoints)
|
||||||
{
|
{
|
||||||
if (endpoint.detour.IsNullOrEmpty() && !fullConfigTemplate.ProxyDetour.IsNullOrEmpty())
|
if (endpoint.detour.IsNullOrEmpty() && !fullConfigTemplate.ProxyDetour.IsNullOrEmpty())
|
||||||
|
|
|
||||||
|
|
@ -19,22 +19,18 @@ public partial class CoreConfigV2rayService
|
||||||
// Handle balancer and rules modifications (for multiple load scenarios)
|
// Handle balancer and rules modifications (for multiple load scenarios)
|
||||||
if (_coreConfig.routing?.balancers?.Count > 0)
|
if (_coreConfig.routing?.balancers?.Count > 0)
|
||||||
{
|
{
|
||||||
var balancer =
|
var balancer = _coreConfig.routing.balancers.First();
|
||||||
_coreConfig.routing.balancers.FirstOrDefault(b => b.tag == Global.ProxyTag + Global.BalancerTagSuffix, null);
|
|
||||||
|
|
||||||
// Modify existing rules in custom config
|
// Modify existing rules in custom config
|
||||||
if (balancer != null)
|
var rulesNode = fullConfigTemplateNode["routing"]?["rules"];
|
||||||
|
if (rulesNode != null)
|
||||||
{
|
{
|
||||||
var rulesNode = fullConfigTemplateNode["routing"]?["rules"];
|
foreach (var rule in rulesNode.AsArray())
|
||||||
if (rulesNode != null)
|
|
||||||
{
|
{
|
||||||
foreach (var rule in rulesNode.AsArray())
|
if (rule["outboundTag"]?.GetValue<string>() == Global.ProxyTag)
|
||||||
{
|
{
|
||||||
if (rule["outboundTag"]?.GetValue<string>() == Global.ProxyTag)
|
rule.AsObject().Remove("outboundTag");
|
||||||
{
|
rule["balancerTag"] = balancer.tag;
|
||||||
rule.AsObject().Remove("outboundTag");
|
|
||||||
rule["balancerTag"] = balancer.tag;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -101,8 +97,8 @@ public partial class CoreConfigV2rayService
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!fullConfigTemplate.ProxyDetour.IsNullOrEmpty()
|
else if ((!fullConfigTemplate.ProxyDetour.IsNullOrEmpty())
|
||||||
&& (outbound.streamSettings?.sockopt?.dialerProxy.IsNullOrEmpty() ?? true))
|
&& ((outbound.streamSettings?.sockopt?.dialerProxy.IsNullOrEmpty() ?? true) == true))
|
||||||
{
|
{
|
||||||
var outboundAddress = outbound.settings?.servers?.FirstOrDefault()?.address
|
var outboundAddress = outbound.settings?.servers?.FirstOrDefault()?.address
|
||||||
?? outbound.settings?.vnext?.FirstOrDefault()?.address
|
?? outbound.settings?.vnext?.FirstOrDefault()?.address
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,9 @@ public partial class CoreConfigV2rayService
|
||||||
.ToList() ?? [];
|
.ToList() ?? [];
|
||||||
if (balancerTagList.Count > 0)
|
if (balancerTagList.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var rulesItem in _coreConfig.routing.rules.Where(r => balancerTagList.Contains(r.outboundTag + Global.BalancerTagSuffix)))
|
foreach (var rulesItem in _coreConfig.routing.rules.Where(r => balancerTagList.Contains(r.outboundTag)))
|
||||||
{
|
{
|
||||||
rulesItem.balancerTag = rulesItem.outboundTag + Global.BalancerTagSuffix;
|
rulesItem.balancerTag = rulesItem.outboundTag;
|
||||||
rulesItem.outboundTag = null;
|
rulesItem.outboundTag = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue