From 3becb5b9d1a2a1cfe3608acba39cf9b20338deba Mon Sep 17 00:00:00 2001 From: DHR60 Date: Tue, 5 May 2026 16:32:45 +0800 Subject: [PATCH] Fix --- v2rayN/ServiceLib/Handler/ConfigHandler.cs | 15 ++++++-- v2rayN/ServiceLib/Handler/Fmt/InnerFmt.cs | 35 ++++++++++++++++--- v2rayN/ServiceLib/Resx/ResUI.Designer.cs | 18 +++++----- v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx | 4 +-- v2rayN/ServiceLib/Resx/ResUI.fr.resx | 4 +-- v2rayN/ServiceLib/Resx/ResUI.hu.resx | 4 +-- v2rayN/ServiceLib/Resx/ResUI.resx | 4 +-- v2rayN/ServiceLib/Resx/ResUI.ru.resx | 4 +-- v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx | 4 +-- v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx | 4 +-- .../v2rayN.Desktop/Views/ProfilesView.axaml | 2 +- .../Views/ProfilesView.axaml.cs | 2 +- v2rayN/v2rayN/Views/ProfilesView.xaml | 4 +-- v2rayN/v2rayN/Views/ProfilesView.xaml.cs | 2 +- 14 files changed, 72 insertions(+), 34 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index 9c4d4d5e..93d617a5 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -1792,6 +1792,7 @@ public static class ConfigHandler { EConfigType.VMess => await AddVMessServer(config, profileItem), EConfigType.Shadowsocks => await AddShadowsocksServer(config, profileItem), + EConfigType.HTTP => await AddHttpServer(config, profileItem), EConfigType.SOCKS => await AddSocksServer(config, profileItem), EConfigType.Trojan => await AddTrojanServer(config, profileItem), EConfigType.VLESS => await AddVlessServer(config, profileItem), @@ -1800,6 +1801,7 @@ public static class ConfigHandler EConfigType.WireGuard => await AddWireguardServer(config, profileItem), EConfigType.Anytls => await AddAnytlsServer(config, profileItem), EConfigType.Naive => await AddNaiveServer(config, profileItem), + EConfigType.PolicyGroup or EConfigType.ProxyChain => await AddServerCommon(config, profileItem), _ => -1, }; if (addStatus == 0) @@ -1862,9 +1864,18 @@ public static class ConfigHandler counter = await AddBatchServers4Wireguard(config, strData, subid, isSub); } - if (counter < 1) + //May be standard uri mixed with internal uri + var innerUriCount = await AddBatchServers4InnerUri(config, strData, subid, isSub); + if (innerUriCount > 0) { - counter = await AddBatchServers4InnerUri(config, strData, subid, isSub); + if (counter > 0) + { + counter += innerUriCount; + } + else + { + counter = innerUriCount; + } } //maybe other sub diff --git a/v2rayN/ServiceLib/Handler/Fmt/InnerFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/InnerFmt.cs index e540f1cd..b035e219 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/InnerFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/InnerFmt.cs @@ -32,10 +32,6 @@ public class InnerFmt // Unsupported, also to avoid possible sources of attacks, skip it continue; } - if (profileItem.ConfigVersion != 4) - { - continue; - } // overwrite indexId var newIndexId = Utils.GetGuid(false); if (!profileItem.IndexId.IsNullOrEmpty()) @@ -48,6 +44,7 @@ public class InnerFmt } } // For group-type profile items, also overwrite the ChildItems and ChildSubId + var emptyGroupProfileList = new List(); foreach (var item in list.Where(i => i.ConfigType.IsGroupType())) { var protocolExtra = item.GetProtocolExtra(); @@ -87,7 +84,14 @@ public class InnerFmt }; } item.SetProtocolExtra(protocolExtra); + if (protocolExtra.SubChildItems.IsNullOrEmpty() + && protocolExtra.ChildItems.IsNullOrEmpty()) + { + emptyGroupProfileList.Add(item); + } } + // Remove empty group profile items + list.RemoveAll(emptyGroupProfileList.Contains); return list; } @@ -172,6 +176,29 @@ public class InnerFmt jsonObj.Remove("TransportExtraObj"); } var profileItem = JsonUtils.Deserialize(JsonUtils.Serialize(jsonObj, false)); + if (profileItem is null) + { + return null; + } + if (profileItem.ConfigVersion != 4) + { + return null; + } + // Check Enum.IsDefined + if (!Enum.IsDefined(typeof(EConfigType), profileItem.ConfigType)) + { + return null; + } + if (profileItem.CoreType is not (null or ECoreType.Xray or ECoreType.sing_box)) + { + return null; + } + var protocolExtra = profileItem.GetProtocolExtra(); + var multipleLoad = protocolExtra.MultipleLoad; + if (multipleLoad is not null && !Enum.IsDefined(typeof(EMultipleLoad), multipleLoad)) + { + return null; + } return profileItem; } diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs index 0661316d..7aba3abe 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs +++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs @@ -1023,6 +1023,15 @@ namespace ServiceLib.Resx { } } + /// + /// 查找类似 Export v2rayN Internal Share Link to Clipboard 的本地化字符串。 + /// + public static string menuExport2InnerUri { + get { + return ResourceManager.GetString("menuExport2InnerUri", resourceCulture); + } + } + /// /// 查找类似 Export Share Link to Clipboard 的本地化字符串。 /// @@ -1041,15 +1050,6 @@ namespace ServiceLib.Resx { } } - /// - /// 查找类似 Backup to Clipboard 的本地化字符串。 - /// - public static string menuExport4Backup { - get { - return ResourceManager.GetString("menuExport4Backup", resourceCulture); - } - } - /// /// 查找类似 Export 的本地化字符串。 /// diff --git a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx index ca5f5e45..21a6c7f1 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx @@ -1728,7 +1728,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if PreSharedKey - - Backup to Clipboard + + Export v2rayN Internal Share Link to Clipboard \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.fr.resx b/v2rayN/ServiceLib/Resx/ResUI.fr.resx index c84610b1..bca6c2b7 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.fr.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.fr.resx @@ -1725,7 +1725,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if PreSharedKey - - Backup to Clipboard + + Export v2rayN Internal Share Link to Clipboard \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.hu.resx b/v2rayN/ServiceLib/Resx/ResUI.hu.resx index 7b6c4dc0..d73a170c 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.hu.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.hu.resx @@ -1728,7 +1728,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if PreSharedKey - - Backup to Clipboard + + Export v2rayN Internal Share Link to Clipboard \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx index c2a7df7a..13883be4 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.resx @@ -1728,7 +1728,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if PreSharedKey - - Backup to Clipboard + + Export v2rayN Internal Share Link to Clipboard \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.ru.resx b/v2rayN/ServiceLib/Resx/ResUI.ru.resx index 5f692fef..4d02c0a7 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.ru.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.ru.resx @@ -1728,7 +1728,7 @@ PreSharedKey - - Backup to Clipboard + + Export v2rayN Internal Share Link to Clipboard \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx index c8d65400..e8617160 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx @@ -1725,7 +1725,7 @@ PreSharedKey - - 备份至剪贴板 (多选) + + 导出 v2rayN 内部分享链接至剪贴板 (多选) \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx index e10fe66d..547f5749 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx @@ -1725,7 +1725,7 @@ PreSharedKey - - Backup to Clipboard + + Export v2rayN Internal Share Link to Clipboard \ No newline at end of file diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml index 3afcbc3e..a567ae6a 100644 --- a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml +++ b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml @@ -192,7 +192,7 @@ Header="{x:Static resx:ResUI.menuExport2ShareUrl}" InputGesture="Ctrl+C" /> - + diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs index f16ac5ce..b025c114 100644 --- a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs @@ -88,7 +88,7 @@ public partial class ProfilesView : ReactiveUserControl this.BindCommand(ViewModel, vm => vm.Export2ClientConfigClipboardCmd, v => v.menuExport2ClientConfigClipboard).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.Export2ShareUrlCmd, v => v.menuExport2ShareUrl).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.Export2ShareUrlBase64Cmd, v => v.menuExport2ShareUrlBase64).DisposeWith(disposables); - this.BindCommand(ViewModel, vm => vm.Export2InnerUriCmd, v => v.menuExport4Backup).DisposeWith(disposables); + this.BindCommand(ViewModel, vm => vm.Export2InnerUriCmd, v => v.menuExport2InnerUri).DisposeWith(disposables); AppEvents.AppExitRequested .AsObservable() diff --git a/v2rayN/v2rayN/Views/ProfilesView.xaml b/v2rayN/v2rayN/Views/ProfilesView.xaml index 8c8a9335..5a25e4c7 100644 --- a/v2rayN/v2rayN/Views/ProfilesView.xaml +++ b/v2rayN/v2rayN/Views/ProfilesView.xaml @@ -243,9 +243,9 @@ Height="{StaticResource MenuItemHeight}" Header="{x:Static resx:ResUI.menuExport2ShareUrlBase64}" /> + Header="{x:Static resx:ResUI.menuExport2InnerUri}" /> diff --git a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs index a73e7018..1db64f34 100644 --- a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs +++ b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs @@ -82,7 +82,7 @@ public partial class ProfilesView this.BindCommand(ViewModel, vm => vm.Export2ClientConfigClipboardCmd, v => v.menuExport2ClientConfigClipboard).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.Export2ShareUrlCmd, v => v.menuExport2ShareUrl).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.Export2ShareUrlBase64Cmd, v => v.menuExport2ShareUrlBase64).DisposeWith(disposables); - this.BindCommand(ViewModel, vm => vm.Export2InnerUriCmd, v => v.menuExport4Backup).DisposeWith(disposables); + this.BindCommand(ViewModel, vm => vm.Export2InnerUriCmd, v => v.menuExport2InnerUri).DisposeWith(disposables); AppEvents.AppExitRequested .AsObservable()