Skip to content

Commit 398dbbd

Browse files
committed
Bug fix
#5035
1 parent e9b392d commit 398dbbd

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

v2rayN/v2rayN/Handler/CoreConfigSingbox.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,24 +539,38 @@ private int GenRouting(SingboxConfig singboxConfig)
539539
{
540540
try
541541
{
542+
var dnsOutbound = "dns_out";
543+
if (!_config.inbound[0].sniffingEnabled)
544+
{
545+
singboxConfig.route.rules.Add(new()
546+
{
547+
port = [53],
548+
network = "udp",
549+
outbound = dnsOutbound
550+
});
551+
}
552+
542553
if (_config.tunModeItem.enableTun)
543554
{
544555
singboxConfig.route.auto_detect_interface = true;
545556

546557
var tunRules = JsonUtils.Deserialize<List<Rule4Sbox>>(Utils.GetEmbedText(Global.TunSingboxRulesFileName));
547-
singboxConfig.route.rules.AddRange(tunRules);
558+
if (tunRules != null)
559+
{
560+
singboxConfig.route.rules.AddRange(tunRules);
561+
}
548562

549563
GenRoutingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe);
550564
singboxConfig.route.rules.Add(new()
551565
{
552566
port = new() { 53 },
553-
outbound = "dns_out",
567+
outbound = dnsOutbound,
554568
process_name = lstDnsExe
555569
});
556570

557571
singboxConfig.route.rules.Add(new()
558572
{
559-
outbound = "direct",
573+
outbound = Global.DirectTag,
560574
process_name = lstDirectExe
561575
});
562576
}
@@ -805,7 +819,7 @@ private int GenDns(ProfileItem node, SingboxConfig singboxConfig)
805819
{
806820
tag = "local_local",
807821
address = "223.5.5.5",
808-
detour = "direct"
822+
detour = Global.DirectTag,
809823
});
810824
dns4Sbox.rules.Add(new()
811825
{

v2rayN/v2rayN/Models/SingboxConfig.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ public class Route4Sbox
4141
[Serializable]
4242
public class Rule4Sbox
4343
{
44-
public string outbound { get; set; }
45-
public string server { get; set; }
44+
public string? outbound { get; set; }
45+
public string? server { get; set; }
4646
public bool? disable_cache { get; set; }
4747
public List<string>? inbound { get; set; }
4848
public List<string>? protocol { get; set; }
49-
public string type { get; set; }
50-
public string mode { get; set; }
51-
public string network { get; set; }
49+
public string? type { get; set; }
50+
public string? mode { get; set; }
51+
public string? network { get; set; }
5252
public bool? ip_is_private { get; set; }
5353
public List<int>? port { get; set; }
5454
public List<string>? port_range { get; set; }

0 commit comments

Comments
 (0)