AuthZoneInfo: implemented zone last modified feature.

This commit is contained in:
Shreyas Zare
2023-09-23 18:06:41 +05:30
parent 88457090f2
commit 323876b14f

View File

@@ -55,6 +55,7 @@ namespace DnsServerCore.Dns.Zones
readonly IReadOnlyCollection<IPAddress> _notifyNameServers;
readonly AuthZoneUpdate _update;
readonly IReadOnlyCollection<IPAddress> _updateIpAddresses;
readonly DateTime _lastModified;
readonly DateTime _expiry;
readonly IReadOnlyList<DnsResourceRecord> _zoneHistory; //for IXFR support
readonly IReadOnlyDictionary<string, object> _zoneTransferTsigKeyNames;
@@ -87,7 +88,7 @@ namespace DnsServerCore.Dns.Zones
}
}
public AuthZoneInfo(BinaryReader bR)
public AuthZoneInfo(BinaryReader bR, DateTime lastModified)
{
byte version = bR.ReadByte();
switch (version)
@@ -99,6 +100,7 @@ namespace DnsServerCore.Dns.Zones
case 5:
case 6:
case 7:
case 8:
_name = bR.ReadShortString();
_type = (AuthZoneType)bR.ReadByte();
_disabled = bR.ReadBoolean();
@@ -169,6 +171,11 @@ namespace DnsServerCore.Dns.Zones
}
}
if (version >= 8)
_lastModified = bR.ReadDateTime();
else
_lastModified = lastModified;
switch (_type)
{
case AuthZoneType.Primary:
@@ -363,6 +370,7 @@ namespace DnsServerCore.Dns.Zones
_notifyNameServers = _apexZone.NotifyNameServers;
_update = _apexZone.Update;
_updateIpAddresses = _apexZone.UpdateIpAddresses;
_lastModified = _apexZone.LastModified;
}
#endregion
@@ -458,7 +466,7 @@ namespace DnsServerCore.Dns.Zones
if (_apexZone is null)
throw new InvalidOperationException();
bW.Write((byte)7); //version
bW.Write((byte)8); //version
bW.WriteShortString(_name);
bW.Write((byte)_type);
@@ -502,6 +510,8 @@ namespace DnsServerCore.Dns.Zones
ipAddress.WriteTo(bW);
}
bW.Write(_lastModified);
switch (_type)
{
case AuthZoneType.Primary:
@@ -780,6 +790,17 @@ namespace DnsServerCore.Dns.Zones
}
}
public DateTime LastModified
{
get
{
if (_apexZone is null)
return _lastModified;
return _apexZone.LastModified;
}
}
public DateTime Expiry
{
get