mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2025-12-27 11:59:39 +00:00
DhcpServer: Updated implementation to remove delayed save feature for modified auth zones.
This commit is contained in:
@@ -72,10 +72,6 @@ namespace DnsServerCore.Dhcp
|
|||||||
DnsServer _dnsServer;
|
DnsServer _dnsServer;
|
||||||
AuthManager _authManager;
|
AuthManager _authManager;
|
||||||
|
|
||||||
ConcurrentDictionary<string, object> _modifiedDnsAuthZones = new ConcurrentDictionary<string, object>();
|
|
||||||
readonly Timer _saveModifiedDnsAuthZonesTimer;
|
|
||||||
const int SAVE_MODIFIED_DNS_AUTH_ZONES_INTERVAL = 10000;
|
|
||||||
|
|
||||||
volatile ServiceState _state = ServiceState.Stopped;
|
volatile ServiceState _state = ServiceState.Stopped;
|
||||||
|
|
||||||
readonly IPEndPoint _dhcpDefaultEP = new IPEndPoint(IPAddress.Any, 67);
|
readonly IPEndPoint _dhcpDefaultEP = new IPEndPoint(IPAddress.Any, 67);
|
||||||
@@ -109,11 +105,6 @@ namespace DnsServerCore.Dhcp
|
|||||||
|
|
||||||
SaveScopeFile(scope);
|
SaveScopeFile(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
_saveModifiedDnsAuthZonesTimer = new Timer(delegate (object state)
|
|
||||||
{
|
|
||||||
SaveModifiedDnsAuthZones();
|
|
||||||
}, null, Timeout.Infinite, Timeout.Infinite);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -129,12 +120,10 @@ namespace DnsServerCore.Dhcp
|
|||||||
|
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
Stop();
|
|
||||||
|
|
||||||
_saveModifiedDnsAuthZonesTimer?.Dispose();
|
|
||||||
|
|
||||||
_maintenanceTimer?.Dispose();
|
_maintenanceTimer?.Dispose();
|
||||||
|
|
||||||
|
Stop();
|
||||||
|
|
||||||
if (_scopes is not null)
|
if (_scopes is not null)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, Scope> scope in _scopes)
|
foreach (KeyValuePair<string, Scope> scope in _scopes)
|
||||||
@@ -884,11 +873,11 @@ namespace DnsServerCore.Dhcp
|
|||||||
|
|
||||||
//save auth zone file
|
//save auth zone file
|
||||||
if (zoneName is not null)
|
if (zoneName is not null)
|
||||||
SaveDnsAuthZone(zoneName);
|
_dnsServer?.AuthZoneManager.SaveZoneFile(zoneName);
|
||||||
|
|
||||||
//save reverse auth zone file
|
//save reverse auth zone file
|
||||||
if (reverseZoneName is not null)
|
if (reverseZoneName is not null)
|
||||||
SaveDnsAuthZone(reverseZoneName);
|
_dnsServer?.AuthZoneManager.SaveZoneFile(reverseZoneName);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -896,33 +885,6 @@ namespace DnsServerCore.Dhcp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveDnsAuthZone(string zoneName)
|
|
||||||
{
|
|
||||||
if (_modifiedDnsAuthZones.TryAdd(zoneName, null))
|
|
||||||
_saveModifiedDnsAuthZonesTimer.Change(SAVE_MODIFIED_DNS_AUTH_ZONES_INTERVAL, Timeout.Infinite); //save dns auth zone files per interval
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveModifiedDnsAuthZones()
|
|
||||||
{
|
|
||||||
if (_dnsServer is null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ConcurrentDictionary<string, object> modifiedDnsAuthZones = _modifiedDnsAuthZones;
|
|
||||||
_modifiedDnsAuthZones = new ConcurrentDictionary<string, object>();
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, object> authZone in modifiedDnsAuthZones)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_dnsServer.AuthZoneManager.SaveZoneFile(authZone.Key);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_log?.Write(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void BindUdpListener(IPEndPoint dhcpEP)
|
private void BindUdpListener(IPEndPoint dhcpEP)
|
||||||
{
|
{
|
||||||
UdpListener listener = _udpListeners.GetOrAdd(dhcpEP.Address, delegate (IPAddress key)
|
UdpListener listener = _udpListeners.GetOrAdd(dhcpEP.Address, delegate (IPAddress key)
|
||||||
@@ -1292,7 +1254,6 @@ namespace DnsServerCore.Dhcp
|
|||||||
StopMaintenanceTimer();
|
StopMaintenanceTimer();
|
||||||
|
|
||||||
SaveModifiedScopes();
|
SaveModifiedScopes();
|
||||||
SaveModifiedDnsAuthZones();
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, Scope> scope in _scopes)
|
foreach (KeyValuePair<string, Scope> scope in _scopes)
|
||||||
UnloadScope(scope.Value);
|
UnloadScope(scope.Value);
|
||||||
|
|||||||
Reference in New Issue
Block a user