From e300ef1efd6b17f6f23b197c45f5165dd54e867f Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sun, 16 Jan 2022 19:35:12 +0530 Subject: [PATCH] PrimaryZone: inheriting ApexZone. Fixed issue in UpdateRecord() by handling the error case correctly. --- DnsServerCore/Dns/Zones/PrimaryZone.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DnsServerCore/Dns/Zones/PrimaryZone.cs b/DnsServerCore/Dns/Zones/PrimaryZone.cs index 86b21888..21129b97 100644 --- a/DnsServerCore/Dns/Zones/PrimaryZone.cs +++ b/DnsServerCore/Dns/Zones/PrimaryZone.cs @@ -1,6 +1,6 @@ /* Technitium DNS Server -Copyright (C) 2021 Shreyas Zare (shreyas@technitium.com) +Copyright (C) 2022 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 @@ -28,7 +28,7 @@ using TechnitiumLibrary.Net.Dns.ResourceRecords; namespace DnsServerCore.Dns.Zones { - class PrimaryZone : AuthZone + class PrimaryZone : ApexZone { #region variables @@ -407,7 +407,9 @@ namespace DnsServerCore.Dns.Zones if (oldRecord.Type != newRecord.Type) throw new InvalidOperationException("Old and new record types do not match."); - DeleteRecord(oldRecord.Type, oldRecord.RDATA, out DnsResourceRecord deletedRecord); + if (!DeleteRecord(oldRecord.Type, oldRecord.RDATA, out DnsResourceRecord deletedRecord)) + throw new InvalidOperationException("Cannot update record: the record does not exists to be updated."); + base.AddRecord(newRecord); CommitAndIncrementSerial(new DnsResourceRecord[] { deletedRecord }, new DnsResourceRecord[] { newRecord });