From bceebc1661055bbb24e78be8fb3234b8fe5f9c32 Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Thu, 5 Feb 2026 16:52:48 +0800
Subject: [PATCH] Add process to routing domains
https://github.com/2dust/v2rayN/issues/8757
---
v2rayN/ServiceLib/Common/Utils.cs | 14 +++++++++++++-
.../CoreConfig/Singbox/SingboxRoutingService.cs | 8 ++------
.../CoreConfig/V2ray/V2rayRoutingService.cs | 2 +-
.../ViewModels/RoutingRuleSettingViewModel.cs | 2 +-
.../Views/RoutingRuleSettingWindow.axaml | 2 +-
v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml | 2 +-
6 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs
index 7824ff4a..7a3fa9a0 100644
--- a/v2rayN/ServiceLib/Common/Utils.cs
+++ b/v2rayN/ServiceLib/Common/Utils.cs
@@ -1086,7 +1086,19 @@ public class Utils
public static string GetExeName(string name)
{
- return IsWindows() ? $"{name}.exe" : name;
+ if (name.IsNullOrEmpty() || IsNonWindows())
+ {
+ return name;
+ }
+
+ if (name.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
+ {
+ return name;
+ }
+ else
+ {
+ return $"{name}.exe";
+ }
}
public static bool IsAdministrator()
diff --git a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxRoutingService.cs b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxRoutingService.cs
index cb4a2af1..0370ce29 100644
--- a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxRoutingService.cs
+++ b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxRoutingService.cs
@@ -277,7 +277,7 @@ public partial class CoreConfigSingboxService
}
}
- if (_config.TunModeItem.EnableTun && item.Process?.Count > 0)
+ if (item.Process?.Count > 0)
{
var ruleProcName = JsonUtils.DeepCopy(rule3);
ruleProcName.process_name ??= [];
@@ -304,11 +304,7 @@ public partial class CoreConfigSingboxService
}
// sing-box strictly matches the exe suffix on Windows
- var procName = process;
- if (Utils.IsWindows() && !procName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
- {
- procName += ".exe";
- }
+ var procName = Utils.GetExeName(process);
ruleProcName.process_name.Add(procName);
}
diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayRoutingService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayRoutingService.cs
index 96984094..8691abb1 100644
--- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayRoutingService.cs
+++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayRoutingService.cs
@@ -109,7 +109,7 @@ public partial class CoreConfigV2rayService
v2rayConfig.routing.rules.Add(it);
hasDomainIp = true;
}
- if (_config.TunModeItem.EnableTun && rule.process?.Count > 0)
+ if (rule.process?.Count > 0)
{
var it = JsonUtils.DeepCopy(rule);
it.domain = null;
diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs
index 71d42218..3baf79c6 100644
--- a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs
@@ -106,7 +106,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
Network = item.Network,
Protocols = Utils.List2String(item.Protocol),
InboundTags = Utils.List2String(item.InboundTag),
- Domains = Utils.List2String((item.Domain ?? []).Concat(item.Ip ?? []).ToList()),
+ Domains = Utils.List2String((item.Domain ?? []).Concat(item.Ip ?? []).ToList().Concat(item.Process ?? []).ToList()),
Enabled = item.Enabled,
Remarks = item.Remarks,
};
diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml
index 7d00b3cc..a770b3ed 100644
--- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml
+++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml
@@ -248,7 +248,7 @@
+ Header="domain / ip / process" />
diff --git a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml
index c8e679a8..83238cb7 100644
--- a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml
+++ b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml
@@ -333,7 +333,7 @@
+ Header="domain / ip / process" />