Compare commits

...

6 commits

Author SHA1 Message Date
DHR60
93389cdfc8
Merge daa09fc0bf into 17ed26cd06 2026-03-12 16:04:27 +08:00
2dust
17ed26cd06 Improve profile matching for Subscription, remove old option 2026-03-12 14:56:01 +08:00
2dust
5e18567ce6 Modify routing rule process name description 2026-03-12 14:21:21 +08:00
2dust
06cec89ec9 up 7.19.3
Some checks failed
release Linux / build (Release) (push) Has been cancelled
release macOS / build (Release) (push) Has been cancelled
release Windows desktop (Avalonia UI) / build (Release) (push) Has been cancelled
release Windows / build (Release) (push) Has been cancelled
release Linux / rpm (push) Has been cancelled
2026-03-10 17:38:03 +08:00
2dust
26f65dd3b2 Code cleanup: pattern matching and minor fixes 2026-03-10 17:19:21 +08:00
DHR60
daa09fc0bf Add sing-box ech query server name 2026-03-01 20:10:51 +08:00
24 changed files with 104 additions and 94 deletions

View file

@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<Version>7.19.2</Version>
<Version>7.19.3</Version>
</PropertyGroup>
<PropertyGroup>

View file

@ -95,7 +95,7 @@ public class Global
public const string PolicyGroupDefaultAllFilter = $"^(?!.*(?:{PolicyGroupExcludeKeywords})).*$";
public static readonly List<string> PolicyGroupDefaultFilterList =
public static readonly List<string> PolicyGroupDefaultFilterList =
[
// All nodes (exclude traffic/expiry info)
PolicyGroupDefaultAllFilter,

View file

@ -81,7 +81,9 @@ public class NodeValidator
{
var transportError = ValidateSingboxTransport(item.ConfigType, net);
if (transportError != null)
{
v.Error(transportError);
}
if (!Global.SingboxSupportConfigType.Contains(item.ConfigType))
{

View file

@ -95,10 +95,7 @@ public static class ConfigHandler
config.GuiItem ??= new();
config.MsgUIItem ??= new();
config.UiItem ??= new UIItem()
{
EnableUpdateSubOnlyRemarksExist = true
};
config.UiItem ??= new();
config.UiItem.MainColumnItem ??= new();
config.UiItem.WindowSizeItem ??= new();
@ -1040,8 +1037,8 @@ public static class ConfigHandler
if (profileItem.StreamSecurity.IsNotEmpty())
{
if (profileItem.StreamSecurity != Global.StreamSecurity
&& profileItem.StreamSecurity != Global.StreamSecurityReality)
if (profileItem.StreamSecurity is not Global.StreamSecurity
and not Global.StreamSecurityReality)
{
profileItem.StreamSecurity = string.Empty;
}
@ -1132,6 +1129,84 @@ public static class ConfigHandler
}
}
/// <summary>
/// Searches the specified collection for a profile item that matches the target profile item based on a series of
/// criteria.
/// </summary>
/// <remarks>The method attempts to find a match by comparing the target's remarks, address, port, and
/// password in various combinations. The search is performed in order of specificity, starting with the most
/// detailed comparison. If no match is found at any stage, the method returns null.</remarks>
/// <param name="source">An enumerable collection of profile items to search. This parameter can be null.</param>
/// <param name="target">The profile item to match against items in the source collection. This parameter can be null.</param>
/// <returns>A profile item from the source collection that matches the target item according to defined criteria; otherwise,
/// null if no match is found or if either parameter is null.</returns>
private static ProfileItem? FindMatchedProfileItem(IEnumerable<ProfileItem>? source, ProfileItem? target)
{
if (source == null || target == null)
{
return null;
}
var matchedItem = source.FirstOrDefault(t => CompareProfileItem(t, target, true));
if (matchedItem != null)
{
return matchedItem;
}
if (target.Remarks.IsNotEmpty())
{
matchedItem = source.FirstOrDefault(t => t.Remarks == target.Remarks);
if (matchedItem != null)
{
return matchedItem;
}
}
if (target.Address.IsNotEmpty() && target.Port > 0 && target.Password.IsNotEmpty())
{
matchedItem = source.FirstOrDefault(t =>
IsSameText(t.Address, target.Address) &&
t.Port == target.Port &&
IsSameText(t.Password, target.Password));
if (matchedItem != null)
{
return matchedItem;
}
}
if (target.Address.IsNotEmpty() && target.Port > 0)
{
matchedItem = source.FirstOrDefault(t =>
IsSameText(t.Address, target.Address) &&
t.Port == target.Port);
if (matchedItem != null)
{
return matchedItem;
}
}
if (target.Address.IsNotEmpty())
{
matchedItem = source.FirstOrDefault(t => IsSameText(t.Address, target.Address));
if (matchedItem != null)
{
return matchedItem;
}
}
return null;
static bool IsSameText(string? left, string? right)
{
if (left.IsNullOrEmpty() || right.IsNullOrEmpty())
{
return false;
}
return string.Equals(left.TrimEx(), right.TrimEx(), StringComparison.OrdinalIgnoreCase);
}
}
/// <summary>
/// Remove a single server profile by its index ID
/// Deletes the configuration file if it's a custom config
@ -1636,7 +1711,7 @@ public static class ConfigHandler
if (activeProfile != null)
{
var lstSub = await AppManager.Instance.ProfileItems(subid);
var existItem = lstSub?.FirstOrDefault(t => config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.Remarks == activeProfile.Remarks : CompareProfileItem(t, activeProfile, true));
var existItem = FindMatchedProfileItem(lstSub, activeProfile);
if (existItem != null)
{
await ConfigHandler.SetDefaultServerIndex(config, existItem.IndexId);
@ -1649,7 +1724,7 @@ public static class ConfigHandler
var lstSub = await AppManager.Instance.ProfileItems(subid);
foreach (var item in lstSub)
{
var existItem = lstOriSub?.FirstOrDefault(t => config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.Remarks == item.Remarks : CompareProfileItem(t, item, true));
var existItem = FindMatchedProfileItem(lstOriSub, item);
if (existItem != null)
{
await StatisticsManager.Instance.CloneServerStatItem(existItem.IndexId, item.IndexId);

View file

@ -87,7 +87,6 @@ public class MsgUIItem
public class UIItem
{
public bool EnableAutoAdjustMainLvColWidth { get; set; }
public bool EnableUpdateSubOnlyRemarksExist { get; set; }
public int MainGirdHeight1 { get; set; }
public int MainGirdHeight2 { get; set; }
public EGirdOrientation MainGirdOrientation { get; set; } = EGirdOrientation.Vertical;

View file

@ -9,6 +9,6 @@ public class ServerTestItem
public EConfigType ConfigType { get; set; }
public bool AllowTest { get; set; }
public int QueueNum { get; set; }
public required ProfileItem Profile { get; set; }
public ProfileItem Profile { get; set; }
public ECoreType CoreType { get; set; }
}

View file

@ -3376,7 +3376,7 @@ namespace ServiceLib.Resx {
}
/// <summary>
/// 查找类似 Process (Tun mode) 的本地化字符串。
/// 查找类似 Process name: Linux/Windows/macOS (sing-box) 的本地化字符串。
/// </summary>
public static string TbRoutingRuleProcess {
get {
@ -3816,15 +3816,6 @@ namespace ServiceLib.Resx {
}
}
/// <summary>
/// 查找类似 Updating subscription, only determining if remarks exist 的本地化字符串。
/// </summary>
public static string TbSettingsEnableUpdateSubOnlyRemarksExist {
get {
return ResourceManager.GetString("TbSettingsEnableUpdateSubOnlyRemarksExist", resourceCulture);
}
}
/// <summary>
/// 查找类似 Exception 的本地化字符串。
/// </summary>

View file

@ -1027,7 +1027,7 @@
<value>پروتکل sing-box Mux</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>Process (Tun mode)</value>
<value>Process name: Linux/Windows/macOS (sing-box)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP or IP CIDR</value>
@ -1098,9 +1098,6 @@
<data name="TbSettingsSpeedPingTestUrl" xml:space="preserve">
<value>آدرس اینترنتی تست پینگ سرعت</value>
</data>
<data name="TbSettingsEnableUpdateSubOnlyRemarksExist" xml:space="preserve">
<value>اشتراک در حال به‌روزرسانی، فقط مشخص کنید که ملاحظاتی آیا وجود دارد!</value>
</data>
<data name="SpeedtestingStop" xml:space="preserve">
<value>پایان تست...</value>
</data>

View file

@ -1024,7 +1024,7 @@
<value>Protocole de multiplexage Mux (sing-box)</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>Process (Tun mode)</value>
<value>Process name: Linux/Windows/macOS (sing-box)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP ou IP CIDR</value>
@ -1095,9 +1095,6 @@
<data name="TbSettingsSpeedPingTestUrl" xml:space="preserve">
<value>Adresse de test de connexion réelle</value>
</data>
<data name="TbSettingsEnableUpdateSubOnlyRemarksExist" xml:space="preserve">
<value>Ne vérifier lexistence de lalias quà la maj. des abonnements</value>
</data>
<data name="SpeedtestingStop" xml:space="preserve">
<value>Arrêt du test en cours...</value>
</data>
@ -1668,4 +1665,4 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
<data name="menuGenRegionGroup" xml:space="preserve">
<value>Group by Region</value>
</data>
</root>
</root>

View file

@ -1027,7 +1027,7 @@
<value>sing-box Mux protokoll</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>Process (Tun mode)</value>
<value>Process name: Linux/Windows/macOS (sing-box)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP vagy IP CIDR</value>
@ -1098,9 +1098,6 @@
<data name="TbSettingsSpeedPingTestUrl" xml:space="preserve">
<value>Sebesség Ping Teszt URL</value>
</data>
<data name="TbSettingsEnableUpdateSubOnlyRemarksExist" xml:space="preserve">
<value>Előfizetés frissítése, csak a megjegyzések létezésének ellenőrzése</value>
</data>
<data name="SpeedtestingStop" xml:space="preserve">
<value>Teszt megszakítása...</value>
</data>

View file

@ -1027,7 +1027,7 @@
<value>sing-box Mux Protocol</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>Process (Tun mode)</value>
<value>Process name: Linux/Windows/macOS (sing-box)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP or IP CIDR</value>
@ -1098,9 +1098,6 @@
<data name="TbSettingsSpeedPingTestUrl" xml:space="preserve">
<value>Speed Ping Test URL</value>
</data>
<data name="TbSettingsEnableUpdateSubOnlyRemarksExist" xml:space="preserve">
<value>Updating subscription, only determining if remarks exist</value>
</data>
<data name="SpeedtestingStop" xml:space="preserve">
<value>Test terminating...</value>
</data>

View file

@ -1027,7 +1027,7 @@
<value>Протокол Mux для sing-box</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>Process (Tun mode)</value>
<value>Process name: Linux/Windows/macOS (sing-box)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP-адрес или сеть CIDR</value>
@ -1098,9 +1098,6 @@
<data name="TbSettingsSpeedPingTestUrl" xml:space="preserve">
<value>URL для быстрой проверки реальной задержки</value>
</data>
<data name="TbSettingsEnableUpdateSubOnlyRemarksExist" xml:space="preserve">
<value>Обновляя подписку, проверять лишь наличие примечаний</value>
</data>
<data name="SpeedtestingStop" xml:space="preserve">
<value>Отмена тестирования...</value>
</data>

View file

@ -1024,7 +1024,7 @@
<value>sing-box Mux 多路复用协议</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>进程 (Tun 模式)</value>
<value>进程名 Linux/Windows/macOS(sing-box)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP 或 IP CIDR</value>
@ -1095,9 +1095,6 @@
<data name="TbSettingsSpeedPingTestUrl" xml:space="preserve">
<value>真连接测试地址</value>
</data>
<data name="TbSettingsEnableUpdateSubOnlyRemarksExist" xml:space="preserve">
<value>更新订阅时只判断别名已存在否</value>
</data>
<data name="SpeedtestingStop" xml:space="preserve">
<value>测试终止中...</value>
</data>

View file

@ -1024,7 +1024,7 @@
<value>sing-box Mux 多路復用協定</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>行程 (Tun 模式)</value>
<value>行程名 Linux/Windows/macOS(sing-box)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP 或 IP CIDR</value>
@ -1095,9 +1095,6 @@
<data name="TbSettingsSpeedPingTestUrl" xml:space="preserve">
<value>真連線測試位址</value>
</data>
<data name="TbSettingsEnableUpdateSubOnlyRemarksExist" xml:space="preserve">
<value>更新訂閱時只判斷別名是否存在</value>
</data>
<data name="SpeedtestingStop" xml:space="preserve">
<value>測試終止中...</value>
</data>

View file

@ -243,7 +243,6 @@ public partial class CoreConfigSingboxService
if (Utils.IsIpv6(predefined))
{
rule.answer = new List<string> { $"*. IN AAAA {predefined}" };
}
else
{

View file

@ -727,13 +727,12 @@ public partial class CoreConfigSingboxService
}, null);
}
var idx = echConfig.IndexOf('+');
// NOTE: query_server_name, since sing-box 1.13.0
//var queryServerName = idx > 0 ? echConfig[..idx] : null;
var queryServerName = idx > 0 ? echConfig[..idx] : null;
var echDnsServer = idx > 0 ? echConfig[(idx + 1)..] : echConfig;
return (new Ech4Sbox()
{
enabled = true,
query_server_name = null,
query_server_name = queryServerName,
}, ParseDnsAddress(echDnsServer));
}
}

View file

@ -47,7 +47,6 @@ public class OptionSettingViewModel : MyReactiveObject
[Reactive] public bool KeepOlderDedupl { get; set; }
[Reactive] public bool DisplayRealTimeSpeed { get; set; }
[Reactive] public bool EnableAutoAdjustMainLvColWidth { get; set; }
[Reactive] public bool EnableUpdateSubOnlyRemarksExist { get; set; }
[Reactive] public bool AutoHideStartup { get; set; }
[Reactive] public bool Hide2TrayWhenClose { get; set; }
[Reactive] public bool MacOSShowInDock { get; set; }
@ -180,7 +179,6 @@ public class OptionSettingViewModel : MyReactiveObject
DisplayRealTimeSpeed = _config.GuiItem.DisplayRealTimeSpeed;
KeepOlderDedupl = _config.GuiItem.KeepOlderDedupl;
EnableAutoAdjustMainLvColWidth = _config.UiItem.EnableAutoAdjustMainLvColWidth;
EnableUpdateSubOnlyRemarksExist = _config.UiItem.EnableUpdateSubOnlyRemarksExist;
AutoHideStartup = _config.UiItem.AutoHideStartup;
Hide2TrayWhenClose = _config.UiItem.Hide2TrayWhenClose;
MacOSShowInDock = _config.UiItem.MacOSShowInDock;
@ -345,7 +343,6 @@ public class OptionSettingViewModel : MyReactiveObject
_config.GuiItem.DisplayRealTimeSpeed = DisplayRealTimeSpeed;
_config.GuiItem.KeepOlderDedupl = KeepOlderDedupl;
_config.UiItem.EnableAutoAdjustMainLvColWidth = EnableAutoAdjustMainLvColWidth;
_config.UiItem.EnableUpdateSubOnlyRemarksExist = EnableUpdateSubOnlyRemarksExist;
_config.UiItem.AutoHideStartup = AutoHideStartup;
_config.UiItem.Hide2TrayWhenClose = Hide2TrayWhenClose;
_config.UiItem.MacOSShowInDock = MacOSShowInDock;

View file

@ -8,9 +8,9 @@ public partial class ClashConnectionsView : ReactiveUserControl<ClashConnections
public ClashConnectionsView()
{
InitializeComponent();
_config = AppManager.Instance.Config;
ViewModel = new ClashConnectionsViewModel(UpdateViewHandler);
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
@ -65,7 +65,7 @@ public partial class ClashConnectionsView : ReactiveUserControl<ClashConnections
{
ViewModel?.ClashConnectionClose(false);
}
#region UI
private void RestoreUI()

View file

@ -410,19 +410,6 @@
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="6"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbSettingsEnableUpdateSubOnlyRemarksExist}" />
<ToggleSwitch
x:Name="togEnableUpdateSubOnlyRemarksExist"
Grid.Row="6"
Grid.Column="1"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="8"
Grid.Column="0"

View file

@ -86,7 +86,6 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
this.Bind(ViewModel, vm => vm.DisplayRealTimeSpeed, v => v.togDisplayRealTimeSpeed.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.KeepOlderDedupl, v => v.togKeepOlderDedupl.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableAutoAdjustMainLvColWidth, v => v.togEnableAutoAdjustMainLvColWidth.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableUpdateSubOnlyRemarksExist, v => v.togEnableUpdateSubOnlyRemarksExist.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoHideStartup, v => v.togAutoHideStartup.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Hide2TrayWhenClose, v => v.togHide2TrayWhenClose.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.MacOSShowInDock, v => v.togMacOSShowInDock.IsChecked).DisposeWith(disposables);

View file

@ -630,20 +630,6 @@
Margin="{StaticResource Margin8}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="6"
Grid.Column="0"
Margin="{StaticResource Margin8}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsEnableUpdateSubOnlyRemarksExist}" />
<ToggleButton
x:Name="togEnableUpdateSubOnlyRemarksExist"
Grid.Row="6"
Grid.Column="1"
Margin="{StaticResource Margin8}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="8"
Grid.Column="0"

View file

@ -91,7 +91,6 @@ public partial class OptionSettingWindow
this.Bind(ViewModel, vm => vm.DisplayRealTimeSpeed, v => v.togDisplayRealTimeSpeed.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.KeepOlderDedupl, v => v.togKeepOlderDedupl.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableAutoAdjustMainLvColWidth, v => v.togEnableAutoAdjustMainLvColWidth.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableUpdateSubOnlyRemarksExist, v => v.togEnableUpdateSubOnlyRemarksExist.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoHideStartup, v => v.togAutoHideStartup.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableDragDropSort, v => v.togEnableDragDropSort.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.DoubleClick2Activate, v => v.togDoubleClick2Activate.IsChecked).DisposeWith(disposables);

View file

@ -97,8 +97,7 @@ public partial class ProfilesSelectWindow
private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e)
{
var colHeader = sender as DataGridColumnHeader;
if (colHeader == null || colHeader.TabIndex < 0 || colHeader.Column == null)
if (sender is not DataGridColumnHeader colHeader || colHeader.TabIndex < 0 || colHeader.Column == null)
{
return;
}

View file

@ -233,8 +233,7 @@ public partial class ProfilesView
private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e)
{
var colHeader = sender as DataGridColumnHeader;
if (colHeader == null || colHeader.TabIndex < 0 || colHeader.Column == null)
if (sender is not DataGridColumnHeader colHeader || colHeader.TabIndex < 0 || colHeader.Column == null)
{
return;
}