Browse Source

Add clash_mode to rule

pull/5377/head
2dust 4 months ago
parent
commit
72fecb2b9a
  1. 21
      v2rayN/v2rayN/Handler/CoreConfig/CoreConfigSingbox.cs
  2. 1
      v2rayN/v2rayN/Models/SingboxConfig.cs

21
v2rayN/v2rayN/Handler/CoreConfig/CoreConfigSingbox.cs

@ -903,6 +903,17 @@ namespace v2rayN.Handler.CoreConfig
}); });
} }
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) if (_config.tunModeItem.enableTun)
{ {
singboxConfig.route.auto_detect_interface = true; singboxConfig.route.auto_detect_interface = true;
@ -1192,6 +1203,16 @@ namespace v2rayN.Handler.CoreConfig
detour = Global.DirectTag, detour = Global.DirectTag,
strategy = Utils.IsNullOrEmpty(strategy) ? null : strategy, 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 var lstDomain = singboxConfig.outbounds
.Where(t => !Utils.IsNullOrEmpty(t.server) && Utils.IsDomain(t.server)) .Where(t => !Utils.IsNullOrEmpty(t.server) && Utils.IsDomain(t.server))

1
v2rayN/v2rayN/Models/SingboxConfig.cs

@ -50,6 +50,7 @@
public bool? ip_is_private { get; set; } public bool? ip_is_private { get; set; }
public string? client_subnet { get; set; } public string? client_subnet { get; set; }
public bool? invert { get; set; } public bool? invert { get; set; }
public string? clash_mode { 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 List<string>? network { get; set; } public List<string>? network { get; set; }

Loading…
Cancel
Save