Пример #1
0
        public void ConvertToDynamicLease(HttpListenerRequest request)
        {
            string scopeName = request.QueryString["name"];

            if (string.IsNullOrEmpty(scopeName))
            {
                throw new DnsWebServiceException("Parameter 'name' missing.");
            }

            Scope scope = _dnsWebService.DhcpServer.GetScope(scopeName);

            if (scope == null)
            {
                throw new DnsWebServiceException("DHCP scope does not exists: " + scopeName);
            }

            string strHardwareAddress = request.QueryString["hardwareAddress"];

            if (string.IsNullOrEmpty(strHardwareAddress))
            {
                throw new DnsWebServiceException("Parameter 'hardwareAddress' missing.");
            }

            scope.ConvertToDynamicLease(strHardwareAddress);

            _dnsWebService.DhcpServer.SaveScope(scopeName);

            _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] DHCP scope's lease was unreserved successfully: " + scopeName);
        }
Пример #2
0
        public void FlushBlockedZone(HttpListenerRequest request)
        {
            _dnsWebService.DnsServer.BlockedZoneManager.Flush();

            _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] Blocked zone was flushed successfully.");
            _dnsWebService.DnsServer.BlockedZoneManager.SaveZoneFile();
        }
Пример #3
0
        public void DeleteDhcpScope(HttpListenerRequest request)
        {
            string scopeName = request.QueryString["name"];

            if (string.IsNullOrEmpty(scopeName))
            {
                throw new DnsWebServiceException("Parameter 'name' missing.");
            }

            _dnsWebService.DhcpServer.DeleteScope(scopeName);

            _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] DHCP scope was deleted successfully: " + scopeName);
        }
Пример #4
0
        public void DeleteLog(HttpListenerRequest request)
        {
            string log = request.QueryString["log"];

            if (string.IsNullOrEmpty(log))
            {
                throw new DnsWebServiceException("Parameter 'log' missing.");
            }

            _dnsWebService.Log.DeleteLog(log);

            _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] Log file was deleted: " + log);
        }
Пример #5
0
        public void UninstallApp(HttpListenerRequest request)
        {
            string name = request.QueryString["name"];

            if (string.IsNullOrEmpty(name))
            {
                throw new DnsWebServiceException("Parameter 'name' missing.");
            }

            name = name.Trim();

            _dnsWebService.DnsServer.DnsApplicationManager.UninstallApplication(name);
            _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] DNS application '" + name + "' was uninstalled successfully.");
        }
Пример #6
0
        public void DeleteCachedZone(HttpListenerRequest request)
        {
            string domain = request.QueryString["domain"];

            if (string.IsNullOrEmpty(domain))
            {
                throw new DnsWebServiceException("Parameter 'domain' missing.");
            }

            if (_dnsWebService.DnsServer.CacheZoneManager.DeleteZone(domain))
            {
                _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] Cached zone was deleted: " + domain);
            }
        }
Пример #7
0
        public void DisableDhcpScope(HttpListenerRequest request)
        {
            string scopeName = request.QueryString["name"];

            if (string.IsNullOrEmpty(scopeName))
            {
                throw new DnsWebServiceException("Parameter 'name' missing.");
            }

            if (!_dnsWebService.DhcpServer.DisableScope(scopeName))
            {
                throw new DnsWebServiceException("Failed to disable DHCP scope, please check logs for details: " + scopeName);
            }

            _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] DHCP scope was disabled successfully: " + scopeName);
        }
Пример #8
0
        public async Task SetAppConfigAsync(HttpListenerRequest request)
        {
            string name = request.QueryString["name"];

            if (string.IsNullOrEmpty(name))
            {
                throw new DnsWebServiceException("Parameter 'name' missing.");
            }

            name = name.Trim();

            if (!_dnsWebService.DnsServer.DnsApplicationManager.Applications.TryGetValue(name, out DnsApplication application))
            {
                throw new DnsWebServiceException("DNS application was not found: " + name);
            }

            string formRequest;

            using (StreamReader sR = new StreamReader(request.InputStream, request.ContentEncoding))
            {
                formRequest = await sR.ReadToEndAsync();
            }

            string[] formParts = formRequest.Split('&');

            foreach (string formPart in formParts)
            {
                if (formPart.StartsWith("config="))
                {
                    string config = formPart.Substring(7);

                    if (config.Length == 0)
                    {
                        config = null;
                    }

                    await application.SetConfigAsync(config);

                    _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] DNS application '" + name + "' app config was saved successfully.");
                    return;
                }
            }

            throw new DnsWebServiceException("Missing POST parameter: config");
        }
Пример #9
0
        public void ImportBlockedZones(HttpListenerRequest request)
        {
            if (!request.ContentType.StartsWith("application/x-www-form-urlencoded"))
            {
                throw new DnsWebServiceException("Invalid content type. Expected application/x-www-form-urlencoded.");
            }

            string formRequest;

            using (StreamReader sR = new StreamReader(request.InputStream, request.ContentEncoding))
            {
                formRequest = sR.ReadToEnd();
            }

            string[] formParts = formRequest.Split('&');

            foreach (string formPart in formParts)
            {
                if (formPart.StartsWith("blockedZones="))
                {
                    string[] blockedZones = formPart.Substring(13).Split(',');
                    bool     added        = false;

                    foreach (string blockedZone in blockedZones)
                    {
                        if (_dnsWebService.DnsServer.BlockedZoneManager.BlockZone(blockedZone))
                        {
                            added = true;
                        }
                    }

                    if (added)
                    {
                        _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] Total " + blockedZones.Length + " zones were imported into blocked zone successfully.");
                        _dnsWebService.DnsServer.BlockedZoneManager.SaveZoneFile();
                    }

                    return;
                }
            }

            throw new DnsWebServiceException("Parameter 'blockedZones' missing.");
        }
Пример #10
0
        public void BlockZone(HttpListenerRequest request)
        {
            string domain = request.QueryString["domain"];

            if (string.IsNullOrEmpty(domain))
            {
                throw new DnsWebServiceException("Parameter 'domain' missing.");
            }

            if (IPAddress.TryParse(domain, out IPAddress ipAddress))
            {
                domain = (new DnsQuestionRecord(ipAddress, DnsClass.IN)).Name;
            }

            if (_dnsWebService.DnsServer.BlockedZoneManager.BlockZone(domain))
            {
                _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] Domain was added to blocked zone: " + domain);
                _dnsWebService.DnsServer.BlockedZoneManager.SaveZoneFile();
            }
        }
Пример #11
0
        public void RemoveDhcpLease(HttpListenerRequest request)
        {
            string scopeName = request.QueryString["name"];

            if (string.IsNullOrEmpty(scopeName))
            {
                throw new DnsWebServiceException("Parameter 'name' missing.");
            }

            string strHardwareAddress = request.QueryString["hardwareAddress"];

            if (string.IsNullOrEmpty(strHardwareAddress))
            {
                throw new DnsWebServiceException("Parameter 'hardwareAddress' missing.");
            }

            _dnsWebService.DhcpServer.RemoveLease(scopeName, strHardwareAddress);
            _dnsWebService.DhcpServer.SaveScope(scopeName);

            _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] DHCP scope's lease was removed successfully: " + scopeName);
        }
Пример #12
0
        public void ConvertToDynamicLease(HttpListenerRequest request)
        {
            string scopeName = request.QueryString["name"];

            if (string.IsNullOrEmpty(scopeName))
            {
                throw new DnsWebServiceException("Parameter 'name' missing.");
            }

            Scope scope = _dnsWebService.DhcpServer.GetScope(scopeName);

            if (scope == null)
            {
                throw new DnsWebServiceException("DHCP scope does not exists: " + scopeName);
            }

            string strClientIdentifier = request.QueryString["clientIdentifier"];
            string strHardwareAddress  = request.QueryString["hardwareAddress"];

            if (!string.IsNullOrEmpty(strClientIdentifier))
            {
                scope.ConvertToDynamicLease(ClientIdentifierOption.Parse(strClientIdentifier));
            }
            else if (!string.IsNullOrEmpty(strHardwareAddress))
            {
                scope.ConvertToDynamicLease(strHardwareAddress);
            }
            else
            {
                throw new DnsWebServiceException("Parameter 'hardwareAddress' or 'clientIdentifier' missing. At least one of them must be specified.");
            }

            _dnsWebService.DhcpServer.SaveScope(scopeName);

            _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] DHCP scope's lease was unreserved successfully: " + scopeName);
        }
Пример #13
0
        public void DeleteAllStats(HttpListenerRequest request)
        {
            _dnsWebService.DnsServer.StatsManager.DeleteAllStats();

            _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] All stats files were deleted.");
        }
Пример #14
0
        public void DeleteAllLogs(HttpListenerRequest request)
        {
            _dnsWebService.Log.DeleteAllLogs();

            _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] All log files were deleted.");
        }
Пример #15
0
        public void FlushCache(HttpListenerRequest request)
        {
            _dnsWebService.DnsServer.CacheZoneManager.Flush();

            _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] Cache was flushed.");
        }
Пример #16
0
        public async Task SetDhcpScopeAsync(HttpListenerRequest request)
        {
            string scopeName = request.QueryString["name"];

            if (string.IsNullOrEmpty(scopeName))
            {
                throw new DnsWebServiceException("Parameter 'name' missing.");
            }

            string strStartingAddress = request.QueryString["startingAddress"];
            string strEndingAddress   = request.QueryString["endingAddress"];
            string strSubnetMask      = request.QueryString["subnetMask"];

            bool  scopeExists;
            Scope scope = _dnsWebService.DhcpServer.GetScope(scopeName);

            if (scope is null)
            {
                //scope does not exists; create new scope
                if (string.IsNullOrEmpty(strStartingAddress))
                {
                    throw new DnsWebServiceException("Parameter 'startingAddress' missing.");
                }

                if (string.IsNullOrEmpty(strEndingAddress))
                {
                    throw new DnsWebServiceException("Parameter 'endingAddress' missing.");
                }

                if (string.IsNullOrEmpty(strSubnetMask))
                {
                    throw new DnsWebServiceException("Parameter 'subnetMask' missing.");
                }

                scopeExists = false;
                scope       = new Scope(scopeName, true, IPAddress.Parse(strStartingAddress), IPAddress.Parse(strEndingAddress), IPAddress.Parse(strSubnetMask));
            }
            else
            {
                scopeExists = true;

                IPAddress startingAddress;
                if (string.IsNullOrEmpty(strStartingAddress))
                {
                    startingAddress = scope.StartingAddress;
                }
                else
                {
                    startingAddress = IPAddress.Parse(strStartingAddress);
                }

                IPAddress endingAddress;
                if (string.IsNullOrEmpty(strEndingAddress))
                {
                    endingAddress = scope.EndingAddress;
                }
                else
                {
                    endingAddress = IPAddress.Parse(strEndingAddress);
                }

                IPAddress subnetMask;
                if (string.IsNullOrEmpty(strSubnetMask))
                {
                    subnetMask = scope.SubnetMask;
                }
                else
                {
                    subnetMask = IPAddress.Parse(strSubnetMask);
                }

                //validate scope address
                foreach (KeyValuePair <string, Scope> entry in _dnsWebService.DhcpServer.Scopes)
                {
                    Scope existingScope = entry.Value;

                    if (existingScope.Equals(scope))
                    {
                        continue;
                    }

                    if (existingScope.IsAddressInRange(startingAddress) || existingScope.IsAddressInRange(endingAddress))
                    {
                        throw new DhcpServerException("Scope with overlapping range already exists: " + existingScope.StartingAddress.ToString() + "-" + existingScope.EndingAddress.ToString());
                    }
                }

                scope.ChangeNetwork(startingAddress, endingAddress, subnetMask);
            }

            string strLeaseTimeDays = request.QueryString["leaseTimeDays"];

            if (!string.IsNullOrEmpty(strLeaseTimeDays))
            {
                scope.LeaseTimeDays = ushort.Parse(strLeaseTimeDays);
            }

            string strLeaseTimeHours = request.QueryString["leaseTimeHours"];

            if (!string.IsNullOrEmpty(strLeaseTimeHours))
            {
                scope.LeaseTimeHours = byte.Parse(strLeaseTimeHours);
            }

            string strLeaseTimeMinutes = request.QueryString["leaseTimeMinutes"];

            if (!string.IsNullOrEmpty(strLeaseTimeMinutes))
            {
                scope.LeaseTimeMinutes = byte.Parse(strLeaseTimeMinutes);
            }

            string strOfferDelayTime = request.QueryString["offerDelayTime"];

            if (!string.IsNullOrEmpty(strOfferDelayTime))
            {
                scope.OfferDelayTime = ushort.Parse(strOfferDelayTime);
            }

            string strPingCheckEnabled = request.QueryString["pingCheckEnabled"];

            if (!string.IsNullOrEmpty(strPingCheckEnabled))
            {
                scope.PingCheckEnabled = bool.Parse(strPingCheckEnabled);
            }

            string strPingCheckTimeout = request.QueryString["pingCheckTimeout"];

            if (!string.IsNullOrEmpty(strPingCheckTimeout))
            {
                scope.PingCheckTimeout = ushort.Parse(strPingCheckTimeout);
            }

            string strPingCheckRetries = request.QueryString["pingCheckRetries"];

            if (!string.IsNullOrEmpty(strPingCheckRetries))
            {
                scope.PingCheckRetries = byte.Parse(strPingCheckRetries);
            }

            string strDomainName = request.QueryString["domainName"];

            if (strDomainName != null)
            {
                scope.DomainName = strDomainName.Length == 0 ? null : strDomainName;
            }

            string strDnsTtl = request.QueryString["dnsTtl"];

            if (!string.IsNullOrEmpty(strDnsTtl))
            {
                scope.DnsTtl = uint.Parse(strDnsTtl);
            }

            string strServerAddress = request.QueryString["serverAddress"];

            if (strServerAddress != null)
            {
                scope.ServerAddress = strServerAddress.Length == 0 ? null : IPAddress.Parse(strServerAddress);
            }

            string strServerHostName = request.QueryString["serverHostName"];

            if (strServerHostName != null)
            {
                scope.ServerHostName = strServerHostName.Length == 0 ? null : strServerHostName;
            }

            string strBootFileName = request.QueryString["bootFileName"];

            if (strBootFileName != null)
            {
                scope.BootFileName = strBootFileName.Length == 0 ? null : strBootFileName;
            }

            string strRouterAddress = request.QueryString["routerAddress"];

            if (strRouterAddress != null)
            {
                scope.RouterAddress = strRouterAddress.Length == 0 ? null : IPAddress.Parse(strRouterAddress);
            }

            string strUseThisDnsServer = request.QueryString["useThisDnsServer"];

            if (!string.IsNullOrEmpty(strUseThisDnsServer))
            {
                scope.UseThisDnsServer = bool.Parse(strUseThisDnsServer);
            }

            if (!scope.UseThisDnsServer)
            {
                string strDnsServers = request.QueryString["dnsServers"];
                if (strDnsServers != null)
                {
                    if (strDnsServers.Length == 0)
                    {
                        scope.DnsServers = null;
                    }
                    else
                    {
                        string[]    strDnsServerParts = strDnsServers.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        IPAddress[] dnsServers        = new IPAddress[strDnsServerParts.Length];

                        for (int i = 0; i < strDnsServerParts.Length; i++)
                        {
                            dnsServers[i] = IPAddress.Parse(strDnsServerParts[i]);
                        }

                        scope.DnsServers = dnsServers;
                    }
                }
            }

            string strWinsServers = request.QueryString["winsServers"];

            if (strWinsServers != null)
            {
                if (strWinsServers.Length == 0)
                {
                    scope.WinsServers = null;
                }
                else
                {
                    string[]    strWinsServerParts = strWinsServers.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    IPAddress[] winsServers        = new IPAddress[strWinsServerParts.Length];

                    for (int i = 0; i < strWinsServerParts.Length; i++)
                    {
                        winsServers[i] = IPAddress.Parse(strWinsServerParts[i]);
                    }

                    scope.WinsServers = winsServers;
                }
            }

            string strNtpServers = request.QueryString["ntpServers"];

            if (strNtpServers != null)
            {
                if (strNtpServers.Length == 0)
                {
                    scope.NtpServers = null;
                }
                else
                {
                    string[]    strNtpServerParts = strNtpServers.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    IPAddress[] ntpServers        = new IPAddress[strNtpServerParts.Length];

                    for (int i = 0; i < strNtpServerParts.Length; i++)
                    {
                        ntpServers[i] = IPAddress.Parse(strNtpServerParts[i]);
                    }

                    scope.NtpServers = ntpServers;
                }
            }

            string strStaticRoutes = request.QueryString["staticRoutes"];

            if (strStaticRoutes != null)
            {
                if (strStaticRoutes.Length == 0)
                {
                    scope.StaticRoutes = null;
                }
                else
                {
                    string[] strStaticRoutesParts = strStaticRoutes.Split('|');
                    List <ClasslessStaticRouteOption.Route> staticRoutes = new List <ClasslessStaticRouteOption.Route>();

                    for (int i = 0; i < strStaticRoutesParts.Length; i += 3)
                    {
                        staticRoutes.Add(new ClasslessStaticRouteOption.Route(IPAddress.Parse(strStaticRoutesParts[i + 0]), IPAddress.Parse(strStaticRoutesParts[i + 1]), IPAddress.Parse(strStaticRoutesParts[i + 2])));
                    }

                    scope.StaticRoutes = staticRoutes;
                }
            }

            string strVendorInfo = request.QueryString["vendorInfo"];

            if (strVendorInfo != null)
            {
                if (strVendorInfo.Length == 0)
                {
                    scope.VendorInfo = null;
                }
                else
                {
                    string[] strVendorInfoParts = strVendorInfo.Split('|');
                    Dictionary <string, VendorSpecificInformationOption> vendorInfo = new Dictionary <string, VendorSpecificInformationOption>();

                    for (int i = 0; i < strVendorInfoParts.Length; i += 2)
                    {
                        vendorInfo.Add(strVendorInfoParts[i + 0], new VendorSpecificInformationOption(strVendorInfoParts[i + 1]));
                    }

                    scope.VendorInfo = vendorInfo;
                }
            }

            string strExclusions = request.QueryString["exclusions"];

            if (strExclusions != null)
            {
                if (strExclusions.Length == 0)
                {
                    scope.Exclusions = null;
                }
                else
                {
                    string[]         strExclusionsParts = strExclusions.Split('|');
                    List <Exclusion> exclusions         = new List <Exclusion>();

                    for (int i = 0; i < strExclusionsParts.Length; i += 2)
                    {
                        exclusions.Add(new Exclusion(IPAddress.Parse(strExclusionsParts[i + 0]), IPAddress.Parse(strExclusionsParts[i + 1])));
                    }

                    scope.Exclusions = exclusions;
                }
            }

            string strReservedLeases = request.QueryString["reservedLeases"];

            if (strReservedLeases != null)
            {
                if (strReservedLeases.Length == 0)
                {
                    scope.ReservedLeases = null;
                }
                else
                {
                    string[]     strReservedLeaseParts = strReservedLeases.Split('|');
                    List <Lease> reservedLeases        = new List <Lease>();

                    for (int i = 0; i < strReservedLeaseParts.Length; i += 4)
                    {
                        reservedLeases.Add(new Lease(LeaseType.Reserved, strReservedLeaseParts[i + 0], DhcpMessageHardwareAddressType.Ethernet, strReservedLeaseParts[i + 1], IPAddress.Parse(strReservedLeaseParts[i + 2]), strReservedLeaseParts[i + 3]));
                    }

                    scope.ReservedLeases = reservedLeases;
                }
            }

            string strAllowOnlyReservedLeases = request.QueryString["allowOnlyReservedLeases"];

            if (!string.IsNullOrEmpty(strAllowOnlyReservedLeases))
            {
                scope.AllowOnlyReservedLeases = bool.Parse(strAllowOnlyReservedLeases);
            }

            if (scopeExists)
            {
                _dnsWebService.DhcpServer.SaveScope(scopeName);

                _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] DHCP scope was updated successfully: " + scopeName);
            }
            else
            {
                await _dnsWebService.DhcpServer.AddScopeAsync(scope);

                _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] DHCP scope was added successfully: " + scopeName);
            }

            string newName = request.QueryString["newName"];

            if (!string.IsNullOrEmpty(newName) && !newName.Equals(scopeName))
            {
                _dnsWebService.DhcpServer.RenameScope(scopeName, newName);

                _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] DHCP scope was renamed successfully: '" + scopeName + "' to '" + newName + "'");
            }
        }
Пример #17
0
        public async Task UpdateAppAsync(HttpListenerRequest request)
        {
            string name = request.QueryString["name"];

            if (string.IsNullOrEmpty(name))
            {
                throw new DnsWebServiceException("Parameter 'name' missing.");
            }

            name = name.Trim();

            #region skip to content

            int crlfCount = 0;
            int byteRead;

            while (crlfCount != 4)
            {
                byteRead = await request.InputStream.ReadByteValueAsync();

                switch (byteRead)
                {
                case 13:     //CR
                case 10:     //LF
                    crlfCount++;
                    break;

                default:
                    crlfCount = 0;
                    break;
                }
            }

            #endregion

            string tmpFile = Path.GetTempFileName();
            try
            {
                using (FileStream fS = new FileStream(tmpFile, FileMode.Create, FileAccess.ReadWrite))
                {
                    //write to temp file
                    await request.InputStream.CopyToAsync(fS);

                    //update app
                    fS.Position = 0;
                    await _dnsWebService.DnsServer.DnsApplicationManager.UpdateApplicationAsync(name, fS);

                    _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] DNS application '" + name + "' was updated successfully.");
                }
            }
            finally
            {
                try
                {
                    File.Delete(tmpFile);
                }
                catch (Exception ex)
                {
                    _dnsWebService.Log.Write(ex);
                }
            }
        }
Пример #18
0
        public async Task DownloadAndUpdateAppAsync(HttpListenerRequest request)
        {
            string name = request.QueryString["name"];

            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.");
            }

            if (!url.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
            {
                throw new DnsWebServiceException("Parameter 'url' value must start with 'https://'.");
            }

            string tmpFile = Path.GetTempFileName();

            try
            {
                using (FileStream fS = new FileStream(tmpFile, FileMode.Create, FileAccess.ReadWrite))
                {
                    //download to temp file
                    SocketsHttpHandler handler = new SocketsHttpHandler();
                    handler.Proxy = _dnsWebService.DnsServer.Proxy;
                    handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

                    using (HttpClient http = new HttpClient(handler))
                    {
                        using (Stream httpStream = await http.GetStreamAsync(url))
                        {
                            await httpStream.CopyToAsync(fS);
                        }
                    }

                    //update app
                    fS.Position = 0;
                    await _dnsWebService.DnsServer.DnsApplicationManager.UpdateApplicationAsync(name, fS);

                    _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] DNS application '" + name + "' was updated successfully from: " + url);
                }
            }
            finally
            {
                try
                {
                    File.Delete(tmpFile);
                }
                catch (Exception ex)
                {
                    _dnsWebService.Log.Write(ex);
                }
            }
        }