mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2026-01-06 08:45:32 +00:00
DnsWebService: Save zone file code updated to allow storing all records for a given authoritative zone in a single file instead of different file for each sub domain. Implemented delete zone file feature accordingly.
This commit is contained in:
@@ -691,10 +691,8 @@ namespace DnsServerCore
|
||||
if (string.IsNullOrEmpty(domain))
|
||||
throw new DnsWebServiceException("Parameter 'domain' missing.");
|
||||
|
||||
string[] deletedZones = _dnsServer.AuthoritativeZoneRoot.DeleteZone(domain);
|
||||
|
||||
foreach (string deletedZone in deletedZones)
|
||||
DeleteZoneFile(deletedZone);
|
||||
_dnsServer.AuthoritativeZoneRoot.DeleteZone(domain);
|
||||
DeleteZoneFile(domain);
|
||||
}
|
||||
|
||||
private void EnableZone(HttpListenerRequest request)
|
||||
@@ -1311,26 +1309,22 @@ namespace DnsServerCore
|
||||
private void SaveZoneFile(string domain)
|
||||
{
|
||||
domain = domain.ToLower();
|
||||
DnsResourceRecord[] records = _dnsServer.AuthoritativeZoneRoot.GetAllRecords(domain, false);
|
||||
DnsResourceRecord[] records = _dnsServer.AuthoritativeZoneRoot.GetAllRecords(domain, true, true);
|
||||
|
||||
if ((records == null) || (records.Length == 0))
|
||||
{
|
||||
DeleteZoneFile(domain);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (FileStream fS = new FileStream(Path.Combine(_configFolder, domain + ".zone"), FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
BincodingEncoder encoder = new BincodingEncoder(fS, "DZ", 1);
|
||||
string authZone = records[0].Name.ToLower();
|
||||
|
||||
encoder.Encode(records);
|
||||
}
|
||||
using (FileStream fS = new FileStream(Path.Combine(_configFolder, authZone + ".zone"), FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
BincodingEncoder encoder = new BincodingEncoder(fS, "DZ", 1);
|
||||
|
||||
encoder.Encode(records);
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteZoneFile(string domain)
|
||||
{
|
||||
domain = domain.ToLower();
|
||||
|
||||
File.Delete(Path.Combine(_configFolder, domain + ".zone"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user