mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2026-03-16 02:20:07 +00:00
WebApp: Blocked Zones UI tab added. Block List URL settings added.
This commit is contained in:
@@ -89,6 +89,7 @@
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li id="mainPanelTabListZones" role="presentation" class="active"><a href="#mainPanelTabPaneZones" aria-controls="mainPanelTabPaneZones" role="tab" data-toggle="tab" onclick="return refreshZonesList();">Zones</a></li>
|
||||
<li id="mainPanelTabListCachedZones" role="presentation"><a href="#mainPanelTabPaneCachedZones" aria-controls="mainPanelTabPaneCachedZones" role="tab" data-toggle="tab" onclick="return false;">Cached Zones</a></li>
|
||||
<li id="mainPanelTabListBlockedZones" role="presentation"><a href="#mainPanelTabPaneBlockedZones" aria-controls="mainPanelTabPaneBlockedZones" role="tab" data-toggle="tab" onclick="return false;">Blocked Zones</a></li>
|
||||
<li id="mainPanelTabListDnsClient" role="presentation"><a href="#mainPanelTabPaneDnsClient" aria-controls="mainPanelTabPaneZones" role="tab" data-toggle="tab" onclick="return false;">DNS Client</a></li>
|
||||
<li id="mainPanelTabListSettings" role="presentation"><a href="#mainPanelTabPaneSettings" aria-controls="mainPanelTabPaneSettings" role="tab" data-toggle="tab" onclick="return loadDnsSettings();">Settings</a></li>
|
||||
<li id="mainPanelTabListLogs" role="presentation"><a href="#mainPanelTabPaneLogs" aria-controls="mainPanelTabPaneLogs" role="tab" data-toggle="tab" onclick="return refreshLogFilesList();">Logs</a></li>
|
||||
@@ -398,6 +399,40 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div id="mainPanelTabPaneBlockedZones" role="tabpanel" class="tab-pane" style="padding: 10px 0 0 0;">
|
||||
|
||||
<div class="well well-sm zone-list-pane">
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" style="width: 170px;" id="txtBlockZone" placeholder="example.com">
|
||||
<button id="btnBlockZone" type="submit" class="btn btn-primary" data-loading-text="Block" onclick="return blockZone();">Block</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div id="lstBlockedZones" class="zones">
|
||||
<div class="zone"><a href="#" onclick="return refreshBlockedZonesList('technitium.com');">technitium.com</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divBlockedZoneViewer" class="zone-viewer-pane">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" style="height: 36px; padding: 4px 6px;">
|
||||
<div id="txtBlockedZoneViewerTitle" style="float: left; padding: 4px;">technitium.com</div>
|
||||
<div style="float: right;">
|
||||
<button id="btnDeleteBlockedZone" type="button" class="btn btn-danger" data-loading-text="Delete" onclick="return deleteBlockedZone();" style="font-size: 12px; padding: 4px 6px;">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<pre id="preBlockedZoneViewerBody">
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="mainPanelTabPaneDnsClient" role="tabpanel" class="tab-pane" style="padding: 10px 0 0 0;">
|
||||
|
||||
<form class="form-inline well">
|
||||
@@ -565,6 +600,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="well well-sm form-horizontal">
|
||||
<div class="form-group">
|
||||
<label for="txtBlockListUrl" class="col-sm-3 control-label">Block List URL</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" id="txtBlockListUrl" placeholder="Block List URL">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 10px;">DNS Server will use the <i>hosts</i> file returned by the block list URL to update the blocked zones automatically every 24 hours. The expected file format is standard <i>hosts</i> file format.</div>
|
||||
</div>
|
||||
|
||||
<div class="well well-sm form-horizontal">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">Network Proxy</label>
|
||||
@@ -674,6 +720,7 @@
|
||||
<div class="form-group" style="margin-bottom: 0px;">
|
||||
<button id="btnSaveDnsSettings" type="button" class="btn btn-primary" data-loading-text="Saving..." onclick="return saveDnsSettings();" style="margin-right: 6px;">Save Settings</button>
|
||||
<button id="btnFlushDnsCache" type="button" class="btn btn-warning" data-loading-text="Flushing..." onclick="return flushDnsCache();">Flush Cache</button>
|
||||
<button id="btnFlushBlockedZone" type="button" class="btn btn-warning" data-loading-text="Flushing..." onclick="return flushBlockedZone();">Flush Blocked Zone</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
@@ -52,6 +52,7 @@ function showPageMain(username) {
|
||||
loadDnsSettings();
|
||||
refreshZonesList();
|
||||
refreshCachedZonesList();
|
||||
refreshBlockedZonesList();
|
||||
checkForUpdate();
|
||||
|
||||
refreshZonesTimerHandle = setInterval(function () { refreshZonesList(true); }, 60000);
|
||||
@@ -358,6 +359,14 @@ function loadDnsSettings() {
|
||||
break;
|
||||
}
|
||||
|
||||
var blockListUrl = responseJSON.response.blockListUrl;
|
||||
if (blockListUrl === null) {
|
||||
$("#txtBlockListUrl").val("");
|
||||
}
|
||||
else {
|
||||
$("#txtBlockListUrl").val(blockListUrl);
|
||||
}
|
||||
|
||||
divDnsSettingsLoader.hide();
|
||||
divDnsSettings.show();
|
||||
},
|
||||
@@ -419,17 +428,21 @@ function saveDnsSettings() {
|
||||
|
||||
var forwarderProtocol = $('input[name=rdForwarderProtocol]:checked').val();
|
||||
|
||||
var blockListUrl = $("#txtBlockListUrl").val();
|
||||
if (blockListUrl.length === 0)
|
||||
blockListUrl = false;
|
||||
|
||||
var btn = $("#btnSaveDnsSettings").button('loading');
|
||||
|
||||
HTTPRequest({
|
||||
url: "/api/setDnsSettings?token=" + token + "&serverDomain=" + serverDomain + "&webServicePort=" + webServicePort + "&preferIPv6=" + preferIPv6 + "&logQueries=" + logQueries + "&allowRecursion=" + allowRecursion + "&allowRecursionOnlyForPrivateNetworks=" + allowRecursionOnlyForPrivateNetworks + proxy + "&forwarders=" + forwarders + "&forwarderProtocol=" + forwarderProtocol,
|
||||
url: "/api/setDnsSettings?token=" + token + "&serverDomain=" + serverDomain + "&webServicePort=" + webServicePort + "&preferIPv6=" + preferIPv6 + "&logQueries=" + logQueries + "&allowRecursion=" + allowRecursion + "&allowRecursionOnlyForPrivateNetworks=" + allowRecursionOnlyForPrivateNetworks + proxy + "&forwarders=" + forwarders + "&forwarderProtocol=" + forwarderProtocol + "&blockListUrl=" + blockListUrl,
|
||||
success: function (responseJSON) {
|
||||
document.title = "Technitium DNS Server " + responseJSON.response.version + " - " + responseJSON.response.serverDomain;
|
||||
$("#lblServerDomain").text(" - " + responseJSON.response.serverDomain);
|
||||
$("#txtServerDomain").val(responseJSON.response.serverDomain)
|
||||
$("#txtServerDomain").val(responseJSON.response.serverDomain);
|
||||
|
||||
btn.button('reset');
|
||||
showAlert("success", "Settings Saved!", "Dns server settings were saved successfully.");
|
||||
showAlert("success", "Settings Saved!", "DNS Server settings were saved successfully.");
|
||||
},
|
||||
error: function () {
|
||||
btn.button('reset');
|
||||
@@ -445,7 +458,7 @@ function saveDnsSettings() {
|
||||
|
||||
function flushDnsCache() {
|
||||
|
||||
if (!confirm("Are you sure to flush the DNS server cache?"))
|
||||
if (!confirm("Are you sure to flush the DNS Server cache?"))
|
||||
return false;
|
||||
|
||||
var btn = $("#btnFlushDnsCache").button('loading');
|
||||
@@ -454,7 +467,7 @@ function flushDnsCache() {
|
||||
url: "/api/flushDnsCache?token=" + token,
|
||||
success: function (responseJSON) {
|
||||
btn.button('reset');
|
||||
showAlert("success", "Cache Flushed!", "Dns server cache was flushed successfully.");
|
||||
showAlert("success", "Cache Flushed!", "DNS Server cache was flushed successfully.");
|
||||
},
|
||||
error: function () {
|
||||
btn.button('reset');
|
||||
@@ -581,6 +594,160 @@ function refreshCachedZonesList(domain, direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function blockZone() {
|
||||
|
||||
var domain = $("#txtBlockZone").val();
|
||||
|
||||
if ((domain === null) || (domain === "")) {
|
||||
showAlert("warning", "Missing!", "Please enter a domain name to block.");
|
||||
return false;
|
||||
}
|
||||
|
||||
var btn = $("#btnBlockZone").button('loading');
|
||||
|
||||
HTTPRequest({
|
||||
url: "/api/blockZone?token=" + token + "&domain=" + domain,
|
||||
success: function (responseJSON) {
|
||||
refreshBlockedZonesList(domain);
|
||||
|
||||
$("#txtBlockZone").val("");
|
||||
btn.button('reset');
|
||||
|
||||
showAlert("success", "Zone Blocked!", "Zone was blocked successfully.");
|
||||
},
|
||||
error: function () {
|
||||
btn.button('reset');
|
||||
},
|
||||
invalidToken: function () {
|
||||
btn.button('reset');
|
||||
showPageLogin();
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function flushBlockedZone() {
|
||||
|
||||
if (!confirm("Are you sure to flush the DNS Server blocked zone?"))
|
||||
return false;
|
||||
|
||||
var btn = $("#btnFlushBlockedZone").button('loading');
|
||||
|
||||
HTTPRequest({
|
||||
url: "/api/flushBlockedZone?token=" + token,
|
||||
success: function (responseJSON) {
|
||||
btn.button('reset');
|
||||
showAlert("success", "Blocked Zone Flushed!", "DNS Server blocked zone was flushed successfully.");
|
||||
},
|
||||
error: function () {
|
||||
btn.button('reset');
|
||||
},
|
||||
invalidToken: function () {
|
||||
btn.button('reset');
|
||||
showPageLogin();
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function deleteBlockedZone() {
|
||||
|
||||
var domain = $("#txtBlockedZoneViewerTitle").text();
|
||||
|
||||
if (!confirm("Are you sure you want to delete the blocked zone '" + domain + "'?"))
|
||||
return false;
|
||||
|
||||
var btn = $("#btnDeleteBlockedZone").button('loading');
|
||||
|
||||
HTTPRequest({
|
||||
url: "/api/deleteBlockedZone?token=" + token + "&domain=" + domain,
|
||||
success: function (responseJSON) {
|
||||
refreshBlockedZonesList(getParentDomain(domain), "up");
|
||||
|
||||
btn.button('reset');
|
||||
showAlert("success", "Blocked Zone Deleted!", "Blocked zone was deleted successfully.");
|
||||
},
|
||||
error: function () {
|
||||
btn.button('reset');
|
||||
},
|
||||
invalidToken: function () {
|
||||
btn.button('reset');
|
||||
showPageLogin();
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function refreshBlockedZonesList(domain, direction) {
|
||||
|
||||
if (domain == null)
|
||||
domain = "";
|
||||
|
||||
domain.toLowerCase();
|
||||
|
||||
var lstBlockedZones = $("#lstBlockedZones");
|
||||
var divBlockedZoneViewer = $("#divBlockedZoneViewer");
|
||||
var preBlockedZoneViewerBody = $("#preBlockedZoneViewerBody");
|
||||
|
||||
divBlockedZoneViewer.hide();
|
||||
preBlockedZoneViewerBody.hide();
|
||||
|
||||
HTTPRequest({
|
||||
url: "/api/listBlockedZones?token=" + token + "&domain=" + domain + ((direction == null) ? "" : "&direction=" + direction),
|
||||
success: function (responseJSON) {
|
||||
var newDomain = responseJSON.response.domain;
|
||||
var zones = responseJSON.response.zones;
|
||||
|
||||
var list = "<div class=\"zone\"><a href=\"#\" onclick=\"return refreshBlockedZonesList('" + newDomain + "');\"><b>[refresh]</b></a></div>"
|
||||
|
||||
var parentDomain = getParentDomain(newDomain);
|
||||
|
||||
if (parentDomain != null)
|
||||
list += "<div class=\"zone\"><a href=\"#\" onclick=\"return refreshBlockedZonesList('" + parentDomain + "', 'up');\"><b>[up]</b></a></div>"
|
||||
|
||||
for (var i = 0; i < zones.length; i++) {
|
||||
var zoneName = htmlEncode(zones[i]);
|
||||
|
||||
list += "<div class=\"zone\"><a href=\"#\" onclick=\"return refreshBlockedZonesList('" + zoneName + "');\">" + zoneName + "</a></div>"
|
||||
}
|
||||
|
||||
lstBlockedZones.html(list);
|
||||
|
||||
if (newDomain == "") {
|
||||
$("#txtBlockedZoneViewerTitle").text("<ROOT>");
|
||||
$("#btnDeleteBlockedZone").hide();
|
||||
}
|
||||
else {
|
||||
$("#txtBlockedZoneViewerTitle").text(newDomain);
|
||||
|
||||
if ((newDomain == "root-servers.net") || newDomain.endsWith(".root-servers.net"))
|
||||
$("#btnDeleteBlockedZone").hide();
|
||||
else
|
||||
$("#btnDeleteBlockedZone").show();
|
||||
}
|
||||
|
||||
if (responseJSON.response.records.length > 0) {
|
||||
preBlockedZoneViewerBody.text(JSON.stringify(responseJSON.response.records, null, 2));
|
||||
preBlockedZoneViewerBody.show();
|
||||
}
|
||||
|
||||
divBlockedZoneViewer.show();
|
||||
},
|
||||
invalidToken: function () {
|
||||
showPageLogin();
|
||||
},
|
||||
error: function () {
|
||||
lstBlockedZones.html("<div class=\"zone\"><a href=\"#\" onclick=\"return refreshBlockedZonesList('" + domain + "');\"><b>[refresh]</b></a></div>");
|
||||
},
|
||||
objLoaderPlaceholder: lstBlockedZones
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function refreshZonesList(hideLoader) {
|
||||
|
||||
if (hideLoader == null)
|
||||
|
||||
Reference in New Issue
Block a user