From 135c22ebe8b545de4209a8ea72a072ed85e0bf1d Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 14 Nov 2020 16:49:50 +0530 Subject: [PATCH] StubZone: updated stub zone to not allow adding records since this will create inconsistency issues when resursive resolvers query the stub zone. Removed stub sub domain zone too. --- .../Dns/ZoneManagers/AuthZoneManager.cs | 2 - DnsServerCore/Dns/Zones/StubSubDomainZone.cs | 32 ----------- DnsServerCore/Dns/Zones/StubZone.cs | 53 ++----------------- 3 files changed, 5 insertions(+), 82 deletions(-) delete mode 100644 DnsServerCore/Dns/Zones/StubSubDomainZone.cs diff --git a/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs b/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs index e3046631..1fef40bf 100644 --- a/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs +++ b/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs @@ -232,8 +232,6 @@ namespace DnsServerCore.Dns.ZoneManagers return new PrimarySubDomainZone(authZone as PrimaryZone, domain); else if (authZone is SecondaryZone) return new SecondarySubDomainZone(domain); - else if (authZone is StubZone) - return new StubSubDomainZone(domain); else if (authZone is ForwarderZone) return new ForwarderSubDomainZone(domain); diff --git a/DnsServerCore/Dns/Zones/StubSubDomainZone.cs b/DnsServerCore/Dns/Zones/StubSubDomainZone.cs deleted file mode 100644 index 145fdef1..00000000 --- a/DnsServerCore/Dns/Zones/StubSubDomainZone.cs +++ /dev/null @@ -1,32 +0,0 @@ -/* -Technitium DNS Server -Copyright (C) 2020 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 -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -namespace DnsServerCore.Dns.Zones -{ - class StubSubDomainZone : SubDomainZone - { - #region constructor - - public StubSubDomainZone(string name) - : base(name) - { } - - #endregion - } -} diff --git a/DnsServerCore/Dns/Zones/StubZone.cs b/DnsServerCore/Dns/Zones/StubZone.cs index d0282cbc..27f5e13a 100644 --- a/DnsServerCore/Dns/Zones/StubZone.cs +++ b/DnsServerCore/Dns/Zones/StubZone.cs @@ -332,12 +332,6 @@ namespace DnsServerCore.Dns.Zones { switch (type) { - case DnsResourceRecordType.CNAME: - throw new InvalidOperationException("Cannot set CNAME record to zone root."); - - case DnsResourceRecordType.NS: - throw new InvalidOperationException("Cannot set NS records at stub zone root."); - case DnsResourceRecordType.SOA: if ((records.Count != 1) || !records[0].Name.Equals(_name, StringComparison.OrdinalIgnoreCase)) throw new InvalidOperationException("Invalid SOA record."); @@ -346,65 +340,28 @@ namespace DnsServerCore.Dns.Zones break; default: - base.SetRecords(type, records); - break; + throw new InvalidOperationException("Cannot set records in stub zone."); } } public override void AddRecord(DnsResourceRecord record) { - switch (record.Type) - { - case DnsResourceRecordType.NS: - throw new InvalidOperationException("Cannot add NS record at stub zone root."); - - default: - base.AddRecord(record); - break; - } + throw new InvalidOperationException("Cannot add record in stub zone."); } public override bool DeleteRecords(DnsResourceRecordType type) { - switch (type) - { - case DnsResourceRecordType.NS: - throw new InvalidOperationException("Cannot delete NS records in stub zone root."); - - case DnsResourceRecordType.SOA: - throw new InvalidOperationException("Cannot delete SOA record."); - - default: - return base.DeleteRecords(type); - } + throw new InvalidOperationException("Cannot delete record in stub zone."); } public override bool DeleteRecord(DnsResourceRecordType type, DnsResourceRecordData record) { - switch (type) - { - case DnsResourceRecordType.NS: - throw new InvalidOperationException("Cannot delete NS record in stub zone root."); - - case DnsResourceRecordType.SOA: - throw new InvalidOperationException("Cannot delete SOA record."); - - default: - return base.DeleteRecord(type, record); - } + throw new InvalidOperationException("Cannot delete records in stub zone."); } public override IReadOnlyList QueryRecords(DnsResourceRecordType type) { - switch (type) - { - case DnsResourceRecordType.SOA: - case DnsResourceRecordType.NS: - return Array.Empty(); //stub zone has no authority so cant return NS or SOA records as query response - - default: - return base.QueryRecords(type); - } + return Array.Empty(); //stub zone has no authority so cant return any records as query response to allow generating referral response } #endregion