This commit is contained in:
Virtuworks 2013-09-30 16:40:19 -04:00
commit 91a0c420bf

View file

@ -30,10 +30,12 @@ using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.ServiceProcess;
using WebsitePanel.Server.Utils;
using WebsitePanel.Providers.Utils;
namespace WebsitePanel.Providers.DNS
{
public class IscBind : HostingServiceProviderBase, IDnsServer
@ -149,12 +151,9 @@ namespace WebsitePanel.Providers.DNS
soa.PrimaryNsServer = System.Net.Dns.GetHostEntry("LocalHost").HostName;
soa.PrimaryPerson = "hostmaster";//"hostmaster." + zoneName;
records.Add(soa);
ReloadBIND("reconfig", "");
// add DNS zone
UpdateZone(zoneName, records);
// reload config
ReloadBIND();
}
public virtual void AddSecondaryZone(string zoneName, string[] masterServers)
@ -185,7 +184,7 @@ namespace WebsitePanel.Providers.DNS
File.Create(GetZoneFilePath(zoneName)).Close();
// reload config
ReloadBIND();
ReloadBIND("reconfig", "");
}
public virtual DnsRecord[] GetZoneRecords(string zoneName)
@ -255,8 +254,8 @@ namespace WebsitePanel.Providers.DNS
if (File.Exists(zonePath))
File.Delete(zonePath);
// reload config
ReloadBIND();
// reload named.conf
ReloadBIND("reconfig", "");
}
#endregion
@ -819,6 +818,7 @@ namespace WebsitePanel.Providers.DNS
// update zone file
UpdateZoneFile(zoneName, sb.ToString());
ReloadBIND("reload", zoneName);
}
private string CorrectRecordName(string zoneName, string host)
@ -924,10 +924,41 @@ namespace WebsitePanel.Providers.DNS
return StringUtils.ReplaceStringVariable(ZoneFileNameTemplate, "domain_name", zoneName);
}
private void ReloadBIND()
private void ReloadBIND(string Args, string zoneName)
{
// Do we have a rndc.exe? if so use it - improves handling
if (BindReloadBatch.IndexOf("rndc.exe") > 0)
{
Process rndc = new Process();
rndc.StartInfo.FileName = BindReloadBatch;
string rndcArguments = Args;
if (zoneName.Length > 0)
{
rndcArguments += " " + zoneName;
}
rndc.StartInfo.Arguments = rndcArguments;
rndc.StartInfo.CreateNoWindow = true;
rndc.Start();
/*
* Can't figure out how to log the output of the process to auditlog. If someone could be of assistans and fix this.
* it's rndcOutput var that should be written to audit log.s
*
string rndcOutput = "";
while (!rndc.StandardOutput.EndOfStream)
{
rndcOutput += rndc.StandardOutput.ReadLine();
}
*/
}
else
{
FileUtils.ExecuteSystemCommand(BindReloadBatch, "");
}
}
#endregion
public override bool IsInstalled()