From ffd31e05e61a8267f75a4da5c4a70eff82e087a5 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 19 Feb 2022 12:50:33 +0530 Subject: [PATCH] ZoneTree: renamed FindZone() to FindZoneNode(). Updated FindZoneNode() to set correct closest authority when exact match is found for an apex zone. --- DnsServerCore/Dns/Trees/ZoneTree.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/DnsServerCore/Dns/Trees/ZoneTree.cs b/DnsServerCore/Dns/Trees/ZoneTree.cs index 3098b963..5dcaa1ce 100644 --- a/DnsServerCore/Dns/Trees/ZoneTree.cs +++ b/DnsServerCore/Dns/Trees/ZoneTree.cs @@ -190,7 +190,7 @@ namespace DnsServerCore.Dns.Trees return (i == mainKey.Length) && (j < testKey.Length); } - protected TNode FindZone(byte[] key, out Node closestNode, out Node closestAuthorityNode, out TSubDomainZone closestSubDomain, out TSubDomainZone closestDelegation, out TApexZone closestAuthority) + protected TNode FindZoneNode(byte[] key, out Node closestNode, out Node closestAuthorityNode, out TSubDomainZone closestSubDomain, out TSubDomainZone closestDelegation, out TApexZone closestAuthority) { closestNode = _root; closestAuthorityNode = null; @@ -263,7 +263,24 @@ namespace DnsServerCore.Dns.Trees { //match exact + wildcard keys if (KeysMatch(key, value.Key)) + { + //update authority since the matched zone is apex zone + TNode zoneValue = value.Value; + if (zoneValue is not null) + { + TApexZone authority = null; + + GetClosestValuesForZone(zoneValue, ref closestSubDomain, ref closestDelegation, ref authority); + + if (authority is not null) + { + closestAuthority = authority; + closestAuthorityNode = closestNode; + } + } + return value.Value; //found matching value + } } }