Add Hy2 Port hopping for sing-box 1.11+
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run

https://github.com/2dust/v2rayN/issues/6772
This commit is contained in:
2dust 2025-03-01 21:13:37 +08:00
parent 2dd10cf5a1
commit e70658f311
16 changed files with 126 additions and 16 deletions

View file

@ -217,6 +217,7 @@ namespace ServiceLib.Handler
item.Remarks = profileItem.Remarks;
item.Address = profileItem.Address;
item.Port = profileItem.Port;
item.Ports = profileItem.Ports;
item.Id = profileItem.Id;
item.AlterId = profileItem.AlterId;

View file

@ -197,6 +197,7 @@ namespace ServiceLib.Models
{
public int UpMbps { get; set; }
public int DownMbps { get; set; }
public int HopInterval { get; set; } = 30;
}
[Serializable]

View file

@ -1,4 +1,4 @@
using SQLite;
using SQLite;
namespace ServiceLib.Models
{
@ -64,11 +64,11 @@ namespace ServiceLib.Models
[PrimaryKey]
public string IndexId { get; set; }
public EConfigType ConfigType { get; set; }
public int ConfigVersion { get; set; }
public string Address { get; set; }
public int Port { get; set; }
public string Ports { get; set; }
public string Id { get; set; }
public int AlterId { get; set; }
public string Security { get; set; }

View file

@ -1,4 +1,4 @@
namespace ServiceLib.Models
namespace ServiceLib.Models
{
public class SingboxConfig
{
@ -101,21 +101,23 @@
public string tag { get; set; }
public string? server { get; set; }
public int? server_port { get; set; }
public string uuid { get; set; }
public string security { get; set; }
public List<string>? server_ports { get; set; }
public string? uuid { get; set; }
public string? security { get; set; }
public int? alter_id { get; set; }
public string flow { get; set; }
public string? flow { get; set; }
public string? hop_interval { get; set; }
public int? up_mbps { get; set; }
public int? down_mbps { get; set; }
public string auth_str { get; set; }
public string? auth_str { get; set; }
public int? recv_window_conn { get; set; }
public int? recv_window { get; set; }
public bool? disable_mtu_discovery { get; set; }
public string? detour { get; set; }
public string method { get; set; }
public string username { get; set; }
public string password { get; set; }
public string congestion_control { get; set; }
public string? method { get; set; }
public string? username { get; set; }
public string? password { get; set; }
public string? congestion_control { get; set; }
public string? version { get; set; }
public string? network { get; set; }
public string? packet_encoding { get; set; }

View file

@ -2536,6 +2536,24 @@ namespace ServiceLib.Resx {
}
}
/// <summary>
/// 查找类似 Server port range 的本地化字符串。
/// </summary>
public static string TbPorts7 {
get {
return ResourceManager.GetString("TbPorts7", resourceCulture);
}
}
/// <summary>
/// 查找类似 Will cover the port, separate with commas (,) 的本地化字符串。
/// </summary>
public static string TbPorts7Tips {
get {
return ResourceManager.GetString("TbPorts7Tips", resourceCulture);
}
}
/// <summary>
/// 查找类似 Socks port 的本地化字符串。
/// </summary>

View file

@ -1396,4 +1396,10 @@
<data name="RemoveInvalidServerResultTip" xml:space="preserve">
<value>Removed {0} invalid test results.</value>
</data>
<data name="TbPorts7" xml:space="preserve">
<value>Server port range</value>
</data>
<data name="TbPorts7Tips" xml:space="preserve">
<value>Will cover the port, separate with commas (,)</value>
</data>
</root>

View file

@ -1396,4 +1396,10 @@
<data name="RemoveInvalidServerResultTip" xml:space="preserve">
<value>Removed {0} invalid test results.</value>
</data>
<data name="TbPorts7" xml:space="preserve">
<value>Server port range</value>
</data>
<data name="TbPorts7Tips" xml:space="preserve">
<value>Will cover the port, separate with commas (,)</value>
</data>
</root>

View file

@ -1396,4 +1396,10 @@
<data name="RemoveInvalidServerResultTip" xml:space="preserve">
<value>Removed {0} invalid test results.</value>
</data>
<data name="TbPorts7" xml:space="preserve">
<value>Server port range</value>
</data>
<data name="TbPorts7Tips" xml:space="preserve">
<value>Will cover the port, separate with commas (,)</value>
</data>
</root>

View file

@ -1396,4 +1396,10 @@
<data name="RemoveInvalidServerResultTip" xml:space="preserve">
<value>Removed {0} invalid test results.</value>
</data>
<data name="TbPorts7" xml:space="preserve">
<value>Server port range</value>
</data>
<data name="TbPorts7Tips" xml:space="preserve">
<value>Will cover the port, separate with commas (,)</value>
</data>
</root>

View file

@ -1393,4 +1393,10 @@
<data name="RemoveInvalidServerResultTip" xml:space="preserve">
<value>移除无效测试结果 {0} 个。</value>
</data>
<data name="TbPorts7" xml:space="preserve">
<value>跳跃端口范围</value>
</data>
<data name="TbPorts7Tips" xml:space="preserve">
<value>会覆盖端口,多组时用逗号(,)隔开</value>
</data>
</root>

View file

@ -1394,4 +1394,10 @@
<data name="RemoveInvalidServerResultTip" xml:space="preserve">
<value>移除無效測試結果 {0} 個。</value>
</data>
<data name="TbPorts7" xml:space="preserve">
<value>跳躍端口範圍</value>
</data>
<data name="TbPorts7Tips" xml:space="preserve">
<value>會覆蓋端口,多組時用逗號(,)隔開</value>
</data>
</root>

View file

@ -730,6 +730,13 @@ namespace ServiceLib.Services.CoreConfig
outbound.up_mbps = _config.HysteriaItem.UpMbps > 0 ? _config.HysteriaItem.UpMbps : null;
outbound.down_mbps = _config.HysteriaItem.DownMbps > 0 ? _config.HysteriaItem.DownMbps : null;
if (node.Ports.IsNotEmpty())
{
outbound.server_port = null;
outbound.server_ports = node.Ports.Split(",").ToList();
outbound.hop_interval = _config.HysteriaItem.HopInterval > 0 ? $"{_config.HysteriaItem.HopInterval}s" : null;
}
break;
}
case EConfigType.TUIC:

View file

@ -308,7 +308,7 @@
<Grid
x:Name="gridHysteria2"
Grid.Row="2"
ColumnDefinitions="180,Auto"
ColumnDefinitions="180,Auto,Auto"
IsVisible="False"
RowDefinitions="Auto,Auto,Auto,Auto">
@ -337,6 +337,25 @@
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}" />
<TextBlock
Grid.Row="3"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbPorts7}" />
<TextBox
x:Name="txtPorts7"
Grid.Row="3"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}" />
<TextBlock
Grid.Row="3"
Grid.Column="2"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbPorts7Tips}" />
</Grid>
<Grid
x:Name="gridTuic"

View file

@ -178,6 +178,7 @@ namespace v2rayN.Desktop.Views
case EConfigType.Hysteria2:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId7.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath7.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Ports, v => v.txtPorts7.Text).DisposeWith(disposables);
break;
case EConfigType.TUIC:

View file

@ -1,4 +1,4 @@
<reactiveui:ReactiveWindow
<reactiveui:ReactiveWindow
x:Class="v2rayN.Views.AddServerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -432,6 +432,7 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
@ -463,6 +464,29 @@
Width="400"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefTextBox}" />
<TextBlock
Grid.Row="3"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbPorts7}" />
<TextBox
x:Name="txtPorts7"
Grid.Row="3"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
Style="{StaticResource DefTextBox}" />
<TextBlock
Grid.Row="3"
Grid.Column="2"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbPorts7Tips}" />
</Grid>
<Grid
x:Name="gridTuic"

View file

@ -172,6 +172,7 @@ namespace v2rayN.Views
case EConfigType.Hysteria2:
this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId7.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath7.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Ports, v => v.txtPorts7.Text).DisposeWith(disposables);
break;
case EConfigType.TUIC: