From ba343ce8112d90f8a2d99549bde52d07bff3ace2 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 19 Dec 2020 13:33:33 +0530 Subject: [PATCH] webapp: implemented UI options for serve stale, logging and block list settings. --- DnsServerCore/www/index.html | 133 +++++++++++++++++++++++++++-------- DnsServerCore/www/js/main.js | 116 +++++++++++++++++++++++++++--- 2 files changed, 210 insertions(+), 39 deletions(-) diff --git a/DnsServerCore/www/index.html b/DnsServerCore/www/index.html index 90239f07..47c60988 100644 --- a/DnsServerCore/www/index.html +++ b/DnsServerCore/www/index.html @@ -720,16 +720,49 @@
+
+ +
+
Enable this option to log error and audit logs into the log file.
+
Enable this option to log every query received by this DNS Server and the corresponding response answers into the log file.
+ +
+ +
+
Enable this option to use local time instead of UTC for logging.
-
Enabling query logging will significantly increase the log file size. Error and audit logs are enabled by default.
+
+ +
+ +
+ +
The folder path on the server where the log files should be saved. The path can be relative to the DNS server config folder.
+
+ +
+ +
+ + days (default 365, must be greater than 1) +
+ +
Max number of days to keep the log files. Log files older than the specified number of days will be deleted automatically.
+
+ +
Warning: Enabling query logging will significantly increase the log file size.
@@ -762,6 +795,29 @@
Disable recursion if you wish this server to act only as authoritative name server for the configured zones.
+
+
+ +
+
+ +
+
Enable the serve stale feature to improve resiliency by using expired or stale records in cache when the DNS server is unable to reach the upstream or authoritative name servers.
+
+
+ +
+ +
+ + (recommended 259200 seconds i.e. 3 days) +
+
The TTL value in seconds which should be used for cached records that are expired. When the serve stale TTL too expires for a stale record, it gets removed from the cache. Recommended value is between 1-3 days and maximum supported value is 7 days.
+
+
+
@@ -833,9 +889,6 @@ - - - @@ -846,7 +899,25 @@
-
DNS Server will use the data returned by the block list URLs to update the blocked zone automatically every 24 hours. The expected file format is standard hosts file format or plain text file containing list of domains to block.
+
+ +
+ + hours (default 24, valid range 1-168) +
+
The interval in hours to automatically download and update the block lists.
+
+ +
+ +
+ + +
+
Click the 'Update Now' button to reset the next update schedule and force download and update of the block lists.
+
+ +
DNS Server will use the data returned by the block list URLs to update the block list zone automatically. The expected file format is standard hosts file format or plain text file containing list of domains to block.
Help: Blocking Internet Ads Using DNS Sinkhole
@@ -1180,32 +1251,6 @@ -
-
- -
- -
-
The bootstrap TFTP server IP address to be used by the clients. If not specified, the DHCP server's IP address is used.
-
- -
- -
- -
-
The optional bootstrap TFTP server host name to be used by the clients to identify the TFTP server.
-
- -
- -
- -
-
The boot file name stored on the bootstrap TFTP server to be used by the clients.
-
-
-
@@ -1268,6 +1313,32 @@
+
+
+ +
+ +
+
The bootstrap TFTP server IP address to be used by the clients. If not specified, the DHCP server's IP address is used.
+
+ +
+ +
+ +
+
The optional bootstrap TFTP server host name to be used by the clients to identify the TFTP server.
+
+ +
+ +
+ +
+
The boot file name stored on the bootstrap TFTP server to be used by the clients.
+
+
+
diff --git a/DnsServerCore/www/js/main.js b/DnsServerCore/www/js/main.js index e61ee236..bb8da8c2 100644 --- a/DnsServerCore/www/js/main.js +++ b/DnsServerCore/www/js/main.js @@ -141,6 +141,11 @@ $(function () { $("#chkAllowRecursionOnlyForPrivateNetworks").prop('disabled', !allowRecursion); }); + $("#chkServeStale").click(function () { + var serveStale = $("#chkServeStale").prop("checked"); + $("#txtServeStaleTtl").prop("disabled", !serveStale); + }); + $("#optQuickBlockList").change(function () { var selectedOption = $("#optQuickBlockList").val(); @@ -157,7 +162,6 @@ $(function () { var defaultList = ""; defaultList += "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" + "\n"; - defaultList += "https://mirror1.malwaredomains.com/files/justdomains" + "\n"; defaultList += "https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt" + "\n"; defaultList += "https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt" + "\n"; @@ -602,12 +606,22 @@ function loadDnsSettings() { $("#txtTlsCertificatePassword").val(responseJSON.response.tlsCertificatePassword); $("#chkPreferIPv6").prop("checked", responseJSON.response.preferIPv6); + + $("#chkEnableLogging").prop("checked", responseJSON.response.enableLogging); $("#chkLogQueries").prop("checked", responseJSON.response.logQueries); + $("#chkUseLocalTime").prop("checked", responseJSON.response.useLocalTime); + $("#txtLogFolderPath").val(responseJSON.response.logFolder); + $("#txtMaxLogFileDays").val(responseJSON.response.maxLogFileDays); + $("#chkAllowRecursion").prop("checked", responseJSON.response.allowRecursion); $("#chkAllowRecursionOnlyForPrivateNetworks").prop('disabled', !responseJSON.response.allowRecursion); $("#chkAllowRecursionOnlyForPrivateNetworks").prop("checked", responseJSON.response.allowRecursionOnlyForPrivateNetworks); $("#chkRandomizeName").prop("checked", responseJSON.response.randomizeName); + $("#chkServeStale").prop("checked", responseJSON.response.serveStale); + $("#txtServeStaleTtl").prop("disabled", !responseJSON.response.serveStale); + $("#txtServeStaleTtl").val(responseJSON.response.serveStaleTtl); + $("#txtCachePrefetchEligibility").val(responseJSON.response.cachePrefetchEligibility); $("#txtCachePrefetchTrigger").val(responseJSON.response.cachePrefetchTrigger); $("#txtCachePrefetchSampleIntervalInMinutes").val(responseJSON.response.cachePrefetchSampleIntervalInMinutes); @@ -725,6 +739,9 @@ function loadDnsSettings() { optCustomLocalBlockList.text("Custom Local Block List (http://localhost:" + responseJSON.response.webServicePort + "/blocklist.txt)"); } + $("#txtBlockListUpdateIntervalHours").val(responseJSON.response.blockListUpdateIntervalHours); + $("#lblBlockListNextUpdatedOn").text(responseJSON.response.blockListNextUpdatedOn); + divDnsSettingsLoader.hide(); divDnsSettings.show(); }, @@ -769,11 +786,20 @@ function saveDnsSettings() { var tlsCertificatePassword = $("#txtTlsCertificatePassword").val(); var preferIPv6 = $("#chkPreferIPv6").prop('checked'); + + var enableLogging = $("#chkEnableLogging").prop('checked'); var logQueries = $("#chkLogQueries").prop('checked'); + var useLocalTime = $("#chkUseLocalTime").prop('checked'); + var logFolder = $("#txtLogFolderPath").val(); + var maxLogFileDays = $("#txtMaxLogFileDays").val(); + var allowRecursion = $("#chkAllowRecursion").prop('checked'); var allowRecursionOnlyForPrivateNetworks = $("#chkAllowRecursionOnlyForPrivateNetworks").prop('checked'); var randomizeName = $("#chkRandomizeName").prop('checked'); + var serveStale = $("#chkServeStale").prop("checked"); + var serveStaleTtl = $("#txtServeStaleTtl").val(); + var cachePrefetchEligibility = $("#txtCachePrefetchEligibility").val(); if ((cachePrefetchEligibility === null) || (cachePrefetchEligibility === "")) { showAlert("warning", "Missing!", "Please enter cache prefetch eligibility value."); @@ -850,14 +876,17 @@ function saveDnsSettings() { else $("#txtBlockListUrls").val(blockListUrls.replace(/,/g, "\n") + "\n"); + var blockListUpdateIntervalHours = $("#txtBlockListUpdateIntervalHours").val(); + var btn = $("#btnSaveDnsSettings").button('loading'); HTTPRequest({ url: "/api/setDnsSettings?token=" + token + "&serverDomain=" + serverDomain + "&webServicePort=" + webServicePort + "&dnsServerLocalEndPoints=" + encodeURIComponent(dnsServerLocalEndPoints) + "&enableDnsOverHttp=" + enableDnsOverHttp + "&enableDnsOverTls=" + enableDnsOverTls + "&enableDnsOverHttps=" + enableDnsOverHttps + "&tlsCertificatePath=" + encodeURIComponent(tlsCertificatePath) + "&tlsCertificatePassword=" + encodeURIComponent(tlsCertificatePassword) - + "&preferIPv6=" + preferIPv6 + "&logQueries=" + logQueries + "&allowRecursion=" + allowRecursion + "&allowRecursionOnlyForPrivateNetworks=" + allowRecursionOnlyForPrivateNetworks + "&randomizeName=" + randomizeName - + "&cachePrefetchEligibility=" + cachePrefetchEligibility + "&cachePrefetchTrigger=" + cachePrefetchTrigger + "&cachePrefetchSampleIntervalInMinutes=" + cachePrefetchSampleIntervalInMinutes + "&cachePrefetchSampleEligibilityHitsPerHour=" + cachePrefetchSampleEligibilityHitsPerHour - + proxy + "&forwarders=" + encodeURIComponent(forwarders) + "&forwarderProtocol=" + forwarderProtocol + "&blockListUrls=" + encodeURIComponent(blockListUrls), + + "&preferIPv6=" + preferIPv6 + "&enableLogging=" + enableLogging + "&logQueries=" + logQueries + "&useLocalTime=" + useLocalTime + "&logFolder=" + encodeURIComponent(logFolder) + "&maxLogFileDays=" + maxLogFileDays + + "&allowRecursion=" + allowRecursion + "&allowRecursionOnlyForPrivateNetworks=" + allowRecursionOnlyForPrivateNetworks + "&randomizeName=" + randomizeName + + "&serveStale=" + serveStale + "&serveStaleTtl=" + serveStaleTtl + "&cachePrefetchEligibility=" + cachePrefetchEligibility + "&cachePrefetchTrigger=" + cachePrefetchTrigger + "&cachePrefetchSampleIntervalInMinutes=" + cachePrefetchSampleIntervalInMinutes + "&cachePrefetchSampleEligibilityHitsPerHour=" + cachePrefetchSampleEligibilityHitsPerHour + + proxy + "&forwarders=" + encodeURIComponent(forwarders) + "&forwarderProtocol=" + forwarderProtocol + "&blockListUrls=" + encodeURIComponent(blockListUrls) + "&blockListUpdateIntervalHours=" + blockListUpdateIntervalHours, success: function (responseJSON) { document.title = "Technitium DNS Server " + responseJSON.response.version + " - " + responseJSON.response.serverDomain; $("#lblServerDomain").text(" - " + responseJSON.response.serverDomain); @@ -886,6 +915,30 @@ function saveDnsSettings() { return false; } +function forceUpdateBlockLists() { + if (!confirm("Are you sure to force download and update the block lists?")) + return false; + + var btn = $("#btnUpdateBlockListsNow").button('loading'); + + HTTPRequest({ + url: "/api/forceUpdateBlockLists?token=" + token, + success: function (responseJSON) { + btn.button('reset'); + showAlert("success", "Updating Block List!", "Block list update was triggered successfully."); + }, + error: function () { + btn.button('reset'); + }, + invalidToken: function () { + btn.button('reset'); + showPageLogin(); + } + }); + + return false; +} + function cleanTextList(text) { text = text.replace(/\n/g, ","); @@ -1611,12 +1664,19 @@ function refreshLogFilesList() { success: function (responseJSON) { var logFiles = responseJSON.response.logFiles; - var list = ""; + var list = ""; - for (var i = 0; i < logFiles.length; i++) { - var logFile = logFiles[i]; + if (logFiles.length == 0) { + list += "
No Log Was Found
"; + } + else { + list += ""; - list += "" + for (var i = 0; i < logFiles.length; i++) { + var logFile = logFiles[i]; + + list += "" + } } lstLogFiles.html(list); @@ -1698,6 +1758,46 @@ function deleteLog() { return false; } +function deleteAllLogs() { + + if (!confirm("Are you sure you want to permanently delete all log files?")) + return false; + + HTTPRequest({ + url: "/api/deleteAllLogs?token=" + token, + success: function (responseJSON) { + refreshLogFilesList(); + + $("#divLogViewer").hide(); + + showAlert("success", "Logs Deleted!", "All log files were deleted successfully."); + }, + invalidToken: function () { + showPageLogin(); + } + }); + + return false; +} + +function deleteAllStats() { + + if (!confirm("Are you sure you want to permanently delete all stats files?")) + return false; + + HTTPRequest({ + url: "/api/deleteAllStats?token=" + token, + success: function (responseJSON) { + showAlert("success", "Stats Deleted!", "All stats files were deleted successfully."); + }, + invalidToken: function () { + showPageLogin(); + } + }); + + return false; +} + function resetImportAllowedZonesModal() { $("#divImportAllowedZonesAlert").html("");