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.

This commit is contained in:
Shreyas Zare
2020-11-14 16:49:50 +05:30
parent 07e714bd14
commit 135c22ebe8
3 changed files with 5 additions and 82 deletions

View File

@@ -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);

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
namespace DnsServerCore.Dns.Zones
{
class StubSubDomainZone : SubDomainZone
{
#region constructor
public StubSubDomainZone(string name)
: base(name)
{ }
#endregion
}
}

View File

@@ -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<DnsResourceRecord> QueryRecords(DnsResourceRecordType type)
{
switch (type)
{
case DnsResourceRecordType.SOA:
case DnsResourceRecordType.NS:
return Array.Empty<DnsResourceRecord>(); //stub zone has no authority so cant return NS or SOA records as query response
default:
return base.QueryRecords(type);
}
return Array.Empty<DnsResourceRecord>(); //stub zone has no authority so cant return any records as query response to allow generating referral response
}
#endregion