diff --git a/DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs b/DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs index 7e31d781..dff0ac18 100644 --- a/DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs +++ b/DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs @@ -223,12 +223,26 @@ namespace DnsServerCore.Dns.ZoneManagers domain = GetParentZone(domain); } - while (domain != null); + while (domain is not null); blockedDomain = null; return null; } + private bool IsZoneAllowed(Dictionary allowedDomains, string domain) + { + do + { + if (allowedDomains.TryGetValue(domain, out _)) + return true; + + domain = GetParentZone(domain); + } + while (domain is not null); + + return false; + } + #endregion #region public @@ -275,7 +289,7 @@ namespace DnsServerCore.Dns.ZoneManagers { string domain = queue.Dequeue(); - if (allowedDomains.TryGetValue(domain, out _)) + if (IsZoneAllowed(allowedDomains, domain)) continue; //domain is in allowed list so skip adding it to block list zone if (!blockListZone.TryGetValue(domain, out List blockLists))