|
|
@ -1,4 +1,5 @@
|
|
|
|
using System.Data;
|
|
|
|
using System.Data;
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
using System.Net;
|
|
|
|
using System.Net;
|
|
|
|
using System.Net.NetworkInformation;
|
|
|
|
using System.Net.NetworkInformation;
|
|
|
|
using v2rayN.Enums;
|
|
|
|
using v2rayN.Enums;
|
|
|
@ -966,28 +967,42 @@ namespace v2rayN.Handler.CoreConfig
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Local srs files address
|
|
|
|
|
|
|
|
var localSrss = Utils.GetBinPath("srss");
|
|
|
|
|
|
|
|
|
|
|
|
//Add ruleset srs
|
|
|
|
//Add ruleset srs
|
|
|
|
singboxConfig.route.rule_set = [];
|
|
|
|
singboxConfig.route.rule_set = [];
|
|
|
|
foreach (var item in new HashSet<string>(ruleSets))
|
|
|
|
foreach (var item in new HashSet<string>(ruleSets))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (Utils.IsNullOrEmpty(item)) { continue; }
|
|
|
|
if (Utils.IsNullOrEmpty(item)) { continue; }
|
|
|
|
var customRuleset = customRulesets.FirstOrDefault(t => t.tag != null && t.tag.Equals(item));
|
|
|
|
var customRuleset = customRulesets.FirstOrDefault(t => t.tag != null && t.tag.Equals(item));
|
|
|
|
if (customRuleset != null)
|
|
|
|
if (customRuleset is null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
singboxConfig.route.rule_set.Add(customRuleset);
|
|
|
|
var pathSrs = Path.Combine(localSrss, $"{item}.srs");
|
|
|
|
|
|
|
|
if (File.Exists(pathSrs))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
customRuleset = new()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
type = "local",
|
|
|
|
|
|
|
|
format = "binary",
|
|
|
|
|
|
|
|
tag = item,
|
|
|
|
|
|
|
|
path = pathSrs
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
singboxConfig.route.rule_set.Add(new()
|
|
|
|
customRuleset = new()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
type = "remote",
|
|
|
|
type = "remote",
|
|
|
|
format = "binary",
|
|
|
|
format = "binary",
|
|
|
|
tag = item,
|
|
|
|
tag = item,
|
|
|
|
url = string.Format(Global.SingboxRulesetUrl, item.StartsWith(geosite) ? geosite : geoip, item),
|
|
|
|
url = string.Format(Global.SingboxRulesetUrl, item.StartsWith(geosite) ? geosite : geoip, item),
|
|
|
|
download_detour = Global.ProxyTag
|
|
|
|
download_detour = Global.ProxyTag
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
singboxConfig.route.rule_set.Add(customRuleset);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|