mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2026-03-20 20:40:15 +00:00
ForwarderZone: added SetRecords() and AddRecord() methods with validation checks.
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user