From d4218a189c759da3034daa10d4e080b2953bba64 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sun, 19 May 2024 15:06:25 +0530 Subject: [PATCH] PrimaryZone: updated implementation to use default responsible person config. Code refactoring done. --- DnsServerCore/Dns/Zones/PrimaryZone.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/DnsServerCore/Dns/Zones/PrimaryZone.cs b/DnsServerCore/Dns/Zones/PrimaryZone.cs index 055b70c7..9320c31b 100644 --- a/DnsServerCore/Dns/Zones/PrimaryZone.cs +++ b/DnsServerCore/Dns/Zones/PrimaryZone.cs @@ -100,8 +100,15 @@ namespace DnsServerCore.Dns.Zones InitNotify(_dnsServer); } + string rp; + + if (_dnsServer.ResponsiblePersonInternal is null) + rp = _name.Length == 0 ? _dnsServer.ResponsiblePerson.Address : "hostadmin@" + _name; + else + rp = _dnsServer.ResponsiblePersonInternal.Address; + uint serial = GetNewSerial(0, 0, useSoaSerialDateScheme); - DnsSOARecordData soa = new DnsSOARecordData(primaryNameServer, _name.Length == 0 ? "hostadmin@localhost" : "hostadmin@" + _name, serial, 900, 300, 604800, 900); + DnsSOARecordData soa = new DnsSOARecordData(primaryNameServer, rp, serial, 900, 300, 604800, 900); DnsResourceRecord soaRecord = new DnsResourceRecord(_name, DnsResourceRecordType.SOA, DnsClass.IN, soa.Minimum, soa); soaRecord.GetAuthRecordInfo().UseSoaSerialDateScheme = useSoaSerialDateScheme; @@ -3046,7 +3053,7 @@ namespace DnsServerCore.Dns.Zones throw new DnsServerException("Cannot update record: TTL cannot be greater than SOA EXPIRE."); if (!TryDeleteRecord(oldRecord.Type, oldRecord.RDATA, out DnsResourceRecord deletedRecord)) - throw new InvalidOperationException("Cannot update record: the record does not exists to be updated."); + throw new DnsServerException("Cannot update record: the record does not exists to be updated."); AddRecord(newRecord, out IReadOnlyList addedRecords, out IReadOnlyList deletedRecords);