Skip to content

Commit

Permalink
Add clash_mode to rule
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Jul 14, 2024
1 parent 4e9dfe5 commit 72fecb2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions v2rayN/v2rayN/Handler/CoreConfig/CoreConfigSingbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,17 @@ private int GenRouting(SingboxConfig singboxConfig)
});
}

singboxConfig.route.rules.Insert(0, new()
{
outbound = Global.DirectTag,
clash_mode = ERuleMode.Direct.ToString()
});
singboxConfig.route.rules.Insert(0, new()
{
outbound = Global.ProxyTag,
clash_mode = ERuleMode.Global.ToString()
});

if (_config.tunModeItem.enableTun)
{
singboxConfig.route.auto_detect_interface = true;
Expand Down Expand Up @@ -1192,6 +1203,16 @@ private int GenDnsDomains(ProfileItem? node, SingboxConfig singboxConfig, string
detour = Global.DirectTag,
strategy = Utils.IsNullOrEmpty(strategy) ? null : strategy,
});
dns4Sbox.rules.Insert(0, new()
{
server = tag,
clash_mode = ERuleMode.Direct.ToString()
});
dns4Sbox.rules.Insert(0, new()
{
server = dns4Sbox.servers.Where(t => t.detour == Global.ProxyTag).Select(t => t.tag).FirstOrDefault() ?? "remote",
clash_mode = ERuleMode.Global.ToString()
});

var lstDomain = singboxConfig.outbounds
.Where(t => !Utils.IsNullOrEmpty(t.server) && Utils.IsDomain(t.server))
Expand Down
1 change: 1 addition & 0 deletions v2rayN/v2rayN/Models/SingboxConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class Rule4Sbox
public bool? ip_is_private { get; set; }
public string? client_subnet { get; set; }
public bool? invert { get; set; }
public string? clash_mode { get; set; }
public List<string>? inbound { get; set; }
public List<string>? protocol { get; set; }
public List<string>? network { get; set; }
Expand Down

0 comments on commit 72fecb2

Please sign in to comment.