This commit is contained in:
DHR60 2026-01-16 09:47:47 +00:00 committed by GitHub
commit ed2fce68ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 69 additions and 11 deletions

View file

@ -68,6 +68,7 @@ public class Rule4Sbox
public List<string>? ip_cidr { get; set; }
public List<string>? source_ip_cidr { get; set; }
public List<string>? process_name { get; set; }
public List<string>? process_path { get; set; }
public List<string>? rule_set { get; set; }
public List<Rule4Sbox>? rules { get; set; }
public string? action { get; set; }

View file

@ -256,6 +256,8 @@ public class RulesItem4Ray
public List<string>? domain { get; set; }
public List<string>? protocol { get; set; }
public List<string>? process { get; set; }
}
public class BalancersItem4Ray

View file

@ -3268,7 +3268,7 @@ namespace ServiceLib.Resx {
}
/// <summary>
/// 查找类似 Full process name (Tun mode) 的本地化字符串。
/// 查找类似 Process (Tun mode) 的本地化字符串。
/// </summary>
public static string TbRoutingRuleProcess {
get {

View file

@ -1027,7 +1027,7 @@
<value>پروتکل sing-box Mux</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>نام کامل فرانید (حالت Tun)</value>
<value>Process (Tun mode)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP or IP CIDR</value>

View file

@ -1024,7 +1024,7 @@
<value>Protocole de multiplexage Mux (sing-box)</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>Nom complet du processus (mode Tun)</value>
<value>Process (Tun mode)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP ou IP CIDR</value>

View file

@ -1027,7 +1027,7 @@
<value>sing-box Mux protokoll</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>Teljes folyamatnév (Tun mód)</value>
<value>Process (Tun mode)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP vagy IP CIDR</value>

View file

@ -1027,7 +1027,7 @@
<value>sing-box Mux Protocol</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>Full process name (Tun mode)</value>
<value>Process (Tun mode)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP or IP CIDR</value>

View file

@ -1027,7 +1027,7 @@
<value>Протокол Mux для sing-box</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>Полное имя процесса (режим TUN)</value>
<value>Process (Tun mode)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP-адрес или сеть CIDR</value>

View file

@ -1024,7 +1024,7 @@
<value>sing-box Mux 多路复用协议</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>进程名全称 (Tun 模式)</value>
<value>进程 (Tun 模式)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP 或 IP CIDR</value>

View file

@ -1024,7 +1024,7 @@
<value>sing-box Mux 多路復用協定</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>行程名全稱 (Tun 模式)</value>
<value>行程 (Tun 模式)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP 或 IP CIDR</value>

View file

@ -280,9 +280,49 @@ public partial class CoreConfigSingboxService
if (_config.TunModeItem.EnableTun && item.Process?.Count > 0)
{
rule3.process_name = item.Process;
rules.Add(rule3);
hasDomainIp = true;
var ruleProcName = JsonUtils.DeepCopy(rule3);
var ruleProcPath = JsonUtils.DeepCopy(rule3);
foreach (var process in item.Process)
{
// sing-box doesn't support this, fall back to process name match
if (process is "self/" or "xray/")
{
ruleProcName.process_name.Add(Utils.GetExeName("sing-box"));
continue;
}
if (process.Contains('/') || process.Contains('\\'))
{
var procPath = process;
if (Utils.IsWindows())
{
procPath = procPath.Replace('/', '\\');
}
ruleProcPath.process_path.Add(procPath);
continue;
}
// sing-box strictly matches the exe suffix on Windows
var procName = process;
if (Utils.IsWindows() && !procName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
{
procName += ".exe";
}
ruleProcName.process_name.Add(procName);
}
if (ruleProcName.process_name.Count > 0)
{
rules.Add(ruleProcName);
hasDomainIp = true;
}
if (ruleProcPath.process_path.Count > 0)
{
rules.Add(ruleProcPath);
hasDomainIp = true;
}
}
if (!hasDomainIp

View file

@ -77,12 +77,17 @@ public partial class CoreConfigV2rayService
{
rule.inboundTag = null;
}
if (rule.process?.Count == 0)
{
rule.process = null;
}
var hasDomainIp = false;
if (rule.domain?.Count > 0)
{
var it = JsonUtils.DeepCopy(rule);
it.ip = null;
it.process = null;
it.type = "field";
for (var k = it.domain.Count - 1; k >= 0; k--)
{
@ -99,6 +104,16 @@ public partial class CoreConfigV2rayService
{
var it = JsonUtils.DeepCopy(rule);
it.domain = null;
it.process = null;
it.type = "field";
v2rayConfig.routing.rules.Add(it);
hasDomainIp = true;
}
if (_config.TunModeItem.EnableTun && rule.process?.Count > 0)
{
var it = JsonUtils.DeepCopy(rule);
it.domain = null;
it.ip = null;
it.type = "field";
v2rayConfig.routing.rules.Add(it);
hasDomainIp = true;