diff --git a/v2rayN/ServiceLib/Models/V2rayConfig.cs b/v2rayN/ServiceLib/Models/V2rayConfig.cs index d080d14c..2e5ed4b4 100644 --- a/v2rayN/ServiceLib/Models/V2rayConfig.cs +++ b/v2rayN/ServiceLib/Models/V2rayConfig.cs @@ -210,6 +210,7 @@ public class DnsServer4Ray { public string? address { get; set; } public List? domains { get; set; } + public bool? skipFallback { get; set; } } public class Routing4Ray diff --git a/v2rayN/ServiceLib/Sample/dns_v2ray_normal b/v2rayN/ServiceLib/Sample/dns_v2ray_normal index 9aecbd6e..3f9c8b22 100644 --- a/v2rayN/ServiceLib/Sample/dns_v2ray_normal +++ b/v2rayN/ServiceLib/Sample/dns_v2ray_normal @@ -15,6 +15,7 @@ }, { "address": "223.5.5.5", + "skipFallback": true, "domains": [ "geosite:cn" ], diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index 1bd23872..7b940d07 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -1176,19 +1176,70 @@ public class CoreConfigV2rayService private async Task GenDnsDomains(ProfileItem? node, JsonNode dns, DNSItem? dNSItem) { if (node == null) - { return 0; } + { + return 0; + } var servers = dns["servers"]; if (servers != null) { + var domainList = new List(); + string? wireguardEndpointDomain = null; if (Utils.IsDomain(node.Address)) + { + domainList.Add(node.Address); + } + var subItem = await AppHandler.Instance.GetSubItem(node.Subid); + if (subItem is not null) + { + // Previous proxy + var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); + if (prevNode is not null + && prevNode.ConfigType != EConfigType.Custom + && prevNode.ConfigType != EConfigType.Hysteria2 + && prevNode.ConfigType != EConfigType.TUIC + && Utils.IsDomain(prevNode.Address)) + { + domainList.Add(prevNode.Address); + } + + // Next proxy + var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile); + if (nextNode is not null + && nextNode.ConfigType != EConfigType.Custom + && nextNode.ConfigType != EConfigType.Hysteria2 + && nextNode.ConfigType != EConfigType.TUIC + && Utils.IsDomain(nextNode.Address)) + { + if (nextNode.ConfigType == EConfigType.WireGuard) + { + wireguardEndpointDomain = nextNode.Address; + } + else + { + domainList.Add(nextNode.Address); + } + } + } + if (domainList.Count > 0) { var dnsServer = new DnsServer4Ray() { address = string.IsNullOrEmpty(dNSItem?.DomainDNSAddress) ? Global.DomainDNSAddress.FirstOrDefault() : dNSItem?.DomainDNSAddress, - domains = [node.Address] + skipFallback = true, + domains = domainList }; servers.AsArray().Add(JsonUtils.SerializeToNode(dnsServer)); } + if (wireguardEndpointDomain is not null) + { + var dnsServer = new DnsServer4Ray() + { + address = string.IsNullOrEmpty(dNSItem?.DomainDNSAddress) ? Global.DomainDNSAddress.FirstOrDefault() : dNSItem?.DomainDNSAddress, + skipFallback = true, + domains = new() { wireguardEndpointDomain } + }; + servers.AsArray().Insert(0, JsonUtils.SerializeToNode(dnsServer)); + } } return await Task.FromResult(0); } diff --git a/v2rayN/ServiceLib/Services/SpeedtestService.cs b/v2rayN/ServiceLib/Services/SpeedtestService.cs index 2a605d36..f4cd64a2 100644 --- a/v2rayN/ServiceLib/Services/SpeedtestService.cs +++ b/v2rayN/ServiceLib/Services/SpeedtestService.cs @@ -357,8 +357,8 @@ public class SpeedtestService private List> GetTestBatchItem(List lstSelected, int pageSize) { List> lstTest = new(); - var lst1 = lstSelected.Where(t => t.ConfigType is not (EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard)).ToList(); - var lst2 = lstSelected.Where(t => t.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard).ToList(); + var lst1 = lstSelected.Where(t => t.ConfigType is not (EConfigType.Hysteria2 or EConfigType.TUIC)).ToList(); + var lst2 = lstSelected.Where(t => t.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC).ToList(); for (var num = 0; num < (int)Math.Ceiling(lst1.Count * 1.0 / pageSize); num++) { diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml index f5d1b947..bbc78a72 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml @@ -39,13 +39,13 @@ + + - - diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml b/v2rayN/v2rayN/Views/MainWindow.xaml index 3511a429..9e82e0af 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml +++ b/v2rayN/v2rayN/Views/MainWindow.xaml @@ -82,6 +82,14 @@ x:Name="menuAddShadowsocksServer" Height="{StaticResource MenuItemHeight}" Header="{x:Static resx:ResUI.menuAddShadowsocksServer}" /> + + - - @@ -147,7 +147,8 @@ - >>>>>> ce6572af3da479b546bc9ea764a4462050ea0ba5 AutomationProperties.Name="{x:Static resx:ResUI.menuSetting}">