mirror of https://github.com/2dust/v2rayN
Adds sing-box DomainStrategy support
parent
5f4a552a77
commit
53d679221e
|
@ -1309,22 +1309,24 @@ public class CoreConfigSingboxService
|
||||||
clash_mode = ERuleMode.Global.ToString()
|
clash_mode = ERuleMode.Global.ToString()
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!(_config.Inbound.First().RouteOnly || _config.TunModeItem.EnableTun))
|
|
||||||
{
|
|
||||||
var domainStrategy = _config.RoutingBasicItem.DomainStrategy4Singbox.IsNullOrEmpty() ? null : _config.RoutingBasicItem.DomainStrategy4Singbox;
|
var domainStrategy = _config.RoutingBasicItem.DomainStrategy4Singbox.IsNullOrEmpty() ? null : _config.RoutingBasicItem.DomainStrategy4Singbox;
|
||||||
var defaultRouting = await ConfigHandler.GetDefaultRouting(_config);
|
var defaultRouting = await ConfigHandler.GetDefaultRouting(_config);
|
||||||
if (defaultRouting.DomainStrategy4Singbox.IsNotEmpty())
|
if (defaultRouting.DomainStrategy4Singbox.IsNotEmpty())
|
||||||
{
|
{
|
||||||
domainStrategy = defaultRouting.DomainStrategy4Singbox;
|
domainStrategy = defaultRouting.DomainStrategy4Singbox;
|
||||||
}
|
}
|
||||||
singboxConfig.route.rules.Add(new()
|
var resolveRule = new Rule4Sbox
|
||||||
{
|
{
|
||||||
action = "resolve",
|
action = "resolve",
|
||||||
strategy = domainStrategy
|
strategy = domainStrategy
|
||||||
});
|
};
|
||||||
|
if (_config.RoutingBasicItem.DomainStrategy == "IPOnDemand")
|
||||||
|
{
|
||||||
|
singboxConfig.route.rules.Add(resolveRule);
|
||||||
}
|
}
|
||||||
|
|
||||||
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
||||||
|
var ipRules = new List<RulesItem>();
|
||||||
if (routing != null)
|
if (routing != null)
|
||||||
{
|
{
|
||||||
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
||||||
|
@ -1333,10 +1335,22 @@ public class CoreConfigSingboxService
|
||||||
if (item.Enabled)
|
if (item.Enabled)
|
||||||
{
|
{
|
||||||
await GenRoutingUserRule(item, singboxConfig);
|
await GenRoutingUserRule(item, singboxConfig);
|
||||||
|
if (item.Ip != null && item.Ip.Count > 0)
|
||||||
|
{
|
||||||
|
ipRules.Add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_config.RoutingBasicItem.DomainStrategy == "IPIfNonMatch")
|
||||||
|
{
|
||||||
|
singboxConfig.route.rules.Add(resolveRule);
|
||||||
|
foreach (var item in ipRules)
|
||||||
|
{
|
||||||
|
await GenRoutingUserRule(item, singboxConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logging.SaveLog(_tag, ex);
|
Logging.SaveLog(_tag, ex);
|
||||||
|
|
Loading…
Reference in New Issue