mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2025-12-29 13:00:35 +00:00
added validation checks for api calls.
This commit is contained in:
@@ -1807,7 +1807,8 @@ namespace DnsServerCore
|
||||
if (string.IsNullOrEmpty(domain))
|
||||
throw new DnsWebServiceException("Parameter 'domain' missing.");
|
||||
|
||||
_dnsServer.AuthoritativeZoneRoot.DeleteZone(domain, false);
|
||||
if (!_dnsServer.AuthoritativeZoneRoot.DeleteZone(domain, false))
|
||||
throw new DnsWebServiceException("Zone '" + domain + "' was not found.");
|
||||
|
||||
_log.Write(GetRequestRemoteEndPoint(request), true, "[" + GetSession(request).Username + "] Authoritative zone was deleted: " + domain);
|
||||
|
||||
@@ -1820,6 +1821,9 @@ namespace DnsServerCore
|
||||
if (string.IsNullOrEmpty(domain))
|
||||
throw new DnsWebServiceException("Parameter 'domain' missing.");
|
||||
|
||||
if (!_dnsServer.AuthoritativeZoneRoot.DeleteZone(domain, false))
|
||||
throw new DnsWebServiceException("Zone '" + domain + "' was not found.");
|
||||
|
||||
_dnsServer.AuthoritativeZoneRoot.EnableZone(domain);
|
||||
|
||||
_log.Write(GetRequestRemoteEndPoint(request), true, "[" + GetSession(request).Username + "] Authoritative zone was enabled: " + domain);
|
||||
@@ -1833,6 +1837,9 @@ namespace DnsServerCore
|
||||
if (string.IsNullOrEmpty(domain))
|
||||
throw new DnsWebServiceException("Parameter 'domain' missing.");
|
||||
|
||||
if (!_dnsServer.AuthoritativeZoneRoot.DeleteZone(domain, false))
|
||||
throw new DnsWebServiceException("Zone '" + domain + "' was not found.");
|
||||
|
||||
_dnsServer.AuthoritativeZoneRoot.DisableZone(domain);
|
||||
|
||||
_log.Write(GetRequestRemoteEndPoint(request), true, "[" + GetSession(request).Username + "] Authoritative zone was disabled: " + domain);
|
||||
@@ -1933,6 +1940,8 @@ namespace DnsServerCore
|
||||
throw new DnsWebServiceException("Parameter 'domain' missing.");
|
||||
|
||||
DnsResourceRecord[] records = _dnsServer.AuthoritativeZoneRoot.GetAllRecords(domain);
|
||||
if (records.Length == 0)
|
||||
throw new DnsWebServiceException("Zone '" + domain + "' was not found.");
|
||||
|
||||
WriteRecordsAsJson(records, jsonWriter, true);
|
||||
}
|
||||
@@ -2151,6 +2160,9 @@ namespace DnsServerCore
|
||||
if (string.IsNullOrEmpty(value))
|
||||
throw new DnsWebServiceException("Parameter 'value' missing.");
|
||||
|
||||
if (!_dnsServer.AuthoritativeZoneRoot.ZoneExists(domain))
|
||||
throw new DnsWebServiceException("Zone '" + domain + "' was not found.");
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DnsResourceRecordType.A:
|
||||
@@ -2654,6 +2666,8 @@ namespace DnsServerCore
|
||||
{
|
||||
domain = domain.ToLower();
|
||||
DnsResourceRecord[] records = _dnsServer.AuthoritativeZoneRoot.GetAllRecords(domain, DnsResourceRecordType.ANY, true, true);
|
||||
if (records.Length == 0)
|
||||
throw new DnsWebServiceException("Zone '" + domain + "' was not found.");
|
||||
|
||||
string authZone = records[0].Name.ToLower();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user