From 728cbe70f25dd533eec57fd8fb901e6e56aeea25 Mon Sep 17 00:00:00 2001 From: DHR60 <192860629+DHR60@users.noreply.github.com> Date: Sat, 22 Aug 2026 02:18:48 +0000 Subject: [PATCH] Add block AAAA query support (#10004) --- v2rayN/ServiceLib/Handler/ConfigHandler.cs | 1 + .../ServiceLib/Models/Configs/ConfigItems.cs | 1 + .../Models/CoreConfigs/V2rayConfig.cs | 1 + v2rayN/ServiceLib/Resx/ResUI.Designer.cs | 29 ++++++++++++++++- v2rayN/ServiceLib/Resx/ResUI.fa.resx | 2 +- v2rayN/ServiceLib/Resx/ResUI.fr.resx | 2 +- v2rayN/ServiceLib/Resx/ResUI.hu.resx | 2 +- v2rayN/ServiceLib/Resx/ResUI.id.resx | 2 +- v2rayN/ServiceLib/Resx/ResUI.resx | 13 ++++++-- v2rayN/ServiceLib/Resx/ResUI.ru.resx | 2 +- v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx | 11 ++++++- v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx | 4 +-- .../CoreConfig/Singbox/SingboxDnsService.cs | 14 +++++++-- .../CoreConfig/V2ray/V2rayDnsService.cs | 5 +++ .../ViewModels/DNSSettingViewModel.cs | 3 ++ .../Views/AddServerWindow.axaml | 6 ++-- .../Views/DNSSettingWindow.axaml | 31 ++++++++++++++++--- .../Views/DNSSettingWindow.axaml.cs | 1 + v2rayN/v2rayN/Views/AddServerWindow.xaml | 6 ++-- v2rayN/v2rayN/Views/DNSSettingWindow.xaml | 31 ++++++++++++++++--- v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs | 1 + 21 files changed, 142 insertions(+), 26 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index f9a95c6f..be64ca8b 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -115,6 +115,7 @@ public static class ConfigHandler config.ConstItem ??= new ConstItem(); config.SimpleDNSItem ??= InitBuiltinSimpleDNS(); + config.SimpleDNSItem.BlockAAAAQuery ??= false; config.SimpleDNSItem.FakeIPRange ??= Global.FakeIPRanges.FirstOrDefault(); config.SimpleDNSItem.GlobalFakeIp ??= true; config.SimpleDNSItem.BootstrapDNS ??= Global.DomainPureIPDNSAddress.FirstOrDefault(); diff --git a/v2rayN/ServiceLib/Models/Configs/ConfigItems.cs b/v2rayN/ServiceLib/Models/Configs/ConfigItems.cs index 4fbdbb0b..11b45000 100644 --- a/v2rayN/ServiceLib/Models/Configs/ConfigItems.cs +++ b/v2rayN/ServiceLib/Models/Configs/ConfigItems.cs @@ -279,6 +279,7 @@ public class SimpleDNSItem public bool? GlobalFakeIp { get; set; } public string? FakeIPRange { get; set; } public bool? BlockBindingQuery { get; set; } + public bool? BlockAAAAQuery { get; set; } public string? DirectDNS { get; set; } public string? RemoteDNS { get; set; } public string? BootstrapDNS { get; set; } diff --git a/v2rayN/ServiceLib/Models/CoreConfigs/V2rayConfig.cs b/v2rayN/ServiceLib/Models/CoreConfigs/V2rayConfig.cs index e5dcd900..cfa6f9d1 100644 --- a/v2rayN/ServiceLib/Models/CoreConfigs/V2rayConfig.cs +++ b/v2rayN/ServiceLib/Models/CoreConfigs/V2rayConfig.cs @@ -241,6 +241,7 @@ public class Dns4Ray public List servers { get; set; } public bool? serveStale { get; set; } public bool? enableParallelQuery { get; set; } + public string? queryStrategy { get; set; } public string? tag { get; set; } } diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs index ea26590f..3b654b11 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs +++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs @@ -2769,6 +2769,24 @@ namespace ServiceLib.Resx { } } + /// + /// 查找类似 Block AAAA Queries 的本地化字符串。 + /// + public static string TbBlockAAAAQueries { + get { + return ResourceManager.GetString("TbBlockAAAAQueries", resourceCulture); + } + } + + /// + /// 查找类似 Block IPv6 queries when enabled 的本地化字符串。 + /// + public static string TbBlockAAAAQueriesTips { + get { + return ResourceManager.GetString("TbBlockAAAAQueriesTips", resourceCulture); + } + } + /// /// 查找类似 Block SVCB and HTTPS Queries 的本地化字符串。 /// @@ -2779,7 +2797,7 @@ namespace ServiceLib.Resx { } /// - /// 查找类似 Block ECH and HTTP/3 availability checks when enabled 的本地化字符串。 + /// 查找类似 Block ECH and HTTP/3 availability checks when enabled. Always enabled in Xray 的本地化字符串。 /// public static string TbBlockSVCBHTTPSQueriesTips { get { @@ -5031,6 +5049,15 @@ namespace ServiceLib.Resx { } } + /// + /// 查找类似 Xray Only 的本地化字符串。 + /// + public static string TbXrayOnly { + get { + return ResourceManager.GetString("TbXrayOnly", resourceCulture); + } + } + /// /// 查找类似 The delay: {0} ms, {1} 的本地化字符串。 /// diff --git a/v2rayN/ServiceLib/Resx/ResUI.fa.resx b/v2rayN/ServiceLib/Resx/ResUI.fa.resx index 7bdc75b4..fc2e3d91 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.fa.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.fa.resx @@ -1456,7 +1456,7 @@ Custom DNS Enabled, This Page's Settings Invalid - Block ECH and HTTP/3 availability checks when enabled + Block ECH and HTTP/3 availability checks when enabled. Always enabled in Xray Please fill in the correct config template diff --git a/v2rayN/ServiceLib/Resx/ResUI.fr.resx b/v2rayN/ServiceLib/Resx/ResUI.fr.resx index 9688fbd4..b86d96b0 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.fr.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.fr.resx @@ -1453,7 +1453,7 @@ DNS personnalisé activé ; la configuration de cette page sera ignorée - Une fois activé, bloque les requêtes ECH et de disponibilité HTTP/3 + Block ECH and HTTP/3 availability checks when enabled. Always enabled in Xray Veuillez saisir un modèle de configuration valide diff --git a/v2rayN/ServiceLib/Resx/ResUI.hu.resx b/v2rayN/ServiceLib/Resx/ResUI.hu.resx index 3adc061f..a3e4367e 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.hu.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.hu.resx @@ -1456,7 +1456,7 @@ Custom DNS Enabled, This Page's Settings Invalid - Block ECH and HTTP/3 availability checks when enabled + Block ECH and HTTP/3 availability checks when enabled. Always enabled in Xray Please fill in the correct config template diff --git a/v2rayN/ServiceLib/Resx/ResUI.id.resx b/v2rayN/ServiceLib/Resx/ResUI.id.resx index 7fc105cf..38e1ba5c 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.id.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.id.resx @@ -1456,7 +1456,7 @@ DNS kustom diaktifkan, pengaturan halaman ini tidak berlaku - Blokir pemeriksaan ketersediaan ECH dan HTTP/3 saat diaktifkan + Block ECH and HTTP/3 availability checks when enabled. Always enabled in Xray Isi template konfigurasi yang benar diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx index f0de8ad6..0412b2ce 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.resx @@ -1462,7 +1462,7 @@ Custom DNS Enabled, This Page's Settings Invalid - Block ECH and HTTP/3 availability checks when enabled + Block ECH and HTTP/3 availability checks when enabled. Always enabled in Xray Please fill in the correct config template @@ -1860,4 +1860,13 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if Custom config core - + + Xray Only + + + Block AAAA Queries + + + Block IPv6 queries when enabled + + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.ru.resx b/v2rayN/ServiceLib/Resx/ResUI.ru.resx index 390dc540..821652fa 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.ru.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.ru.resx @@ -1462,7 +1462,7 @@ Включён пользовательский DNS — настройки на этой странице не применяются - При включении блокирует проверки доступности ECH и HTTP/3 + Block ECH and HTTP/3 availability checks when enabled. Always enabled in Xray Пожалуйста, заполните корректный шаблон конфигурации diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx index 1dfc0378..5a372476 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx @@ -1459,7 +1459,7 @@ 自定义 DNS 已启用,此页面配置将无效 - 开启后将阻止 ECH 和 HTTP/3 可用性查询 + 开启后将阻止 ECH 和 HTTP/3 可用性查询。Xray 固定开启 请填写正确的配置模板 @@ -1861,4 +1861,13 @@ 自定义配置核心 + + 仅 Xray + + + 阻止 AAAA 查询 + + + 开启后将阻止 IPv6 查询 + \ 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 ecb492f5..6d84fa03 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx @@ -1459,7 +1459,7 @@ 已啟用自訂 DNS,此頁面的設定將不會生效 - 啟用後將封鎖 ECH 與 HTTP/3 可用性查詢 + 啟用後將封鎖 ECH 與 HTTP/3 可用性查詢。Xray 固定啟用 請填寫正確的設定範本 @@ -1861,4 +1861,4 @@ 自訂設定核心 - + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs index 547061d6..ad97d246 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs @@ -282,13 +282,23 @@ public partial class CoreConfigSingboxService { query_type = [1, 28], // A and AAAA }, - fakeipFilterRule - ] + fakeipFilterRule, + ], }; _coreConfig.dns.rules.Add(rule4Fake); } + if (simpleDnsItem.BlockAAAAQuery == true) + { + _coreConfig.dns.rules.Add(new() + { + query_type = [28], + action = "predefined", + rcode = "NOERROR", + }); + } + var routing = context.RoutingItem; if (routing == null) { diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayDnsService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayDnsService.cs index cb61aa69..dbb5b5e8 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayDnsService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayDnsService.cs @@ -82,6 +82,11 @@ public partial class CoreConfigV2rayService dnsItem.serveStale = simpleDnsItem?.ServeStale is true ? true : null; dnsItem.enableParallelQuery = simpleDnsItem?.ParallelQuery is true ? true : null; + if (simpleDnsItem.BlockAAAAQuery == true) + { + dnsItem.queryStrategy = "UseIPv4"; + } + // DNS routing var directDnsTags = dnsItem.servers .Select(server => diff --git a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs index d7a83967..a02bf152 100644 --- a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs @@ -9,6 +9,7 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable [Reactive] public partial bool FakeIP { get; set; } [Reactive] public partial string FakeIPRange { get; set; } [Reactive] public partial bool BlockBindingQuery { get; set; } + [Reactive] public partial bool BlockAAAAQuery { get; set; } [Reactive] public partial string DirectDNS { get; set; } [Reactive] public partial string RemoteDNS { get; set; } [Reactive] public partial string BootstrapDNS { get; set; } @@ -74,6 +75,7 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable FakeIP = item.FakeIP ?? false; FakeIPRange = item.FakeIPRange ?? string.Empty; BlockBindingQuery = item.BlockBindingQuery ?? false; + BlockAAAAQuery = item.BlockAAAAQuery ?? false; DirectDNS = item.DirectDNS ?? string.Empty; RemoteDNS = item.RemoteDNS ?? string.Empty; BootstrapDNS = item.BootstrapDNS ?? string.Empty; @@ -108,6 +110,7 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable _config.SimpleDNSItem.FakeIP = FakeIP; _config.SimpleDNSItem.FakeIPRange = FakeIPRange; _config.SimpleDNSItem.BlockBindingQuery = BlockBindingQuery; + _config.SimpleDNSItem.BlockAAAAQuery = BlockAAAAQuery; _config.SimpleDNSItem.DirectDNS = DirectDNS; _config.SimpleDNSItem.RemoteDNS = RemoteDNS; _config.SimpleDNSItem.BootstrapDNS = BootstrapDNS; diff --git a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml index d3d17d9e..04a305b3 100644 --- a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml @@ -1265,8 +1265,10 @@ Width="400" Margin="{StaticResource Margin4}" VerticalAlignment="Center" - Text="{x:Static resx:ResUI.TbCertSha256Tips}" - TextWrapping="Wrap" /> + TextWrapping="Wrap"> + + + + RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,*"> + + + + this.Bind(ViewModel, vm => vm.FakeIP, v => v.togFakeIP.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.FakeIPRange, v => v.cmbFakeIPRange.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.BlockBindingQuery, v => v.togBlockBindingQuery.IsChecked).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.BlockAAAAQuery, v => v.togBlockAAAAQuery.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.DirectDNS, v => v.cmbDirectDNS.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.RemoteDNS, v => v.cmbRemoteDNS.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.BootstrapDNS, v => v.cmbBootstrapDNS.Text).DisposeWith(disposables); diff --git a/v2rayN/v2rayN/Views/AddServerWindow.xaml b/v2rayN/v2rayN/Views/AddServerWindow.xaml index cd39e7bd..a8c03128 100644 --- a/v2rayN/v2rayN/Views/AddServerWindow.xaml +++ b/v2rayN/v2rayN/Views/AddServerWindow.xaml @@ -1593,8 +1593,10 @@ Margin="{StaticResource Margin4}" VerticalAlignment="Center" Style="{StaticResource ToolbarTextBlock}" - Text="{x:Static resx:ResUI.TbCertSha256Tips}" - TextWrapping="Wrap" /> + TextWrapping="Wrap"> + + + + @@ -387,17 +388,39 @@ Margin="{StaticResource Margin8}" VerticalAlignment="Center" Style="{StaticResource ToolbarTextBlock}" + Text="{x:Static resx:ResUI.TbBlockAAAAQueries}" /> + + + + vm.FakeIP, v => v.togFakeIP.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.FakeIPRange, v => v.cmbFakeIPRange.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.BlockBindingQuery, v => v.togBlockBindingQuery.IsChecked).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.BlockAAAAQuery, v => v.togBlockAAAAQuery.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.DirectDNS, v => v.cmbDirectDNS.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.RemoteDNS, v => v.cmbRemoteDNS.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.BootstrapDNS, v => v.cmbBootstrapDNS.Text).DisposeWith(disposables);