From 71a0cd72ca53ef40063fdec37882147e2dd0e22f Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 11 Sep 2021 17:59:26 +0530 Subject: [PATCH] DnsWebService: minor changes and refactoring done. --- DnsServerCore/DnsWebService.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/DnsServerCore/DnsWebService.cs b/DnsServerCore/DnsWebService.cs index 267b0cf9..8b21168a 100644 --- a/DnsServerCore/DnsWebService.cs +++ b/DnsServerCore/DnsWebService.cs @@ -5535,7 +5535,7 @@ namespace DnsServerCore jsonWriter.WriteStartObject(); jsonWriter.WritePropertyName("name"); - jsonWriter.WriteValue(application.AppName); + jsonWriter.WriteValue(application.Name); jsonWriter.WritePropertyName("version"); jsonWriter.WriteValue(GetCleanVersion(application.Version)); @@ -5545,7 +5545,7 @@ namespace DnsServerCore foreach (dynamic jsonStoreApp in jsonStoreAppsArray) { string name = jsonStoreApp.name.Value; - if (name.Equals(application.AppName)) + if (name.Equals(application.Name)) { string version = jsonStoreApp.version.Value; string url = jsonStoreApp.url.Value; @@ -5712,6 +5712,8 @@ namespace DnsServerCore if (string.IsNullOrEmpty(name)) throw new DnsWebServiceException("Parameter 'name' missing."); + name = name.Trim(); + string url = request.QueryString["url"]; if (string.IsNullOrEmpty(url)) throw new DnsWebServiceException("Parameter 'url' missing."); @@ -5763,6 +5765,8 @@ namespace DnsServerCore if (string.IsNullOrEmpty(name)) throw new DnsWebServiceException("Parameter 'name' missing."); + name = name.Trim(); + string url = request.QueryString["url"]; if (string.IsNullOrEmpty(url)) throw new DnsWebServiceException("Parameter 'url' missing."); @@ -5814,6 +5818,8 @@ namespace DnsServerCore if (string.IsNullOrEmpty(name)) throw new DnsWebServiceException("Parameter 'name' missing."); + name = name.Trim(); + #region skip to content int crlfCount = 0; @@ -5874,6 +5880,8 @@ namespace DnsServerCore if (string.IsNullOrEmpty(name)) throw new DnsWebServiceException("Parameter 'name' missing."); + name = name.Trim(); + #region skip to content int crlfCount = 0; @@ -5934,6 +5942,8 @@ namespace DnsServerCore if (string.IsNullOrEmpty(name)) throw new DnsWebServiceException("Parameter 'name' missing."); + name = name.Trim(); + _dnsServer.DnsApplicationManager.UninstallApplication(name); _log.Write(GetRequestRemoteEndPoint(request), "[" + GetSession(request).Username + "] DNS application '" + name + "' was uninstalled successfully."); } @@ -5944,6 +5954,8 @@ namespace DnsServerCore if (string.IsNullOrEmpty(name)) throw new DnsWebServiceException("Parameter 'name' missing."); + name = name.Trim(); + if (!_dnsServer.DnsApplicationManager.Applications.TryGetValue(name, out DnsApplication application)) throw new DnsWebServiceException("DNS application was not found: " + name); @@ -5959,6 +5971,8 @@ namespace DnsServerCore if (string.IsNullOrEmpty(name)) throw new DnsWebServiceException("Parameter 'name' missing."); + name = name.Trim(); + if (!_dnsServer.DnsApplicationManager.Applications.TryGetValue(name, out DnsApplication application)) throw new DnsWebServiceException("DNS application was not found: " + name);