Add custom config Socks port to the group

https://github.com/2dust/v2rayN/issues/5576
pull/5636/head
2dust 2024-08-30 10:12:40 +08:00
parent c9d65e5cd9
commit d189f4b443
10 changed files with 51 additions and 5 deletions

View File

@ -1282,7 +1282,10 @@ namespace ServiceLib.Handler
{
return -1;
}
var subRemarks = LazyConfig.Instance.GetSubItem(subid)?.remarks;
var subItem = LazyConfig.Instance.GetSubItem(subid);
var subRemarks = subItem?.remarks;
var preSocksPort = subItem?.preSocksPort;
List<ProfileItem>? lstProfiles = null;
//Is sing-box array configuration
@ -1306,6 +1309,7 @@ namespace ServiceLib.Handler
{
it.subid = subid;
it.isSub = isSub;
it.preSocksPort = preSocksPort;
if (AddCustomServer(config, it, true) == 0)
{
count++;
@ -1362,6 +1366,7 @@ namespace ServiceLib.Handler
}
profileItem.subid = subid;
profileItem.isSub = isSub;
profileItem.preSocksPort = preSocksPort;
if (AddCustomServer(config, profileItem, true) == 0)
{
return 1;
@ -1501,6 +1506,7 @@ namespace ServiceLib.Handler
item.convertTarget = subItem.convertTarget;
item.prevProfile = subItem.prevProfile;
item.nextProfile = subItem.nextProfile;
item.preSocksPort = subItem.preSocksPort;
}
if (Utils.IsNullOrEmpty(item.id))

View File

@ -218,7 +218,7 @@ namespace ServiceLib.Handler
coreType = preCoreType,
configType = EConfigType.Socks,
address = Global.Loopback,
port = node.preSocksPort
port = node.preSocksPort.Value,
};
_config.runningCoreType = preCoreType;
}

View File

@ -178,7 +178,7 @@ namespace ServiceLib.Models
public ECoreType? coreType { get; set; }
public int preSocksPort { get; set; }
public int? preSocksPort { get; set; }
public string fingerprint { get; set; }

View File

@ -31,5 +31,7 @@ namespace ServiceLib.Models
public string? prevProfile { get; set; }
public string? nextProfile { get; set; }
public int? preSocksPort { get; set; }
}
}

View File

@ -2330,7 +2330,7 @@ namespace ServiceLib.Resx {
}
/// <summary>
/// 查找类似 txtPreSocksPort 的本地化字符串。
/// 查找类似 Socks port 的本地化字符串。
/// </summary>
public static string TbPreSocksPort {
get {
@ -2338,6 +2338,15 @@ namespace ServiceLib.Resx {
}
}
/// <summary>
/// 查找类似 Custom config socks port 的本地化字符串。
/// </summary>
public static string TbPreSocksPort4Sub {
get {
return ResourceManager.GetString("TbPreSocksPort4Sub", resourceCulture);
}
}
/// <summary>
/// 查找类似 PrivateKey 的本地化字符串。
/// </summary>

View File

@ -668,7 +668,7 @@
<value>Encryption</value>
</data>
<data name="TbPreSocksPort" xml:space="preserve">
<value>txtPreSocksPort</value>
<value>Socks port</value>
</data>
<data name="TipPreSocksPort" xml:space="preserve">
<value>* After setting this value, an socks service will be started using Xray/sing-box(Tun) to provide functions such as speed display</value>
@ -1276,4 +1276,7 @@
<data name="UpdateStandalonePackageTip" xml:space="preserve">
<value>You are currently running a standalone package, please manually download the SelfContained.7z file to unzip and overwrite it!</value>
</data>
<data name="TbPreSocksPort4Sub" xml:space="preserve">
<value>Custom config socks port</value>
</data>
</root>

View File

@ -1273,4 +1273,7 @@
<data name="UpdateStandalonePackageTip" xml:space="preserve">
<value>您当前运行的是独立包,请手动下载 SelfContained.7z文件解压覆盖</value>
</data>
<data name="TbPreSocksPort4Sub" xml:space="preserve">
<value>自定义配置的Socks端口</value>
</data>
</root>

View File

@ -1153,4 +1153,7 @@
<data name="UpdateStandalonePackageTip" xml:space="preserve">
<value>您目前運行的是獨立包,請手動下載 SelfContained.7z檔案解壓縮覆蓋</value>
</data>
<data name="TbPreSocksPort4Sub" xml:space="preserve">
<value>自訂配置的Socks端口</value>
</data>
</root>

View File

@ -69,6 +69,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@ -281,6 +282,24 @@
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.LvPrevProfileTip}"
AcceptsReturn="True"
Style="{StaticResource MyOutlinedTextBox}" />
<TextBlock
Grid.Row="11"
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbPreSocksPort4Sub}" />
<TextBox
x:Name="txtPreSocksPort"
Grid.Row="11"
Grid.Column="1"
Margin="4"
HorizontalAlignment="Left"
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.TipPreSocksPort}"
AcceptsReturn="True"
Style="{StaticResource MyOutlinedTextBox}"
ToolTip="{x:Static resx:ResUI.TipPreSocksPort}" />
</Grid>
</ScrollViewer>
</DockPanel>

View File

@ -33,6 +33,7 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.SelectedSource.convertTarget, v => v.cmbConvertTarget.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.prevProfile, v => v.txtPrevProfile.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.nextProfile, v => v.txtNextProfile.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.preSocksPort, v => v.txtPreSocksPort.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
});