mirror of
https://github.com/2dust/v2rayN.git
synced 2026-01-15 10:29:33 +00:00
feat: Add custom Tun IPv4 and IPv6 address settings
- Updated UI resources to include options for custom Tun IPv4 and IPv6 addresses. - Modified the SingboxInboundService to handle custom Tun addresses based on user input. - Enhanced OptionSettingViewModel to store and manage custom Tun address values. - Updated OptionSettingWindow views and bindings to reflect new settings for Tun addresses.
This commit is contained in:
parent
83c63b914a
commit
4addce2c2f
11 changed files with 618 additions and 519 deletions
|
|
@ -91,6 +91,8 @@ public static class ConfigHandler
|
|||
{
|
||||
EnableTun = false,
|
||||
Mtu = 9000,
|
||||
TunIPv4Address = "172.18.0.1/30",
|
||||
TunIPv6Address = "fdfe:dcba:9876::1/126",
|
||||
};
|
||||
config.GuiItem ??= new();
|
||||
config.MsgUIItem ??= new();
|
||||
|
|
|
|||
|
|
@ -147,6 +147,8 @@ public class TunModeItem
|
|||
public int Mtu { get; set; }
|
||||
public bool EnableExInbound { get; set; }
|
||||
public bool EnableIPv6Address { get; set; }
|
||||
public string TunIPv4Address { get; set; }
|
||||
public string TunIPv6Address { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
|
|
|||
1046
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
1046
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1077,6 +1077,12 @@
|
|||
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
|
||||
<value>Enable IPv6 Address</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunIPv4Address" xml:space="preserve">
|
||||
<value>Custom Tun IPv4 Address</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunIPv6Address" xml:space="preserve">
|
||||
<value>Custom Tun IPv6 Address</value>
|
||||
</data>
|
||||
<data name="menuAddWireguardServer" xml:space="preserve">
|
||||
<value>Add [WireGuard] </value>
|
||||
</data>
|
||||
|
|
@ -1641,4 +1647,4 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
|||
<data name="menuServerList2" xml:space="preserve">
|
||||
<value>Configuration Item 2, Select and add from self-built</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
|
|
|
|||
|
|
@ -1074,6 +1074,12 @@
|
|||
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
|
||||
<value>启用 IPv6</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunIPv4Address" xml:space="preserve">
|
||||
<value>自定义 Tun IPv4 地址</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunIPv6Address" xml:space="preserve">
|
||||
<value>自定义 Tun IPv6 地址</value>
|
||||
</data>
|
||||
<data name="menuAddWireguardServer" xml:space="preserve">
|
||||
<value>添加 [WireGuard] </value>
|
||||
</data>
|
||||
|
|
@ -1638,4 +1644,4 @@
|
|||
<data name="menuServerList2" xml:space="preserve">
|
||||
<value>子配置项二,从自建中选择添加</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
|
|
|
|||
|
|
@ -68,7 +68,11 @@ public partial class CoreConfigSingboxService
|
|||
tunInbound.stack = _config.TunModeItem.Stack;
|
||||
if (_config.TunModeItem.EnableIPv6Address == false)
|
||||
{
|
||||
tunInbound.address = ["172.18.0.1/30"];
|
||||
tunInbound.address = [_config.TunModeItem.TunIPv4Address];
|
||||
}
|
||||
else
|
||||
{
|
||||
tunInbound.address = [_config.TunModeItem.TunIPv4Address, _config.TunModeItem.TunIPv6Address];
|
||||
}
|
||||
|
||||
singboxConfig.inbounds.Add(tunInbound);
|
||||
|
|
|
|||
|
|
@ -97,6 +97,8 @@ public class OptionSettingViewModel : MyReactiveObject
|
|||
[Reactive] public int TunMtu { get; set; }
|
||||
[Reactive] public bool TunEnableExInbound { get; set; }
|
||||
[Reactive] public bool TunEnableIPv6Address { get; set; }
|
||||
[Reactive] public string TunIPv4Address { get; set; }
|
||||
[Reactive] public string TunIPv6Address { get; set; }
|
||||
|
||||
#endregion Tun mode
|
||||
|
||||
|
|
@ -221,6 +223,8 @@ public class OptionSettingViewModel : MyReactiveObject
|
|||
TunMtu = _config.TunModeItem.Mtu;
|
||||
TunEnableExInbound = _config.TunModeItem.EnableExInbound;
|
||||
TunEnableIPv6Address = _config.TunModeItem.EnableIPv6Address;
|
||||
TunIPv4Address = _config.TunModeItem.TunIPv4Address;
|
||||
TunIPv6Address = _config.TunModeItem.TunIPv6Address;
|
||||
|
||||
#endregion Tun mode
|
||||
|
||||
|
|
@ -377,6 +381,8 @@ public class OptionSettingViewModel : MyReactiveObject
|
|||
_config.TunModeItem.Mtu = TunMtu;
|
||||
_config.TunModeItem.EnableExInbound = TunEnableExInbound;
|
||||
_config.TunModeItem.EnableIPv6Address = TunEnableIPv6Address;
|
||||
_config.TunModeItem.TunIPv4Address = TunIPv4Address;
|
||||
_config.TunModeItem.TunIPv6Address = TunIPv6Address;
|
||||
|
||||
//coreType
|
||||
await SaveCoreType();
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@
|
|||
VerticalAlignment="Center"
|
||||
IsVisible="{Binding BlIsLinux}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsHide2TrayWhenCloseTip}" />
|
||||
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="10"
|
||||
Grid.Column="0"
|
||||
|
|
@ -786,7 +786,7 @@
|
|||
Margin="{StaticResource Margin4}"
|
||||
ColumnDefinitions="Auto,Auto,Auto"
|
||||
DockPanel.Dock="Top"
|
||||
RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">
|
||||
RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="2"
|
||||
|
|
@ -868,6 +868,30 @@
|
|||
Margin="{StaticResource Margin4}"
|
||||
HorizontalAlignment="Left" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="8"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource Margin4}"
|
||||
VerticalAlignment="Center"
|
||||
Text="{x:Static resx:ResUI.TbSettingsTunIPv4Address}" />
|
||||
<TextBox
|
||||
x:Name="txtTunIPv4Address"
|
||||
Grid.Row="8"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="{StaticResource Margin4}" />
|
||||
<TextBlock
|
||||
Grid.Row="9"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource Margin4}"
|
||||
VerticalAlignment="Center"
|
||||
Text="{x:Static resx:ResUI.TbSettingsTunIPv6Address}" />
|
||||
<TextBox
|
||||
x:Name="txtTunIPv6Address"
|
||||
Grid.Row="9"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="{StaticResource Margin4}" />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
|
|||
this.Bind(ViewModel, vm => vm.TunMtu, v => v.cmbMtu.SelectedValue).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunEnableExInbound, v => v.togEnableExInbound.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunEnableIPv6Address, v => v.togEnableIPv6Address.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunIPv4Address, v => v.txtTunIPv4Address.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunIPv6Address, v => v.txtTunIPv6Address.Text).DisposeWith(disposables);
|
||||
|
||||
this.Bind(ViewModel, vm => vm.CoreType1, v => v.cmbCoreType1.SelectedValue).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.CoreType2, v => v.cmbCoreType2.SelectedValue).DisposeWith(disposables);
|
||||
|
|
|
|||
|
|
@ -1030,6 +1030,8 @@
|
|||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
|
|
@ -1124,6 +1126,31 @@
|
|||
Grid.Column="1"
|
||||
Margin="{StaticResource Margin8}"
|
||||
HorizontalAlignment="Left" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="8"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource Margin4}"
|
||||
VerticalAlignment="Center"
|
||||
Text="{x:Static resx:ResUI.TbSettingsTunIPv4Address}" />
|
||||
<TextBox
|
||||
x:Name="txtTunIPv4Address"
|
||||
Grid.Row="8"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="{StaticResource Margin4}" />
|
||||
<TextBlock
|
||||
Grid.Row="9"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource Margin4}"
|
||||
VerticalAlignment="Center"
|
||||
Text="{x:Static resx:ResUI.TbSettingsTunIPv6Address}" />
|
||||
<TextBox
|
||||
x:Name="txtTunIPv6Address"
|
||||
Grid.Row="9"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="{StaticResource Margin4}" />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ public partial class OptionSettingWindow
|
|||
this.Bind(ViewModel, vm => vm.TunMtu, v => v.cmbMtu.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunEnableExInbound, v => v.togEnableExInbound.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunEnableIPv6Address, v => v.togEnableIPv6Address.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunIPv4Address, v => v.txtTunIPv4Address.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunIPv6Address, v => v.txtTunIPv6Address.Text).DisposeWith(disposables);
|
||||
|
||||
this.Bind(ViewModel, vm => vm.CoreType1, v => v.cmbCoreType1.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.CoreType2, v => v.cmbCoreType2.Text).DisposeWith(disposables);
|
||||
|
|
|
|||
Loading…
Reference in a new issue