From 7be440d547bfe52c828193166159a75d53318a0d Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sun, 14 Jan 2024 17:58:47 +0530 Subject: [PATCH] AuthZone: Added QueryRecordsWildcard() method to get processed wildcard response. --- DnsServerCore/Dns/Zones/AuthZone.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/DnsServerCore/Dns/Zones/AuthZone.cs b/DnsServerCore/Dns/Zones/AuthZone.cs index 6c9afb7d..e488dafd 100644 --- a/DnsServerCore/Dns/Zones/AuthZone.cs +++ b/DnsServerCore/Dns/Zones/AuthZone.cs @@ -1,6 +1,6 @@ /* Technitium DNS Server -Copyright (C) 2023 Shreyas Zare (shreyas@technitium.com) +Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -934,6 +934,24 @@ namespace DnsServerCore.Dns.Zones return Array.Empty(); } + public IReadOnlyList QueryRecordsWildcard(DnsResourceRecordType type, bool dnssecOk, string queryDomain) + { + IReadOnlyList answers = QueryRecords(type, dnssecOk); + + if ((answers.Count > 0) && _name.StartsWith('*') && !_name.Equals(queryDomain, StringComparison.OrdinalIgnoreCase)) + { + //wildcard zone; generate new answer records + DnsResourceRecord[] wildcardAnswers = new DnsResourceRecord[answers.Count]; + + for (int i = 0; i < answers.Count; i++) + wildcardAnswers[i] = new DnsResourceRecord(queryDomain, answers[i].Type, answers[i].Class, answers[i].TTL, answers[i].RDATA) { Tag = answers[i].Tag }; + + answers = wildcardAnswers; + } + + return answers; + } + public IReadOnlyList GetRecords(DnsResourceRecordType type) { if (_entries.TryGetValue(type, out IReadOnlyList records))