diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index 358d4e9a..13be95c9 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -459,6 +459,19 @@ public class Utils return false; } + public static string? GetDomainFromProfile(ProfileItem node) + { + if (IsDomain(node.Address)) + { + return node.Address; + } + else if (node.Sni != null && IsDomain(node.Sni)) + { + return node.Sni; + } + return null; + } + #endregion 数据检查 #region 测速 diff --git a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs index f31cd012..01f92f19 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs @@ -46,16 +46,7 @@ public partial class CoreConfigSingboxService // Tun2SocksAddress if (node != null) { - string? domainToAdd = null; - - if (Utils.IsDomain(node.Address)) - { - domainToAdd = node.Address; - } - else if (node.Sni != null && Utils.IsDomain(node.Sni)) - { - domainToAdd = node.Sni; - } + string? domainToAdd = Utils.GetDomainFromProfile(node); if (domainToAdd != null) { @@ -363,16 +354,7 @@ public partial class CoreConfigSingboxService // Tun2SocksAddress if (node != null) { - string? domainToAdd = null; - - if (Utils.IsDomain(node.Address)) - { - domainToAdd = node.Address; - } - else if (node.Sni != null && Utils.IsDomain(node.Sni)) - { - domainToAdd = node.Sni; - } + string? domainToAdd = Utils.GetDomainFromProfile(node); if (domainToAdd != null) {