2dust 2024-05-03 10:29:32 +08:00
parent e9b392d1c0
commit 398dbbd2e5
2 changed files with 23 additions and 9 deletions

View File

@ -539,24 +539,38 @@ namespace v2rayN.Handler
{ {
try try
{ {
var dnsOutbound = "dns_out";
if (!_config.inbound[0].sniffingEnabled)
{
singboxConfig.route.rules.Add(new()
{
port = [53],
network = "udp",
outbound = dnsOutbound
});
}
if (_config.tunModeItem.enableTun) if (_config.tunModeItem.enableTun)
{ {
singboxConfig.route.auto_detect_interface = true; singboxConfig.route.auto_detect_interface = true;
var tunRules = JsonUtils.Deserialize<List<Rule4Sbox>>(Utils.GetEmbedText(Global.TunSingboxRulesFileName)); var tunRules = JsonUtils.Deserialize<List<Rule4Sbox>>(Utils.GetEmbedText(Global.TunSingboxRulesFileName));
singboxConfig.route.rules.AddRange(tunRules); if (tunRules != null)
{
singboxConfig.route.rules.AddRange(tunRules);
}
GenRoutingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe); GenRoutingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe);
singboxConfig.route.rules.Add(new() singboxConfig.route.rules.Add(new()
{ {
port = new() { 53 }, port = new() { 53 },
outbound = "dns_out", outbound = dnsOutbound,
process_name = lstDnsExe process_name = lstDnsExe
}); });
singboxConfig.route.rules.Add(new() singboxConfig.route.rules.Add(new()
{ {
outbound = "direct", outbound = Global.DirectTag,
process_name = lstDirectExe process_name = lstDirectExe
}); });
} }
@ -805,7 +819,7 @@ namespace v2rayN.Handler
{ {
tag = "local_local", tag = "local_local",
address = "223.5.5.5", address = "223.5.5.5",
detour = "direct" detour = Global.DirectTag,
}); });
dns4Sbox.rules.Add(new() dns4Sbox.rules.Add(new()
{ {

View File

@ -41,14 +41,14 @@
[Serializable] [Serializable]
public class Rule4Sbox public class Rule4Sbox
{ {
public string outbound { get; set; } public string? outbound { get; set; }
public string server { get; set; } public string? server { get; set; }
public bool? disable_cache { get; set; } public bool? disable_cache { get; set; }
public List<string>? inbound { get; set; } public List<string>? inbound { get; set; }
public List<string>? protocol { get; set; } public List<string>? protocol { get; set; }
public string type { get; set; } public string? type { get; set; }
public string mode { get; set; } public string? mode { get; set; }
public string network { get; set; } public string? network { get; set; }
public bool? ip_is_private { get; set; } public bool? ip_is_private { get; set; }
public List<int>? port { get; set; } public List<int>? port { get; set; }
public List<string>? port_range { get; set; } public List<string>? port_range { get; set; }