123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708 |
- /*
- Technitium DNS Server
- Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- using DnsServerCore.ApplicationCommon;
- using DnsServerCore.Auth;
- using DnsServerCore.Dns.Applications;
- using Microsoft.AspNetCore.Http;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Net;
- using System.Net.Http;
- using System.Text.Json;
- using System.Threading;
- using System.Threading.Tasks;
- using TechnitiumLibrary;
- using TechnitiumLibrary.Net.Http.Client;
- namespace DnsServerCore
- {
- sealed class WebServiceAppsApi : IDisposable
- {
- #region variables
- readonly DnsWebService _dnsWebService;
- readonly Uri _appStoreUri;
- string _storeAppsJsonData;
- DateTime _storeAppsJsonDataUpdatedOn;
- const int STORE_APPS_JSON_DATA_CACHE_TIME_SECONDS = 900;
- Timer _appUpdateTimer;
- const int APP_UPDATE_TIMER_INITIAL_INTERVAL = 10000;
- const int APP_UPDATE_TIMER_PERIODIC_INTERVAL = 86400000;
- #endregion
- #region constructor
- public WebServiceAppsApi(DnsWebService dnsWebService, Uri appStoreUri)
- {
- _dnsWebService = dnsWebService;
- _appStoreUri = appStoreUri;
- }
- #endregion
- #region IDisposable
- bool _disposed;
- public void Dispose()
- {
- if (_disposed)
- return;
- if (_appUpdateTimer is not null)
- _appUpdateTimer.Dispose();
- _disposed = true;
- }
- #endregion
- #region private
- private void StartAutomaticUpdate()
- {
- if (_appUpdateTimer is null)
- {
- _appUpdateTimer = new Timer(async delegate (object state)
- {
- try
- {
- if (_dnsWebService.DnsServer.DnsApplicationManager.Applications.Count < 1)
- return;
- _dnsWebService._log.Write("DNS Server has started automatic update check for DNS Apps.");
- string storeAppsJsonData = await GetStoreAppsJsonData(true);
- using JsonDocument jsonDocument = JsonDocument.Parse(storeAppsJsonData);
- JsonElement jsonStoreAppsArray = jsonDocument.RootElement;
- foreach (DnsApplication application in _dnsWebService.DnsServer.DnsApplicationManager.Applications.Values)
- {
- foreach (JsonElement jsonStoreApp in jsonStoreAppsArray.EnumerateArray())
- {
- string name = jsonStoreApp.GetProperty("name").GetString();
- if (name.Equals(application.Name))
- {
- string url = null;
- Version storeAppVersion = null;
- Version lastServerVersion = null;
- foreach (JsonElement jsonVersion in jsonStoreApp.GetProperty("versions").EnumerateArray())
- {
- string strServerVersion = jsonVersion.GetProperty("serverVersion").GetString();
- Version requiredServerVersion = new Version(strServerVersion);
- if (_dnsWebService._currentVersion < requiredServerVersion)
- continue;
- if ((lastServerVersion is not null) && (lastServerVersion > requiredServerVersion))
- continue;
- string version = jsonVersion.GetProperty("version").GetString();
- url = jsonVersion.GetProperty("url").GetString();
- storeAppVersion = new Version(version);
- lastServerVersion = requiredServerVersion;
- }
- if ((storeAppVersion is not null) && (storeAppVersion > application.Version))
- {
- try
- {
- await DownloadAndUpdateAppAsync(application.Name, url, true);
- _dnsWebService._log.Write("DNS application '" + application.Name + "' was automatically updated successfully from: " + url);
- }
- catch (Exception ex)
- {
- _dnsWebService._log.Write("Failed to automatically download and update DNS application '" + application.Name + "': " + ex.ToString());
- }
- }
- break;
- }
- }
- }
- }
- catch (Exception ex)
- {
- _dnsWebService._log.Write(ex);
- }
- });
- _appUpdateTimer.Change(APP_UPDATE_TIMER_INITIAL_INTERVAL, APP_UPDATE_TIMER_PERIODIC_INTERVAL);
- }
- }
- private void StopAutomaticUpdate()
- {
- if (_appUpdateTimer is not null)
- {
- _appUpdateTimer.Dispose();
- _appUpdateTimer = null;
- }
- }
- private async Task<string> GetStoreAppsJsonData(bool doRetry)
- {
- if ((_storeAppsJsonData is null) || (DateTime.UtcNow > _storeAppsJsonDataUpdatedOn.AddSeconds(STORE_APPS_JSON_DATA_CACHE_TIME_SECONDS)))
- {
- SocketsHttpHandler handler = new SocketsHttpHandler();
- handler.Proxy = _dnsWebService.DnsServer.Proxy;
- handler.UseProxy = _dnsWebService.DnsServer.Proxy is not null;
- handler.AutomaticDecompression = DecompressionMethods.All;
- HttpClientNetworkHandler networkHandler = new HttpClientNetworkHandler(handler, _dnsWebService.DnsServer.PreferIPv6 ? HttpClientNetworkType.PreferIPv6 : HttpClientNetworkType.Default, _dnsWebService.DnsServer);
- if (!doRetry)
- networkHandler.Retries = 1;
- using (HttpClient http = new HttpClient(networkHandler))
- {
- _storeAppsJsonData = await http.GetStringAsync(_appStoreUri);
- _storeAppsJsonDataUpdatedOn = DateTime.UtcNow;
- }
- }
- return _storeAppsJsonData;
- }
- private async Task<DnsApplication> DownloadAndUpdateAppAsync(string applicationName, string url, bool doRetry)
- {
- 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.UseProxy = _dnsWebService.DnsServer.Proxy is not null;
- handler.AutomaticDecompression = DecompressionMethods.All;
- HttpClientNetworkHandler networkHandler = new HttpClientNetworkHandler(handler, _dnsWebService.DnsServer.PreferIPv6 ? HttpClientNetworkType.PreferIPv6 : HttpClientNetworkType.Default, _dnsWebService.DnsServer);
- if (!doRetry)
- networkHandler.Retries = 1;
- using (HttpClient http = new HttpClient(networkHandler))
- {
- using (Stream httpStream = await http.GetStreamAsync(url))
- {
- await httpStream.CopyToAsync(fS);
- }
- }
- //update app
- fS.Position = 0;
- return await _dnsWebService.DnsServer.DnsApplicationManager.UpdateApplicationAsync(applicationName, fS);
- }
- }
- finally
- {
- try
- {
- File.Delete(tmpFile);
- }
- catch (Exception ex)
- {
- _dnsWebService._log.Write(ex);
- }
- }
- }
- private void WriteAppAsJson(Utf8JsonWriter jsonWriter, DnsApplication application, JsonElement jsonStoreAppsArray = default)
- {
- jsonWriter.WriteStartObject();
- jsonWriter.WriteString("name", application.Name);
- jsonWriter.WriteString("description", application.Description);
- jsonWriter.WriteString("version", DnsWebService.GetCleanVersion(application.Version));
- if (jsonStoreAppsArray.ValueKind != JsonValueKind.Undefined)
- {
- foreach (JsonElement jsonStoreApp in jsonStoreAppsArray.EnumerateArray())
- {
- string name = jsonStoreApp.GetProperty("name").GetString();
- if (name.Equals(application.Name))
- {
- string version = null;
- string url = null;
- Version storeAppVersion = null;
- Version lastServerVersion = null;
- foreach (JsonElement jsonVersion in jsonStoreApp.GetProperty("versions").EnumerateArray())
- {
- string strServerVersion = jsonVersion.GetProperty("serverVersion").GetString();
- Version requiredServerVersion = new Version(strServerVersion);
- if (_dnsWebService._currentVersion < requiredServerVersion)
- continue;
- if ((lastServerVersion is not null) && (lastServerVersion > requiredServerVersion))
- continue;
- version = jsonVersion.GetProperty("version").GetString();
- url = jsonVersion.GetProperty("url").GetString();
- storeAppVersion = new Version(version);
- lastServerVersion = requiredServerVersion;
- }
- if (storeAppVersion is null)
- break; //no compatible update available
- jsonWriter.WriteString("updateVersion", version);
- jsonWriter.WriteString("updateUrl", url);
- jsonWriter.WriteBoolean("updateAvailable", storeAppVersion > application.Version);
- break;
- }
- }
- }
- jsonWriter.WritePropertyName("dnsApps");
- {
- jsonWriter.WriteStartArray();
- foreach (KeyValuePair<string, IDnsApplication> dnsApp in application.DnsApplications)
- {
- jsonWriter.WriteStartObject();
- jsonWriter.WriteString("classPath", dnsApp.Key);
- jsonWriter.WriteString("description", dnsApp.Value.Description);
- if (dnsApp.Value is IDnsAppRecordRequestHandler appRecordHandler)
- {
- jsonWriter.WriteBoolean("isAppRecordRequestHandler", true);
- jsonWriter.WriteString("recordDataTemplate", appRecordHandler.ApplicationRecordDataTemplate);
- }
- else
- {
- jsonWriter.WriteBoolean("isAppRecordRequestHandler", false);
- }
- jsonWriter.WriteBoolean("isRequestController", dnsApp.Value is IDnsRequestController);
- jsonWriter.WriteBoolean("isAuthoritativeRequestHandler", dnsApp.Value is IDnsAuthoritativeRequestHandler);
- jsonWriter.WriteBoolean("isRequestBlockingHandler", dnsApp.Value is IDnsRequestBlockingHandler);
- jsonWriter.WriteBoolean("isQueryLogger", dnsApp.Value is IDnsQueryLogger);
- jsonWriter.WriteBoolean("isPostProcessor", dnsApp.Value is IDnsPostProcessor);
- jsonWriter.WriteEndObject();
- }
- jsonWriter.WriteEndArray();
- }
- jsonWriter.WriteEndObject();
- }
- #endregion
- #region public
- public async Task ListInstalledAppsAsync(HttpContext context)
- {
- UserSession session = context.GetCurrentSession();
- if (
- !_dnsWebService._authManager.IsPermitted(PermissionSection.Apps, session.User, PermissionFlag.View) &&
- !_dnsWebService._authManager.IsPermitted(PermissionSection.Zones, session.User, PermissionFlag.View) &&
- !_dnsWebService._authManager.IsPermitted(PermissionSection.Logs, session.User, PermissionFlag.View)
- )
- {
- throw new DnsWebServiceException("Access was denied.");
- }
- List<string> apps = new List<string>(_dnsWebService.DnsServer.DnsApplicationManager.Applications.Keys);
- apps.Sort();
- JsonDocument jsonDocument = null;
- try
- {
- JsonElement jsonStoreAppsArray = default;
- if (apps.Count > 0)
- {
- try
- {
- string storeAppsJsonData = await GetStoreAppsJsonData(false).WithTimeout(5000);
- jsonDocument = JsonDocument.Parse(storeAppsJsonData);
- jsonStoreAppsArray = jsonDocument.RootElement;
- }
- catch (Exception ex)
- {
- _dnsWebService._log.Write(ex);
- }
- }
- Utf8JsonWriter jsonWriter = context.GetCurrentJsonWriter();
- jsonWriter.WritePropertyName("apps");
- jsonWriter.WriteStartArray();
- foreach (string app in apps)
- {
- if (_dnsWebService.DnsServer.DnsApplicationManager.Applications.TryGetValue(app, out DnsApplication application))
- WriteAppAsJson(jsonWriter, application, jsonStoreAppsArray);
- }
- jsonWriter.WriteEndArray();
- }
- finally
- {
- if (jsonDocument is not null)
- jsonDocument.Dispose();
- }
- }
- public async Task ListStoreApps(HttpContext context)
- {
- UserSession session = context.GetCurrentSession();
- if (!_dnsWebService._authManager.IsPermitted(PermissionSection.Apps, session.User, PermissionFlag.View))
- throw new DnsWebServiceException("Access was denied.");
- string storeAppsJsonData = await GetStoreAppsJsonData(false).WithTimeout(30000);
- using JsonDocument jsonDocument = JsonDocument.Parse(storeAppsJsonData);
- JsonElement jsonStoreAppsArray = jsonDocument.RootElement;
- Utf8JsonWriter jsonWriter = context.GetCurrentJsonWriter();
- jsonWriter.WritePropertyName("storeApps");
- jsonWriter.WriteStartArray();
- foreach (JsonElement jsonStoreApp in jsonStoreAppsArray.EnumerateArray())
- {
- string name = jsonStoreApp.GetProperty("name").GetString();
- string description = jsonStoreApp.GetProperty("description").GetString();
- string version = null;
- string url = null;
- string size = null;
- Version storeAppVersion = null;
- Version lastServerVersion = null;
- foreach (JsonElement jsonVersion in jsonStoreApp.GetProperty("versions").EnumerateArray())
- {
- string strServerVersion = jsonVersion.GetProperty("serverVersion").GetString();
- Version requiredServerVersion = new Version(strServerVersion);
- if (_dnsWebService._currentVersion < requiredServerVersion)
- continue;
- if ((lastServerVersion is not null) && (lastServerVersion > requiredServerVersion))
- continue;
- version = jsonVersion.GetProperty("version").GetString();
- url = jsonVersion.GetProperty("url").GetString();
- size = jsonVersion.GetProperty("size").GetString();
- storeAppVersion = new Version(version);
- lastServerVersion = requiredServerVersion;
- }
- if (storeAppVersion is null)
- continue; //app is not compatible
- jsonWriter.WriteStartObject();
- jsonWriter.WriteString("name", name);
- jsonWriter.WriteString("description", description);
- jsonWriter.WriteString("version", version);
- jsonWriter.WriteString("url", url);
- jsonWriter.WriteString("size", size);
- bool installed = _dnsWebService.DnsServer.DnsApplicationManager.Applications.TryGetValue(name, out DnsApplication installedApp);
- jsonWriter.WriteBoolean("installed", installed);
- if (installed)
- {
- jsonWriter.WriteString("installedVersion", DnsWebService.GetCleanVersion(installedApp.Version));
- jsonWriter.WriteBoolean("updateAvailable", storeAppVersion > installedApp.Version);
- }
- jsonWriter.WriteEndObject();
- }
- jsonWriter.WriteEndArray();
- }
- public async Task DownloadAndInstallAppAsync(HttpContext context)
- {
- UserSession session = context.GetCurrentSession();
- if (!_dnsWebService._authManager.IsPermitted(PermissionSection.Apps, session.User, PermissionFlag.Delete))
- throw new DnsWebServiceException("Access was denied.");
- HttpRequest request = context.Request;
- string name = request.GetQueryOrForm("name").Trim();
- string url = request.GetQueryOrForm("url");
- 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.UseProxy = _dnsWebService.DnsServer.Proxy is not null;
- handler.AutomaticDecompression = DecompressionMethods.All;
- using (HttpClient http = new HttpClient(new HttpClientNetworkHandler(handler, _dnsWebService.DnsServer.PreferIPv6 ? HttpClientNetworkType.PreferIPv6 : HttpClientNetworkType.Default, _dnsWebService.DnsServer)))
- {
- using (Stream httpStream = await http.GetStreamAsync(url))
- {
- await httpStream.CopyToAsync(fS);
- }
- }
- //install app
- fS.Position = 0;
- DnsApplication application = await _dnsWebService.DnsServer.DnsApplicationManager.InstallApplicationAsync(name, fS);
- _dnsWebService._log.Write(context.GetRemoteEndPoint(), "[" + session.User.Username + "] DNS application '" + name + "' was installed successfully from: " + url);
- Utf8JsonWriter jsonWriter = context.GetCurrentJsonWriter();
- jsonWriter.WritePropertyName("installedApp");
- WriteAppAsJson(jsonWriter, application);
- }
- }
- finally
- {
- try
- {
- File.Delete(tmpFile);
- }
- catch (Exception ex)
- {
- _dnsWebService._log.Write(ex);
- }
- }
- }
- public async Task DownloadAndUpdateAppAsync(HttpContext context)
- {
- UserSession session = context.GetCurrentSession();
- if (!_dnsWebService._authManager.IsPermitted(PermissionSection.Apps, session.User, PermissionFlag.Delete))
- throw new DnsWebServiceException("Access was denied.");
- HttpRequest request = context.Request;
- string name = request.GetQueryOrForm("name").Trim();
- string url = request.GetQueryOrForm("url");
- if (!url.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
- throw new DnsWebServiceException("Parameter 'url' value must start with 'https://'.");
- DnsApplication application = await DownloadAndUpdateAppAsync(name, url, false);
- _dnsWebService._log.Write(context.GetRemoteEndPoint(), "[" + session.User.Username + "] DNS application '" + name + "' was updated successfully from: " + url);
- Utf8JsonWriter jsonWriter = context.GetCurrentJsonWriter();
- jsonWriter.WritePropertyName("updatedApp");
- WriteAppAsJson(jsonWriter, application);
- }
- public async Task InstallAppAsync(HttpContext context)
- {
- UserSession session = context.GetCurrentSession();
- if (!_dnsWebService._authManager.IsPermitted(PermissionSection.Apps, session.User, PermissionFlag.Delete))
- throw new DnsWebServiceException("Access was denied.");
- HttpRequest request = context.Request;
- string name = request.GetQueryOrForm("name").Trim();
- if (!request.HasFormContentType || (request.Form.Files.Count == 0))
- throw new DnsWebServiceException("DNS application zip file is missing.");
- string tmpFile = Path.GetTempFileName();
- try
- {
- using (FileStream fS = new FileStream(tmpFile, FileMode.Create, FileAccess.ReadWrite))
- {
- //write to temp file
- await request.Form.Files[0].CopyToAsync(fS);
- //install app
- fS.Position = 0;
- DnsApplication application = await _dnsWebService.DnsServer.DnsApplicationManager.InstallApplicationAsync(name, fS);
- _dnsWebService._log.Write(context.GetRemoteEndPoint(), "[" + session.User.Username + "] DNS application '" + name + "' was installed successfully.");
- Utf8JsonWriter jsonWriter = context.GetCurrentJsonWriter();
- jsonWriter.WritePropertyName("installedApp");
- WriteAppAsJson(jsonWriter, application);
- }
- }
- finally
- {
- try
- {
- File.Delete(tmpFile);
- }
- catch (Exception ex)
- {
- _dnsWebService._log.Write(ex);
- }
- }
- }
- public async Task UpdateAppAsync(HttpContext context)
- {
- UserSession session = context.GetCurrentSession();
- if (!_dnsWebService._authManager.IsPermitted(PermissionSection.Apps, session.User, PermissionFlag.Delete))
- throw new DnsWebServiceException("Access was denied.");
- HttpRequest request = context.Request;
- string name = request.GetQueryOrForm("name").Trim();
- if (!request.HasFormContentType || (request.Form.Files.Count == 0))
- throw new DnsWebServiceException("DNS application zip file is missing.");
- string tmpFile = Path.GetTempFileName();
- try
- {
- using (FileStream fS = new FileStream(tmpFile, FileMode.Create, FileAccess.ReadWrite))
- {
- //write to temp file
- await request.Form.Files[0].CopyToAsync(fS);
- //update app
- fS.Position = 0;
- DnsApplication application = await _dnsWebService.DnsServer.DnsApplicationManager.UpdateApplicationAsync(name, fS);
- _dnsWebService._log.Write(context.GetRemoteEndPoint(), "[" + session.User.Username + "] DNS application '" + name + "' was updated successfully.");
- Utf8JsonWriter jsonWriter = context.GetCurrentJsonWriter();
- jsonWriter.WritePropertyName("updatedApp");
- WriteAppAsJson(jsonWriter, application);
- }
- }
- finally
- {
- try
- {
- File.Delete(tmpFile);
- }
- catch (Exception ex)
- {
- _dnsWebService._log.Write(ex);
- }
- }
- }
- public void UninstallApp(HttpContext context)
- {
- UserSession session = context.GetCurrentSession();
- if (!_dnsWebService._authManager.IsPermitted(PermissionSection.Apps, session.User, PermissionFlag.Delete))
- throw new DnsWebServiceException("Access was denied.");
- HttpRequest request = context.Request;
- string name = request.GetQueryOrForm("name").Trim();
- _dnsWebService.DnsServer.DnsApplicationManager.UninstallApplication(name);
- _dnsWebService._log.Write(context.GetRemoteEndPoint(), "[" + session.User.Username + "] DNS application '" + name + "' was uninstalled successfully.");
- }
- public async Task GetAppConfigAsync(HttpContext context)
- {
- UserSession session = context.GetCurrentSession();
- if (!_dnsWebService._authManager.IsPermitted(PermissionSection.Apps, session.User, PermissionFlag.View))
- throw new DnsWebServiceException("Access was denied.");
- HttpRequest request = context.Request;
- string name = request.GetQueryOrForm("name").Trim();
- if (!_dnsWebService.DnsServer.DnsApplicationManager.Applications.TryGetValue(name, out DnsApplication application))
- throw new DnsWebServiceException("DNS application was not found: " + name);
- string config = await application.GetConfigAsync();
- Utf8JsonWriter jsonWriter = context.GetCurrentJsonWriter();
- jsonWriter.WriteString("config", config);
- }
- public async Task SetAppConfigAsync(HttpContext context)
- {
- UserSession session = context.GetCurrentSession();
- if (!_dnsWebService._authManager.IsPermitted(PermissionSection.Apps, session.User, PermissionFlag.Modify))
- throw new DnsWebServiceException("Access was denied.");
- HttpRequest request = context.Request;
- string name = request.GetQueryOrForm("name").Trim();
- if (!_dnsWebService.DnsServer.DnsApplicationManager.Applications.TryGetValue(name, out DnsApplication application))
- throw new DnsWebServiceException("DNS application was not found: " + name);
- string config = request.QueryOrForm("config");
- if (config is null)
- throw new DnsWebServiceException("Parameter 'config' missing.");
- if (config.Length == 0)
- config = null;
- await application.SetConfigAsync(config);
- _dnsWebService._log.Write(context.GetRemoteEndPoint(), "[" + session.User.Username + "] DNS application '" + name + "' app config was saved successfully.");
- }
- #endregion
- #region properties
- public bool EnableAutomaticUpdate
- {
- get { return _appUpdateTimer is not null; }
- set
- {
- if (value)
- StartAutomaticUpdate();
- else
- StopAutomaticUpdate();
- }
- }
- #endregion
- }
- }
|