Add ipv6 option for Tun mode

This commit is contained in:
2dust 2023-12-26 18:13:12 +08:00
parent b74188d904
commit 34f63f9006
13 changed files with 91 additions and 3 deletions

View file

@ -39,6 +39,7 @@ namespace v2rayN
public const string V2raySampleHttpresponseFileName = "v2rayN.Sample.SampleHttpresponse";
public const string V2raySampleInbound = "v2rayN.Sample.SampleInbound";
public const string V2raySampleOutbound = "v2rayN.Sample.SampleOutbound";
public const string SingboxSampleOutbound = "v2rayN.Sample.SingboxSampleOutbound";
public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_";
public const string TunSingboxDNSFileName = "v2rayN.Sample.tun_singbox_dns";
public const string TunSingboxInboundFileName = "v2rayN.Sample.tun_singbox_inbound";

View file

@ -180,6 +180,10 @@ namespace v2rayN.Handler
tunInbound.mtu = _config.tunModeItem.mtu;
tunInbound.strict_route = _config.tunModeItem.strictRoute;
tunInbound.stack = _config.tunModeItem.stack;
if (_config.tunModeItem.enableIPv6Address == false)
{
tunInbound.inet6_address = null;
}
singboxConfig.inbounds.Add(tunInbound);
}
@ -450,7 +454,7 @@ namespace v2rayN.Handler
//current proxy
var outbound = singboxConfig.outbounds[0];
var txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
var txtOutbound = Utils.GetEmbedText(Global.SingboxSampleOutbound);
//Previous proxy
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile!);

View file

@ -164,6 +164,7 @@ namespace v2rayN.Mode
public string stack { get; set; }
public int mtu { get; set; }
public bool enableExInbound { get; set; }
public bool enableIPv6Address { get; set; } = true;
}
[Serializable]

View file

@ -72,7 +72,7 @@
public string? domain_strategy { get; set; }
public string interface_name { get; set; }
public string inet4_address { get; set; }
public string inet6_address { get; set; }
public string? inet6_address { get; set; }
public int? mtu { get; set; }
public bool? auto_route { get; set; }
public bool? strict_route { get; set; }

View file

@ -2554,6 +2554,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Enable additional Inbound 的本地化字符串。
/// </summary>
public static string TbSettingsEnableExInbound {
get {
return ResourceManager.GetString("TbSettingsEnableExInbound", resourceCulture);
}
}
/// <summary>
/// 查找类似 Enable hardware acceleration(Require restart) 的本地化字符串。
/// </summary>
@ -2563,6 +2572,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Enable IPv6 Address 的本地化字符串。
/// </summary>
public static string TbSettingsEnableIPv6Address {
get {
return ResourceManager.GetString("TbSettingsEnableIPv6Address", resourceCulture);
}
}
/// <summary>
/// 查找类似 Exception 的本地化字符串。
/// </summary>

View file

@ -1162,4 +1162,10 @@
<data name="LvPrevProfileTip" xml:space="preserve">
<value>Please make sure the remarks exists and is unique</value>
</data>
<data name="TbSettingsEnableExInbound" xml:space="preserve">
<value>Enable additional Inbound</value>
</data>
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
<value>Enable IPv6 Address</value>
</data>
</root>

View file

@ -1159,4 +1159,10 @@
<data name="LvPrevProfileTip" xml:space="preserve">
<value>请确保别名存在并唯一</value>
</data>
<data name="TbSettingsEnableExInbound" xml:space="preserve">
<value>启用额外监听端口</value>
</data>
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
<value>启用IPv6</value>
</data>
</root>

View file

@ -1147,4 +1147,10 @@
<data name="LvPrevProfileTip" xml:space="preserve">
<value>請確保別名存在並且唯一</value>
</data>
<data name="TbSettingsEnableExInbound" xml:space="preserve">
<value>啟用額外監聽端口</value>
</data>
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
<value>啟用IPv6</value>
</data>
</root>

View file

@ -0,0 +1,6 @@
{
"type": "vless",
"tag": "proxy",
"server": "",
"server_port": 443
}

View file

@ -83,6 +83,8 @@ namespace v2rayN.ViewModels
[Reactive] public bool TunStrictRoute { get; set; }
[Reactive] public string TunStack { get; set; }
[Reactive] public int TunMtu { get; set; }
[Reactive] public bool TunEnableExInbound { get; set; }
[Reactive] public bool TunEnableIPv6Address { get; set; }
#endregion Tun mode
@ -174,6 +176,8 @@ namespace v2rayN.ViewModels
TunStrictRoute = _config.tunModeItem.strictRoute;
TunStack = _config.tunModeItem.stack;
TunMtu = _config.tunModeItem.mtu;
TunEnableExInbound = _config.tunModeItem.enableExInbound;
TunEnableIPv6Address = _config.tunModeItem.enableIPv6Address;
#endregion Tun mode
@ -319,6 +323,8 @@ namespace v2rayN.ViewModels
_config.tunModeItem.strictRoute = TunStrictRoute;
_config.tunModeItem.stack = TunStack;
_config.tunModeItem.mtu = TunMtu;
_config.tunModeItem.enableExInbound = TunEnableExInbound;
_config.tunModeItem.enableIPv6Address = TunEnableIPv6Address;
//coreType
SaveCoreType();

View file

@ -805,6 +805,8 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@ -857,6 +859,34 @@
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left"
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="5"
Grid.Column="0"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsEnableExInbound}" />
<ToggleButton
x:Name="togEnableExInbound"
Grid.Row="5"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="6"
Grid.Column="0"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsEnableIPv6Address}" />
<ToggleButton
x:Name="togEnableIPv6Address"
Grid.Row="6"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
</Grid>
</DockPanel>
</TabItem>

View file

@ -186,6 +186,8 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.TunStrictRoute, v => v.togStrictRoute.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunStack, v => v.cmbStack.Text).DisposeWith(disposables);
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.CoreType1, v => v.cmbCoreType1.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CoreType2, v => v.cmbCoreType2.Text).DisposeWith(disposables);

View file

@ -11,7 +11,8 @@
<ApplicationIcon>v2rayN.ico</ApplicationIcon>
<Copyright>Copyright © 2017-2023 (GPLv3)</Copyright>
<FileVersion>6.31</FileVersion>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Downloader" Version="3.0.6" />
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
@ -30,6 +31,7 @@
<ItemGroup>
<AdditionalFiles Include="app.manifest" />
<EmbeddedResource Include="Sample\SingboxSampleOutbound" />
<EmbeddedResource Include="Sample\SingboxSampleClientConfig">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>