Skip to content

Commit

Permalink
Add destOverride
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed May 14, 2024
1 parent 315d4b7 commit d748e6e
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions v2rayN/v2rayN/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ internal class Global
public static readonly List<string> LogLevels = new() { "debug", "info", "warning", "error", "none" };
public static readonly List<string> InboundTags = new() { "socks", "http", "socks2", "http2" };
public static readonly List<string> RuleProtocols = new() { "http", "tls", "bittorrent" };
public static readonly List<string> destOverrideProtocols = ["http", "tls", "quic", "fakedns", "fakedns+others"];
public static readonly List<string> TunMtus = new() { "1280", "1408", "1500", "9000" };
public static readonly List<string> TunStacks = new() { "gvisor", "system" };
public static readonly List<string> PresetMsgFilters = new() { "proxy", "direct", "block", "" };
Expand Down
1 change: 1 addition & 0 deletions v2rayN/v2rayN/Handler/CoreConfigV2ray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ private Inbounds4Ray GetInbound(InItem inItem, EInboundProtocol protocol, bool b
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;
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Models/ConfigItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public class InItem
public bool udpEnabled { get; set; }

public bool sniffingEnabled { get; set; } = true;
public List<string>? destOverride { get; set; } = ["http", "tls"];
public bool routeOnly { get; set; }

public bool allowLANConn { get; set; }

public bool newPort4LAN { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Models/V2rayConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public class UsersItem4Ray
public class Sniffing4Ray
{
public bool enabled { get; set; }
public List<string> destOverride { get; set; }
public List<string>? destOverride { get; set; }
public bool routeOnly { get; set; }
}

Expand Down
2 changes: 2 additions & 0 deletions v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class OptionSettingViewModel : ReactiveObject
[Reactive] public int localPort { get; set; }
[Reactive] public bool udpEnabled { get; set; }
[Reactive] public bool sniffingEnabled { get; set; }
public IList<string> destOverride { get; set; }
[Reactive] public bool routeOnly { get; set; }
[Reactive] public bool allowLANConn { get; set; }
[Reactive] public bool newPort4LAN { get; set; }
Expand Down Expand Up @@ -279,6 +280,7 @@ private void SaveSetting()
_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;
Expand Down
18 changes: 14 additions & 4 deletions v2rayN/v2rayN/Views/OptionSettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,22 @@
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsSniffingEnabled}" />
<ToggleButton
x:Name="togsniffingEnabled"
<StackPanel
Grid.Row="2"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
Grid.ColumnSpan="2"
Orientation="Horizontal">
<ToggleButton
x:Name="togsniffingEnabled"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
<ListBox
x:Name="clbdestOverride"
Margin="4"
HorizontalAlignment="Left"
FontSize="{DynamicResource StdFontSize}"
Style="{StaticResource MaterialDesignFilterChipPrimaryListBox}" />
</StackPanel>

<TextBlock
Grid.Row="3"
Expand Down
14 changes: 14 additions & 0 deletions v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ public OptionSettingWindow()

ViewModel = new OptionSettingViewModel(this);

clbdestOverride.SelectionChanged += ClbdestOverride_SelectionChanged;
Global.destOverrideProtocols.ForEach(it =>
{
clbdestOverride.Items.Add(it);
});
_config.inbound[0].destOverride?.ForEach(it =>
{
clbdestOverride.SelectedItems.Add(it);
});
Global.IEProxyProtocols.ForEach(it =>
{
cmbsystemProxyAdvancedProtocol.Items.Add(it);
Expand Down Expand Up @@ -213,5 +222,10 @@ private List<string> GetFonts(string path)
}
return lstFonts;
}

private void ClbdestOverride_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
ViewModel.destOverride = clbdestOverride.SelectedItems.Cast<string>().ToList();
}
}
}

0 comments on commit d748e6e

Please sign in to comment.