ForwarderZone: added SetRecords() and AddRecord() methods with validation checks.

This commit is contained in:
Shreyas Zare
2020-06-27 11:51:43 +05:30
parent c29424f9c3
commit 6c25e9498e

View File

@@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using TechnitiumLibrary.Net.Dns;
using TechnitiumLibrary.Net.Dns.ResourceRecords;
@@ -41,5 +43,41 @@ namespace DnsServerCore.Dns.Zones
}
#endregion
#region public
public override void SetRecords(DnsResourceRecordType type, IReadOnlyList<DnsResourceRecord> records)
{
switch (type)
{
case DnsResourceRecordType.CNAME:
throw new InvalidOperationException("Cannot set CNAME record to zone root.");
case DnsResourceRecordType.NS:
throw new InvalidOperationException("Cannot set NS record to forwarder zone root.");
case DnsResourceRecordType.SOA:
throw new InvalidOperationException("Cannot set SOA record to forwarder zone root.");
default:
base.SetRecords(type, records);
break;
}
}
public override void AddRecord(DnsResourceRecord record)
{
switch (record.Type)
{
case DnsResourceRecordType.NS:
throw new InvalidOperationException("Cannot add NS record at forwarder zone root.");
default:
base.AddRecord(record);
break;
}
}
#endregion
}
}