Skip to content

Commit d748e6e

Browse files
committed
Add destOverride
1 parent 315d4b7 commit d748e6e

File tree

7 files changed

+34
-6
lines changed

7 files changed

+34
-6
lines changed

v2rayN/v2rayN/Global.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ internal class Global
175175
public static readonly List<string> LogLevels = new() { "debug", "info", "warning", "error", "none" };
176176
public static readonly List<string> InboundTags = new() { "socks", "http", "socks2", "http2" };
177177
public static readonly List<string> RuleProtocols = new() { "http", "tls", "bittorrent" };
178+
public static readonly List<string> destOverrideProtocols = ["http", "tls", "quic", "fakedns", "fakedns+others"];
178179
public static readonly List<string> TunMtus = new() { "1280", "1408", "1500", "9000" };
179180
public static readonly List<string> TunStacks = new() { "gvisor", "system" };
180181
public static readonly List<string> PresetMsgFilters = new() { "proxy", "direct", "block", "" };

v2rayN/v2rayN/Handler/CoreConfigV2ray.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ private Inbounds4Ray GetInbound(InItem inItem, EInboundProtocol protocol, bool b
162162
inbound.protocol = bSocks ? EInboundProtocol.socks.ToString() : EInboundProtocol.http.ToString();
163163
inbound.settings.udp = inItem.udpEnabled;
164164
inbound.sniffing.enabled = inItem.sniffingEnabled;
165+
inbound.sniffing.destOverride = inItem.destOverride;
165166
inbound.sniffing.routeOnly = inItem.routeOnly;
166167

167168
return inbound;

v2rayN/v2rayN/Models/ConfigItems.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public class InItem
4747
public bool udpEnabled { get; set; }
4848

4949
public bool sniffingEnabled { get; set; } = true;
50+
public List<string>? destOverride { get; set; } = ["http", "tls"];
5051
public bool routeOnly { get; set; }
51-
5252
public bool allowLANConn { get; set; }
5353

5454
public bool newPort4LAN { get; set; }

v2rayN/v2rayN/Models/V2rayConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public class UsersItem4Ray
195195
public class Sniffing4Ray
196196
{
197197
public bool enabled { get; set; }
198-
public List<string> destOverride { get; set; }
198+
public List<string>? destOverride { get; set; }
199199
public bool routeOnly { get; set; }
200200
}
201201

v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class OptionSettingViewModel : ReactiveObject
2020
[Reactive] public int localPort { get; set; }
2121
[Reactive] public bool udpEnabled { get; set; }
2222
[Reactive] public bool sniffingEnabled { get; set; }
23+
public IList<string> destOverride { get; set; }
2324
[Reactive] public bool routeOnly { get; set; }
2425
[Reactive] public bool allowLANConn { get; set; }
2526
[Reactive] public bool newPort4LAN { get; set; }
@@ -279,6 +280,7 @@ private void SaveSetting()
279280
_config.inbound[0].localPort = localPort;
280281
_config.inbound[0].udpEnabled = udpEnabled;
281282
_config.inbound[0].sniffingEnabled = sniffingEnabled;
283+
_config.inbound[0].destOverride = destOverride?.ToList();
282284
_config.inbound[0].routeOnly = routeOnly;
283285
_config.inbound[0].allowLANConn = allowLANConn;
284286
_config.inbound[0].newPort4LAN = newPort4LAN;

v2rayN/v2rayN/Views/OptionSettingWindow.xaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,22 @@
119119
VerticalAlignment="Center"
120120
Style="{StaticResource ToolbarTextBlock}"
121121
Text="{x:Static resx:ResUI.TbSettingsSniffingEnabled}" />
122-
<ToggleButton
123-
x:Name="togsniffingEnabled"
122+
<StackPanel
124123
Grid.Row="2"
125124
Grid.Column="1"
126-
Margin="{StaticResource SettingItemMargin}"
127-
HorizontalAlignment="Left" />
125+
Grid.ColumnSpan="2"
126+
Orientation="Horizontal">
127+
<ToggleButton
128+
x:Name="togsniffingEnabled"
129+
Margin="{StaticResource SettingItemMargin}"
130+
HorizontalAlignment="Left" />
131+
<ListBox
132+
x:Name="clbdestOverride"
133+
Margin="4"
134+
HorizontalAlignment="Left"
135+
FontSize="{DynamicResource StdFontSize}"
136+
Style="{StaticResource MaterialDesignFilterChipPrimaryListBox}" />
137+
</StackPanel>
128138

129139
<TextBlock
130140
Grid.Row="3"

v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ public OptionSettingWindow()
3434

3535
ViewModel = new OptionSettingViewModel(this);
3636

37+
clbdestOverride.SelectionChanged += ClbdestOverride_SelectionChanged;
38+
Global.destOverrideProtocols.ForEach(it =>
39+
{
40+
clbdestOverride.Items.Add(it);
41+
});
42+
_config.inbound[0].destOverride?.ForEach(it =>
43+
{
44+
clbdestOverride.SelectedItems.Add(it);
45+
});
3746
Global.IEProxyProtocols.ForEach(it =>
3847
{
3948
cmbsystemProxyAdvancedProtocol.Items.Add(it);
@@ -213,5 +222,10 @@ private List<string> GetFonts(string path)
213222
}
214223
return lstFonts;
215224
}
225+
226+
private void ClbdestOverride_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
227+
{
228+
ViewModel.destOverride = clbdestOverride.SelectedItems.Cast<string>().ToList();
229+
}
216230
}
217231
}

0 commit comments

Comments
 (0)