Create the GetDomainFromProfile() function

This commit is contained in:
Wydy 2025-09-21 10:27:28 +08:00
parent bc90eb7eba
commit 9e21977acf
2 changed files with 15 additions and 20 deletions

View file

@ -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

View file

@ -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)
{