From fef22cfdc57cc8aec2421016a135e4e9c1b6fa3c Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 6 Jun 2020 15:58:16 +0530 Subject: [PATCH] Zone: moved SetRecords(), AddRecord(). DeleteRecords() & DeleteRecord() methods to AuthZone. --- DnsServerCore/Dns/Zones/Zone.cs | 68 --------------------------------- 1 file changed, 68 deletions(-) diff --git a/DnsServerCore/Dns/Zones/Zone.cs b/DnsServerCore/Dns/Zones/Zone.cs index 2d86caed..407fdbb5 100644 --- a/DnsServerCore/Dns/Zones/Zone.cs +++ b/DnsServerCore/Dns/Zones/Zone.cs @@ -17,7 +17,6 @@ along with this program. If not, see . */ -using System; using System.Collections.Concurrent; using System.Collections.Generic; using TechnitiumLibrary.Net.Dns; @@ -54,73 +53,6 @@ namespace DnsServerCore.Dns.Zones return records; } - public virtual void SetRecords(DnsResourceRecordType type, IReadOnlyList records) - { - _entries[type] = records; - } - - public virtual void AddRecord(DnsResourceRecord record) - { - switch (record.Type) - { - case DnsResourceRecordType.CNAME: - case DnsResourceRecordType.PTR: - case DnsResourceRecordType.SOA: - throw new InvalidOperationException("Cannot add record: use SetRecords() for " + record.Type.ToString() + " record"); - } - - _entries.AddOrUpdate(record.Type, delegate (DnsResourceRecordType key) - { - return new DnsResourceRecord[] { record }; - }, - delegate (DnsResourceRecordType key, IReadOnlyList existingRecords) - { - foreach (DnsResourceRecord existingRecord in existingRecords) - { - if (record.Equals(existingRecord.RDATA)) - return existingRecords; - } - - List updateRecords = new List(existingRecords.Count + 1); - - updateRecords.AddRange(existingRecords); - updateRecords.Add(record); - - return updateRecords; - }); - } - - public virtual bool DeleteRecords(DnsResourceRecordType type) - { - return _entries.TryRemove(type, out _); - } - - public virtual bool DeleteRecord(DnsResourceRecordType type, DnsResourceRecordData record) - { - if (_entries.TryGetValue(type, out IReadOnlyList existingRecords)) - { - if (existingRecords.Count == 1) - { - if (record.Equals(existingRecords[0].RDATA)) - return _entries.TryRemove(type, out _); - } - else - { - List updateRecords = new List(existingRecords.Count); - - for (int i = 0; i < existingRecords.Count; i++) - { - if (!record.Equals(existingRecords[i].RDATA)) - updateRecords.Add(existingRecords[i]); - } - - return _entries.TryUpdate(type, updateRecords, existingRecords); - } - } - - return false; - } - public abstract bool ContainsNameServerRecords(); #endregion