From d748e6eff4ae4563153ecd30f3576fcfdba1fbbc Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Tue, 14 May 2024 15:31:19 +0800 Subject: [PATCH] Add destOverride --- v2rayN/v2rayN/Global.cs | 1 + v2rayN/v2rayN/Handler/CoreConfigV2ray.cs | 1 + v2rayN/v2rayN/Models/ConfigItems.cs | 2 +- v2rayN/v2rayN/Models/V2rayConfig.cs | 2 +- .../ViewModels/OptionSettingViewModel.cs | 2 ++ v2rayN/v2rayN/Views/OptionSettingWindow.xaml | 18 ++++++++++++++---- .../v2rayN/Views/OptionSettingWindow.xaml.cs | 14 ++++++++++++++ 7 files changed, 34 insertions(+), 6 deletions(-) diff --git a/v2rayN/v2rayN/Global.cs b/v2rayN/v2rayN/Global.cs index d5033de2..ec894204 100644 --- a/v2rayN/v2rayN/Global.cs +++ b/v2rayN/v2rayN/Global.cs @@ -175,6 +175,7 @@ namespace v2rayN public static readonly List LogLevels = new() { "debug", "info", "warning", "error", "none" }; public static readonly List InboundTags = new() { "socks", "http", "socks2", "http2" }; public static readonly List RuleProtocols = new() { "http", "tls", "bittorrent" }; + public static readonly List destOverrideProtocols = ["http", "tls", "quic", "fakedns", "fakedns+others"]; public static readonly List TunMtus = new() { "1280", "1408", "1500", "9000" }; public static readonly List TunStacks = new() { "gvisor", "system" }; public static readonly List PresetMsgFilters = new() { "proxy", "direct", "block", "" }; diff --git a/v2rayN/v2rayN/Handler/CoreConfigV2ray.cs b/v2rayN/v2rayN/Handler/CoreConfigV2ray.cs index 03dc9190..8ca96e95 100644 --- a/v2rayN/v2rayN/Handler/CoreConfigV2ray.cs +++ b/v2rayN/v2rayN/Handler/CoreConfigV2ray.cs @@ -162,6 +162,7 @@ namespace v2rayN.Handler inbound.protocol = bSocks ? EInboundProtocol.socks.ToString() : EInboundProtocol.http.ToString(); inbound.settings.udp = inItem.udpEnabled; inbound.sniffing.enabled = inItem.sniffingEnabled; + inbound.sniffing.destOverride = inItem.destOverride; inbound.sniffing.routeOnly = inItem.routeOnly; return inbound; diff --git a/v2rayN/v2rayN/Models/ConfigItems.cs b/v2rayN/v2rayN/Models/ConfigItems.cs index 7b1ff779..af768b49 100644 --- a/v2rayN/v2rayN/Models/ConfigItems.cs +++ b/v2rayN/v2rayN/Models/ConfigItems.cs @@ -47,8 +47,8 @@ namespace v2rayN.Models public bool udpEnabled { get; set; } public bool sniffingEnabled { get; set; } = true; + public List? destOverride { get; set; } = ["http", "tls"]; public bool routeOnly { get; set; } - public bool allowLANConn { get; set; } public bool newPort4LAN { get; set; } diff --git a/v2rayN/v2rayN/Models/V2rayConfig.cs b/v2rayN/v2rayN/Models/V2rayConfig.cs index 73259a97..459f3b83 100644 --- a/v2rayN/v2rayN/Models/V2rayConfig.cs +++ b/v2rayN/v2rayN/Models/V2rayConfig.cs @@ -195,7 +195,7 @@ namespace v2rayN.Models public class Sniffing4Ray { public bool enabled { get; set; } - public List destOverride { get; set; } + public List? destOverride { get; set; } public bool routeOnly { get; set; } } diff --git a/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs b/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs index 77746f60..e0987cda 100644 --- a/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs @@ -20,6 +20,7 @@ namespace v2rayN.ViewModels [Reactive] public int localPort { get; set; } [Reactive] public bool udpEnabled { get; set; } [Reactive] public bool sniffingEnabled { get; set; } + public IList destOverride { get; set; } [Reactive] public bool routeOnly { get; set; } [Reactive] public bool allowLANConn { get; set; } [Reactive] public bool newPort4LAN { get; set; } @@ -279,6 +280,7 @@ namespace v2rayN.ViewModels _config.inbound[0].localPort = localPort; _config.inbound[0].udpEnabled = udpEnabled; _config.inbound[0].sniffingEnabled = sniffingEnabled; + _config.inbound[0].destOverride = destOverride?.ToList(); _config.inbound[0].routeOnly = routeOnly; _config.inbound[0].allowLANConn = allowLANConn; _config.inbound[0].newPort4LAN = newPort4LAN; diff --git a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml index 201a985d..1c10ca0d 100644 --- a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml @@ -119,12 +119,22 @@ VerticalAlignment="Center" Style="{StaticResource ToolbarTextBlock}" Text="{x:Static resx:ResUI.TbSettingsSniffingEnabled}" /> - + Grid.ColumnSpan="2" + Orientation="Horizontal"> + + + + { + clbdestOverride.Items.Add(it); + }); + _config.inbound[0].destOverride?.ForEach(it => + { + clbdestOverride.SelectedItems.Add(it); + }); Global.IEProxyProtocols.ForEach(it => { cmbsystemProxyAdvancedProtocol.Items.Add(it); @@ -213,5 +222,10 @@ namespace v2rayN.Views } return lstFonts; } + + private void ClbdestOverride_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) + { + ViewModel.destOverride = clbdestOverride.SelectedItems.Cast().ToList(); + } } } \ No newline at end of file