From 3ae268e92bf3fcc8a3ddc0bfee31e888ccb67808 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sun, 27 Feb 2022 18:07:39 +0530 Subject: [PATCH] CacheZoneTree: Updated FindZone() for minor changes. Code refactoring done. --- DnsServerCore/Dns/Trees/CacheZoneTree.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/DnsServerCore/Dns/Trees/CacheZoneTree.cs b/DnsServerCore/Dns/Trees/CacheZoneTree.cs index 3ad218c6..d236ff7b 100644 --- a/DnsServerCore/Dns/Trees/CacheZoneTree.cs +++ b/DnsServerCore/Dns/Trees/CacheZoneTree.cs @@ -18,7 +18,6 @@ along with this program. If not, see . */ using DnsServerCore.Dns.Zones; -using System; namespace DnsServerCore.Dns.Trees { @@ -40,14 +39,14 @@ namespace DnsServerCore.Dns.Trees public override bool TryRemove(string domain, out CacheZone value) { - bool removed = TryRemove(domain, out value, out Node closestNode); + bool removed = TryRemove(domain, out value, out Node currentNode); //remove all cache zones under current zone - Node current = closestNode; + Node current = currentNode; do { - current = current.GetNextNodeWithValue(closestNode.Depth); + current = current.GetNextNodeWithValue(currentNode.Depth); if (current is null) break; @@ -66,19 +65,16 @@ namespace DnsServerCore.Dns.Trees while (true); if (removed) - closestNode.CleanThisBranch(); + currentNode.CleanThisBranch(); return removed; } public CacheZone FindZone(string domain, out CacheZone closest, out CacheZone delegation) { - if (domain is null) - throw new ArgumentNullException(nameof(domain)); - byte[] key = ConvertToByteKey(domain); - CacheZone zoneValue = FindZoneNode(key, out _, out _, out CacheZone closestSubDomain, out CacheZone closestDelegation, out _); + CacheZone zoneValue = FindZoneNode(key, false, out _, out _, out _, out CacheZone closestSubDomain, out CacheZone closestDelegation, out _); if (zoneValue is null) { //zone not found