mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2025-12-31 22:08:38 +00:00
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:
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user