18 lines
818 B
C#
18 lines
818 B
C#
|
|
using System.Text.RegularExpressions;
|
||
|
|
|
||
|
|
namespace UCVL.VPNPlus;
|
||
|
|
|
||
|
|
// These namespaces carry the control, relay and MagicDNS traffic that the
|
||
|
|
// Tailscale transport itself depends on.
|
||
|
|
internal static class TailnetDnsPolicy
|
||
|
|
{
|
||
|
|
private static readonly string[] Zones = ["tailscale.com", "ts.net"];
|
||
|
|
internal static readonly string DomainPattern = @"(?i)(^|\.)(" + string.Join("|", Zones.Select(Regex.Escape)) + @")\.?$";
|
||
|
|
private static readonly Regex ProtectedDomain = new(DomainPattern, RegexOptions.CultureInvariant);
|
||
|
|
|
||
|
|
internal static bool IsProtectedDomain(string domain) => ProtectedDomain.IsMatch(domain);
|
||
|
|
|
||
|
|
internal static bool IsProtectedSuffix(string suffix) => IsProtectedDomain(suffix)
|
||
|
|
|| Zones.Any(zone => zone.EndsWith("." + suffix.TrimEnd('.'), StringComparison.OrdinalIgnoreCase));
|
||
|
|
}
|