From 98b526e89a80ac23b0800deea800cf7af199030a Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sun, 4 Feb 2024 18:10:42 +0530 Subject: [PATCH] zone.js: updated code for ddns support for forwarders. --- DnsServerCore/www/js/zone.js | 215 ++++++++++++++++++++--------------- 1 file changed, 124 insertions(+), 91 deletions(-) diff --git a/DnsServerCore/www/js/zone.js b/DnsServerCore/www/js/zone.js index 18a62541..3e2b3d10 100644 --- a/DnsServerCore/www/js/zone.js +++ b/DnsServerCore/www/js/zone.js @@ -1,6 +1,6 @@ /* Technitium DNS Server -Copyright (C) 2023 Shreyas Zare (shreyas@technitium.com) +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 @@ -407,10 +407,14 @@ function refreshZones(checkDisplay, pageNumber) { switch (zones[i].type) { case "Primary": - case "Secondary": hideOptionsMenu = zones[i].internal; break; + case "Secondary": + case "Forwarder": + hideOptionsMenu = false; + break; + default: hideOptionsMenu = true; break; @@ -956,114 +960,123 @@ function showZoneOptionsModal(zone) { $("#txtZoneNotifyNameServers").prop("disabled", true); $("#txtDynamicUpdateIpAddresses").prop("disabled", true); - //zone transfer - switch (responseJSON.response.zoneTransfer) { - case "Allow": - $("#rdZoneTransferAllow").prop("checked", true); - break; + if ((responseJSON.response.type == "Primary") || (responseJSON.response.type == "Secondary")) { + //zone transfer + switch (responseJSON.response.zoneTransfer) { + case "Allow": + $("#rdZoneTransferAllow").prop("checked", true); + break; - case "AllowOnlyZoneNameServers": - $("#rdZoneTransferAllowOnlyZoneNameServers").prop("checked", true); - break; + case "AllowOnlyZoneNameServers": + $("#rdZoneTransferAllowOnlyZoneNameServers").prop("checked", true); + break; - case "AllowOnlySpecifiedNameServers": - $("#rdZoneTransferAllowOnlySpecifiedNameServers").prop("checked", true); - $("#txtZoneTransferNameServers").prop("disabled", false); - break; + case "AllowOnlySpecifiedNameServers": + $("#rdZoneTransferAllowOnlySpecifiedNameServers").prop("checked", true); + $("#txtZoneTransferNameServers").prop("disabled", false); + break; - case "AllowBothZoneAndSpecifiedNameServers": - $("#rdZoneTransferAllowBothZoneAndSpecifiedNameServers").prop("checked", true); - $("#txtZoneTransferNameServers").prop("disabled", false); - break; + case "AllowBothZoneAndSpecifiedNameServers": + $("#rdZoneTransferAllowBothZoneAndSpecifiedNameServers").prop("checked", true); + $("#txtZoneTransferNameServers").prop("disabled", false); + break; - case "Deny": - default: - $("#rdZoneTransferDeny").prop("checked", true); - break; - } + case "Deny": + default: + $("#rdZoneTransferDeny").prop("checked", true); + break; + } - { - var value = ""; + { + var value = ""; - for (var i = 0; i < responseJSON.response.zoneTransferNameServers.length; i++) - value += responseJSON.response.zoneTransferNameServers[i] + "\r\n"; + for (var i = 0; i < responseJSON.response.zoneTransferNameServers.length; i++) + value += responseJSON.response.zoneTransferNameServers[i] + "\r\n"; - $("#txtZoneTransferNameServers").val(value); - } + $("#txtZoneTransferNameServers").val(value); + } - { - var value = ""; + { + var value = ""; - if (responseJSON.response.zoneTransferTsigKeyNames != null) { - for (var i = 0; i < responseJSON.response.zoneTransferTsigKeyNames.length; i++) { - value += responseJSON.response.zoneTransferTsigKeyNames[i] + "\r\n"; + if (responseJSON.response.zoneTransferTsigKeyNames != null) { + for (var i = 0; i < responseJSON.response.zoneTransferTsigKeyNames.length; i++) { + value += responseJSON.response.zoneTransferTsigKeyNames[i] + "\r\n"; + } } + + $("#txtZoneOptionsZoneTransferTsigKeyNames").val(value); } - $("#txtZoneOptionsZoneTransferTsigKeyNames").val(value); - } + { + var options = ""; - { - var options = ""; - - if (responseJSON.response.availableTsigKeyNames != null) { - for (var i = 0; i < responseJSON.response.availableTsigKeyNames.length; i++) { - options += ""; + if (responseJSON.response.availableTsigKeyNames != null) { + for (var i = 0; i < responseJSON.response.availableTsigKeyNames.length; i++) { + options += ""; + } } + + $("#optZoneOptionsQuickTsigKeyNames").html(options); } - $("#optZoneOptionsQuickTsigKeyNames").html(options); - } + //notify + switch (responseJSON.response.notify) { + case "ZoneNameServers": + $("#rdZoneNotifyZoneNameServers").prop("checked", true); + break; - //notify - switch (responseJSON.response.notify) { - case "ZoneNameServers": - $("#rdZoneNotifyZoneNameServers").prop("checked", true); - break; + case "SpecifiedNameServers": + $("#rdZoneNotifySpecifiedNameServers").prop("checked", true); + $("#txtZoneNotifyNameServers").prop("disabled", false); + break; - case "SpecifiedNameServers": - $("#rdZoneNotifySpecifiedNameServers").prop("checked", true); - $("#txtZoneNotifyNameServers").prop("disabled", false); - break; + case "BothZoneAndSpecifiedNameServers": + $("#rdZoneNotifyBothZoneAndSpecifiedNameServers").prop("checked", true); + $("#txtZoneNotifyNameServers").prop("disabled", false); + break; - case "BothZoneAndSpecifiedNameServers": - $("#rdZoneNotifyBothZoneAndSpecifiedNameServers").prop("checked", true); - $("#txtZoneNotifyNameServers").prop("disabled", false); - break; - - case "None": - default: - $("#rdZoneNotifyNone").prop("checked", true); - break; - } - - { - var value = ""; - - for (var i = 0; i < responseJSON.response.notifyNameServers.length; i++) - value += responseJSON.response.notifyNameServers[i] + "\r\n"; - - $("#txtZoneNotifyNameServers").val(value); - } - - if (responseJSON.response.notifyFailed) { - var value = ""; - - for (var i = 0; i < responseJSON.response.notifyFailedFor.length; i++) { - if (i == 0) - value = responseJSON.response.notifyFailedFor[i]; - else - value += ", " + responseJSON.response.notifyFailedFor[i]; + case "None": + default: + $("#rdZoneNotifyNone").prop("checked", true); + break; } - $("#divZoneNotifyFailedNameServers").show(); - $("#lblZoneNotifyFailedNameServers").text(value); + { + var value = ""; + + for (var i = 0; i < responseJSON.response.notifyNameServers.length; i++) + value += responseJSON.response.notifyNameServers[i] + "\r\n"; + + $("#txtZoneNotifyNameServers").val(value); + } + + if (responseJSON.response.notifyFailed) { + var value = ""; + + for (var i = 0; i < responseJSON.response.notifyFailedFor.length; i++) { + if (i == 0) + value = responseJSON.response.notifyFailedFor[i]; + else + value += ", " + responseJSON.response.notifyFailedFor[i]; + } + + $("#divZoneNotifyFailedNameServers").show(); + $("#lblZoneNotifyFailedNameServers").text(value); + } + else { + $("#divZoneNotifyFailedNameServers").hide(); + } + + $("#tabListZoneOptionsZoneTranfer").show(); + $("#tabListZoneOptionsNotify").show(); } else { - $("#divZoneNotifyFailedNameServers").hide(); + $("#tabListZoneOptionsZoneTranfer").hide(); + $("#tabListZoneOptionsNotify").hide(); } - if (responseJSON.response.type == "Primary") { + if ((responseJSON.response.type == "Primary") || (responseJSON.response.type == "Forwarder")) { //dynamic update switch (responseJSON.response.update) { case "Allow": @@ -1109,6 +1122,15 @@ function showZoneOptionsModal(zone) { } } + if (responseJSON.response.type == "Forwarder") { + $("#divDynamicUpdateAllowOnlyZoneNameServers").hide(); + $("#divDynamicUpdateAllowBothZoneNameServersAndSpecifiedIpAddresses").hide(); + } + else { + $("#divDynamicUpdateAllowOnlyZoneNameServers").show(); + $("#divDynamicUpdateAllowBothZoneNameServersAndSpecifiedIpAddresses").show(); + } + $("#tabListZoneOptionsUpdate").show(); } else { @@ -1118,12 +1140,22 @@ function showZoneOptionsModal(zone) { $("#tbodyDynamicUpdateSecurityPolicy").html(""); } - $("#tabListZoneOptionsZoneTranfer").addClass("active"); - $("#tabPaneZoneOptionsZoneTransfer").addClass("active"); - $("#tabListZoneOptionsNotify").removeClass("active"); - $("#tabPaneZoneOptionsNotify").removeClass("active"); - $("#tabListZoneOptionsUpdate").removeClass("active"); - $("#tabPaneZoneOptionsUpdate").removeClass("active"); + if (responseJSON.response.type == "Forwarder") { + $("#tabListZoneOptionsZoneTranfer").removeClass("active"); + $("#tabPaneZoneOptionsZoneTransfer").removeClass("active"); + $("#tabListZoneOptionsNotify").removeClass("active"); + $("#tabPaneZoneOptionsNotify").removeClass("active"); + $("#tabListZoneOptionsUpdate").addClass("active"); + $("#tabPaneZoneOptionsUpdate").addClass("active"); + } + else { + $("#tabListZoneOptionsZoneTranfer").addClass("active"); + $("#tabPaneZoneOptionsZoneTransfer").addClass("active"); + $("#tabListZoneOptionsNotify").removeClass("active"); + $("#tabPaneZoneOptionsNotify").removeClass("active"); + $("#tabListZoneOptionsUpdate").removeClass("active"); + $("#tabPaneZoneOptionsUpdate").removeClass("active"); + } divZoneOptionsLoader.hide(); divZoneOptions.show(); @@ -1805,6 +1837,7 @@ function showEditZone(zone, showPageNumber) { switch (zoneType) { case "Primary": case "Secondary": + case "Forwarder": $("#lnkZoneOptions").show(); break;