mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2026-01-07 17:24:02 +00:00
DhcpServer: added error handling to fix issue when exception is thrown causing the client to not receive IP address.
This commit is contained in:
@@ -647,23 +647,32 @@ namespace DnsServerCore.Dhcp
|
||||
if (!DnsClient.IsDomainNameValid(domain))
|
||||
return;
|
||||
|
||||
if (add)
|
||||
try
|
||||
{
|
||||
//update forward zone
|
||||
_authZoneManager.CreatePrimaryZone(scope.DomainName, _authZoneManager.ServerDomain, false);
|
||||
_authZoneManager.SetRecords(domain, DnsResourceRecordType.A, scope.DnsTtl, new DnsResourceRecordData[] { new DnsARecord(address) });
|
||||
if (add)
|
||||
{
|
||||
//update forward zone
|
||||
_authZoneManager.CreatePrimaryZone(scope.DomainName, _authZoneManager.ServerDomain, false);
|
||||
_authZoneManager.SetRecords(domain, DnsResourceRecordType.A, scope.DnsTtl, new DnsResourceRecordData[] { new DnsARecord(address) });
|
||||
|
||||
//update reverse zone
|
||||
_authZoneManager.CreatePrimaryZone(Zone.GetReverseZone(address, scope.SubnetMask), _authZoneManager.ServerDomain, false);
|
||||
_authZoneManager.SetRecords(Zone.GetReverseZone(address, 32), DnsResourceRecordType.PTR, scope.DnsTtl, new DnsResourceRecordData[] { new DnsPTRRecord(domain) });
|
||||
//update reverse zone
|
||||
_authZoneManager.CreatePrimaryZone(Zone.GetReverseZone(address, scope.SubnetMask), _authZoneManager.ServerDomain, false);
|
||||
_authZoneManager.SetRecords(Zone.GetReverseZone(address, 32), DnsResourceRecordType.PTR, scope.DnsTtl, new DnsResourceRecordData[] { new DnsPTRRecord(domain) });
|
||||
}
|
||||
else
|
||||
{
|
||||
//remove from forward zone
|
||||
_authZoneManager.DeleteRecords(domain, DnsResourceRecordType.A);
|
||||
|
||||
//remove from reverse zone
|
||||
_authZoneManager.DeleteRecords(Zone.GetReverseZone(address, 32), DnsResourceRecordType.PTR);
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
//remove from forward zone
|
||||
_authZoneManager.DeleteRecords(domain, DnsResourceRecordType.A);
|
||||
|
||||
//remove from reverse zone
|
||||
_authZoneManager.DeleteRecords(Zone.GetReverseZone(address, 32), DnsResourceRecordType.PTR);
|
||||
LogManager log = _log;
|
||||
if (log != null)
|
||||
log.Write(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user