From 047b507ccb863cda1145eb47886af068a945d9bf Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 14 Sep 2024 20:21:31 +0530 Subject: [PATCH] zone.js: updated code to support new zone types with new options. --- DnsServerCore/www/js/zone.js | 1900 +++++++++++++++++++++++----------- 1 file changed, 1278 insertions(+), 622 deletions(-) diff --git a/DnsServerCore/www/js/zone.js b/DnsServerCore/www/js/zone.js index 2b036427..e0ad8749 100644 --- a/DnsServerCore/www/js/zone.js +++ b/DnsServerCore/www/js/zone.js @@ -25,6 +25,8 @@ $(function () { $("input[type=radio][name=rdAddZoneType]").change(function () { $("#divAddZoneUseSoaSerialDateScheme").hide(); $("#divAddZonePrimaryNameServerAddresses").hide(); + $("#lblAddZonePrimaryNameServerAddresses").text("Primary Name Server Addresses (Optional)"); + $("#divAddZonePrimaryNameServerAddressesInfo").text("Enter the primary name server addresses to sync the zone from. When unspecified, the SOA Primary Name Server will be resolved and used."); $("#divAddZoneZoneTransferProtocol").hide(); $("#divAddZoneTsigKeyName").hide(); $("#divAddZoneValidateZone").hide(); @@ -32,10 +34,14 @@ $(function () { $("#divAddZoneForwarder").hide(); $("#divAddZoneForwarderDnssecValidation").hide(); $("#divAddZoneForwarderProxy").hide(); + $("#divAddZoneCatalogZone").hide(); var zoneType = $('input[name=rdAddZoneType]:checked').val(); switch (zoneType) { case "Primary": + if ($("#optAddZoneCatalogZoneName").attr("hasItems") == "true") + $("#divAddZoneCatalogZone").show(); + $("#divAddZoneUseSoaSerialDateScheme").show(); break; @@ -49,15 +55,32 @@ $(function () { break; case "Stub": + if ($("#optAddZoneCatalogZoneName").attr("hasItems") == "true") + $("#divAddZoneCatalogZone").show(); + $("#divAddZonePrimaryNameServerAddresses").show(); break; case "Forwarder": + if ($("#optAddZoneCatalogZoneName").attr("hasItems") == "true") + $("#divAddZoneCatalogZone").show(); + $("#divAddZoneForwarderProtocol").show(); $("#divAddZoneForwarder").show(); $("#divAddZoneForwarderDnssecValidation").show(); $("#divAddZoneForwarderProxy").show(); break; + + case "SecondaryForwarder": + case "SecondaryCatalog": + $("#lblAddZonePrimaryNameServerAddresses").text("Primary Name Server Addresses"); + $("#divAddZonePrimaryNameServerAddressesInfo").text("Enter the primary name server addresses to sync the zone from."); + $("#divAddZonePrimaryNameServerAddresses").show(); + $("#divAddZoneZoneTransferProtocol").show(); + $("#divAddZoneTsigKeyName").show(); + + loadTsigKeyNames($("#optAddZoneTsigKeyName"), null, $("#divAddZoneAlert")); + break; } }); @@ -90,16 +113,105 @@ $(function () { $("#txtAddZoneForwarderProxyPassword").prop("disabled", disabled); }); - $("input[type=radio][name=rdZoneTransfer]").change(function () { - var zoneTransfer = $('input[name=rdZoneTransfer]:checked').val(); - switch (zoneTransfer) { - case "AllowOnlySpecifiedNameServers": - case "AllowBothZoneAndSpecifiedNameServers": - $("#txtZoneTransferNameServers").prop("disabled", false); + $("#optZoneOptionsCatalogZoneName").change(function () { + var catalog = $("#optZoneOptionsCatalogZoneName").val(); + if (catalog === "") { + $("#chkZoneOptionsCatalogOverrideQueryAccess").prop("checked", false); + $("#chkZoneOptionsCatalogOverrideZoneTransfer").prop("checked", false); + $("#chkZoneOptionsCatalogOverrideNotify").prop("checked", false); + + $("#chkZoneOptionsCatalogOverrideQueryAccess").prop("disabled", true); + $("#chkZoneOptionsCatalogOverrideZoneTransfer").prop("disabled", true); + $("#chkZoneOptionsCatalogOverrideNotify").prop("disabled", true); + + switch ($("#lblZoneOptionsZoneName").attr("data-zone-type")) { + case "Primary": + case "Forwarder": + $("#tabListZoneOptionsQueryAccess").show(); + $("#tabListZoneOptionsZoneTranfer").show(); + $("#tabListZoneOptionsNotify").show(); + break; + + case "Stub": + $("#tabListZoneOptionsQueryAccess").show(); + break; + } + } + else { + $("#chkZoneOptionsCatalogOverrideQueryAccess").prop("checked", false); + $("#chkZoneOptionsCatalogOverrideZoneTransfer").prop("checked", false); + $("#chkZoneOptionsCatalogOverrideNotify").prop("checked", false); + + switch ($("#lblZoneOptionsZoneName").attr("data-zone-type")) { + case "Primary": + case "Forwarder": + $("#chkZoneOptionsCatalogOverrideQueryAccess").prop("disabled", false); + $("#chkZoneOptionsCatalogOverrideZoneTransfer").prop("disabled", false); + $("#chkZoneOptionsCatalogOverrideNotify").prop("disabled", false); + break; + + case "Stub": + $("#chkZoneOptionsCatalogOverrideQueryAccess").prop("disabled", false); + break; + } + + $("#tabListZoneOptionsQueryAccess").hide(); + $("#tabListZoneOptionsZoneTranfer").hide(); + $("#tabListZoneOptionsNotify").hide(); + } + }); + + $("#chkZoneOptionsCatalogOverrideQueryAccess").click(function () { + var checked = $("#chkZoneOptionsCatalogOverrideQueryAccess").prop("checked"); + + if (checked) + $("#tabListZoneOptionsQueryAccess").show(); + else + $("#tabListZoneOptionsQueryAccess").hide(); + }); + + $("#chkZoneOptionsCatalogOverrideZoneTransfer").click(function () { + var checked = $("#chkZoneOptionsCatalogOverrideZoneTransfer").prop("checked"); + + if (checked) + $("#tabListZoneOptionsZoneTranfer").show(); + else + $("#tabListZoneOptionsZoneTranfer").hide(); + }); + + $("#chkZoneOptionsCatalogOverrideNotify").click(function () { + var checked = $("#chkZoneOptionsCatalogOverrideNotify").prop("checked"); + + if (checked) + $("#tabListZoneOptionsNotify").show(); + else + $("#tabListZoneOptionsNotify").hide(); + }); + + $("input[type=radio][name=rdQueryAccess]").change(function () { + var queryAccess = $("input[name=rdQueryAccess]:checked").val(); + switch (queryAccess) { + case "UseSpecifiedNetworkACL": + case "AllowZoneNameServersAndUseSpecifiedNetworkACL": + $("#txtQueryAccessNetworkACL").prop("disabled", false); break; default: - $("#txtZoneTransferNameServers").prop("disabled", true); + $("#txtQueryAccessNetworkACL").prop("disabled", true); + break; + } + }); + + $("input[type=radio][name=rdZoneTransfer]").change(function () { + var zoneTransfer = $('input[name=rdZoneTransfer]:checked').val(); + switch (zoneTransfer) { + case "UseSpecifiedNetworkACL": + case "AllowZoneNameServersAndUseSpecifiedNetworkACL": + $("#txtZoneTransferNetworkACL").prop("disabled", false); + break; + + default: + $("#txtZoneTransferNetworkACL").prop("disabled", true); break; } }); @@ -121,13 +233,13 @@ $(function () { $("input[type=radio][name=rdDynamicUpdate]").change(function () { var dynamicUpdate = $('input[name=rdDynamicUpdate]:checked').val(); switch (dynamicUpdate) { - case "AllowOnlySpecifiedIpAddresses": - case "AllowBothZoneNameServersAndSpecifiedIpAddresses": - $("#txtDynamicUpdateIpAddresses").prop("disabled", false); + case "UseSpecifiedNetworkACL": + case "AllowZoneNameServersAndUseSpecifiedNetworkACL": + $("#txtDynamicUpdateNetworkACL").prop("disabled", false); break; default: - $("#txtDynamicUpdateIpAddresses").prop("disabled", true); + $("#txtDynamicUpdateNetworkACL").prop("disabled", true); break; } }); @@ -356,10 +468,24 @@ function refreshZones(checkDisplay, pageNumber) { name = "."; var type; - if (zones[i].internal) + if (zones[i].internal) { type = "Internal"; - else - type = "" + zones[i].type + ""; + } + else { + switch (zones[i].type) { + case "SecondaryForwarder": + type = "Secondary Forwarder"; + break; + + case "SecondaryCatalog": + type = "Secondary Catalog"; + break; + + default: + type = "" + zones[i].type + ""; + break; + } + } var soaSerial = zones[i].soaSerial; if (soaSerial == null) @@ -407,6 +533,8 @@ function refreshZones(checkDisplay, pageNumber) { switch (zones[i].type) { case "Secondary": + case "SecondaryForwarder": + case "SecondaryCatalog": case "Stub": showResyncMenu = true; break; @@ -424,7 +552,11 @@ function refreshZones(checkDisplay, pageNumber) { break; case "Secondary": + case "SecondaryForwarder": + case "SecondaryCatalog": + case "Stub": case "Forwarder": + case "Catalog": hideOptionsMenu = false; break; @@ -433,12 +565,30 @@ function refreshZones(checkDisplay, pageNumber) { break; } + var nameTags; + + if (zones[i].catalog != null) { + nameTags = "
" + htmlEncode(zones[i].catalog) + "
"; + } + else { + switch (zones[i].type) { + case "Catalog": + case "SecondaryCatalog": + nameTags = "
" + htmlEncode(name) + "
"; + break; + + default: + nameTags = ""; + break; + } + } + tableHtmlRows += "" + (firstRowNumber + i) + ""; if (zones[i].nameIdn == null) - tableHtmlRows += "" + htmlEncode(name === "." ? "" : name) + ""; + tableHtmlRows += "" + htmlEncode(name === "." ? "" : name) + "" + nameTags + ""; else - tableHtmlRows += "" + htmlEncode(zones[i].nameIdn + " (" + name + ")") + ""; + tableHtmlRows += "" + htmlEncode(zones[i].nameIdn + " (" + name + ")") + "" + nameTags + ""; tableHtmlRows += "" + type + ""; tableHtmlRows += "" + dnssecStatus + ""; @@ -459,19 +609,19 @@ function refreshZones(checkDisplay, pageNumber) { tableHtmlRows += "
  • Resync
  • "; } - if (!hideOptionsMenu) { - tableHtmlRows += "
  • Zone Options
  • "; + switch (zones[i].type) { + case "Primary": + case "Forwarder": + tableHtmlRows += "
  • Clone Zone
  • "; + break; } if (!zones[i].internal) { tableHtmlRows += "
  • Permissions
  • "; } - switch (zones[i].type) { - case "Primary": - case "Forwarder": - tableHtmlRows += "
  • Clone Zone
  • "; - break; + if (!hideOptionsMenu) { + tableHtmlRows += "
  • Zone Options
  • "; } if (!zones[i].internal) { @@ -592,8 +742,8 @@ function enableZone(objBtn) { $("#btnEnableZoneEditZone").hide(); $("#btnDisableZoneEditZone").show(); - $("#titleStatusEditZone").attr("class", "label label-success"); - $("#titleStatusEditZone").html("Enabled"); + $("#titleEditZoneStatus").attr("class", "label label-success"); + $("#titleEditZoneStatus").html("Enabled"); showAlert("success", "Zone Enabled!", "Zone '" + zone + "' was enabled successfully."); }, @@ -660,8 +810,8 @@ function disableZone(objBtn) { $("#btnEnableZoneEditZone").show(); $("#btnDisableZoneEditZone").hide(); - $("#titleStatusEditZone").attr("class", "label label-warning"); - $("#titleStatusEditZone").html("Disabled"); + $("#titleEditZoneStatus").attr("class", "label label-warning"); + $("#titleEditZoneStatus").html("Disabled"); showAlert("success", "Zone Disabled!", "Zone '" + zone + "' was disabled successfully."); }, @@ -856,6 +1006,7 @@ function showConvertZoneModal(zone, type) { break; case "Secondary": + case "SecondaryForwarder": $("#rdConvertZoneToTypePrimary").attr("disabled", false); $("#rdConvertZoneToTypeForwarder").attr("disabled", false); @@ -969,213 +1120,689 @@ function showZoneOptionsModal(zone) { $("#modalZoneOptions").modal("show"); HTTPRequest({ - url: "/api/zones/options/get?token=" + sessionData.token + "&zone=" + zone + "&includeAvailableTsigKeyNames=true", + url: "/api/zones/options/get?token=" + sessionData.token + "&zone=" + zone + "&includeAvailableCatalogZoneNames=true&includeAvailableTsigKeyNames=true", success: function (responseJSON) { - $("#txtZoneTransferNameServers").prop("disabled", true); + $("#optZoneOptionsCatalogZoneName").html(""); + + $("#lblZoneOptionsPrimaryNameServerAddresses").text("Primary Name Server Addresses (Optional)"); + $("#divZoneOptionsPrimaryNameServerAddressesInfo").text("Enter the primary name server addresses to sync the zone from. When unspecified, the SOA Primary Name Server will be resolved and used."); + $("#txtZoneOptionsPrimaryNameServerAddresses").val(""); + $("#rdPrimaryZoneTransferProtocolTcp").prop("checked", true); + $("#optZoneOptionsPrimaryZoneTransferTsigKeyName").val(""); + $("#chkZoneOptionsValidateZone").prop("checked", false); + + $("#tabListZoneOptionsGeneral").hide(); + + $("#divZoneOptionsCatalogNotifyFailedNameServers").hide(); + + $("#rdDynamicUpdateDeny").prop("checked", true); + $("#txtDynamicUpdateNetworkACL").val(""); + $("#tbodyDynamicUpdateSecurityPolicy").html(""); + + $("#txtQueryAccessNetworkACL").prop("disabled", true); + $("#txtZoneTransferNetworkACL").prop("disabled", true); $("#txtZoneNotifyNameServers").prop("disabled", true); - $("#txtDynamicUpdateIpAddresses").prop("disabled", true); + $("#txtDynamicUpdateNetworkACL").prop("disabled", true); - if ((responseJSON.response.type == "Primary") || (responseJSON.response.type == "Secondary")) { - //zone transfer - switch (responseJSON.response.zoneTransfer) { - case "Allow": - $("#rdZoneTransferAllow").prop("checked", true); - break; + $("#lblZoneOptionsZoneName").attr("data-zone-type", responseJSON.response.type); - case "AllowOnlyZoneNameServers": - $("#rdZoneTransferAllowOnlyZoneNameServers").prop("checked", true); - break; + //catalog zone + switch (responseJSON.response.type) { + case "Primary": + case "Forwarder": + if (responseJSON.response.availableCatalogZoneNames.length > 0) { + loadCatalogZoneNamesFrom(responseJSON.response.availableCatalogZoneNames, $("#optZoneOptionsCatalogZoneName"), responseJSON.response.catalog); + $("#optZoneOptionsCatalogZoneName").prop("disabled", false); - case "AllowOnlySpecifiedNameServers": - $("#rdZoneTransferAllowOnlySpecifiedNameServers").prop("checked", true); - $("#txtZoneTransferNameServers").prop("disabled", false); - break; + $("#chkZoneOptionsCatalogOverrideQueryAccess").prop("checked", (responseJSON.response.catalog != null) && responseJSON.response.overrideCatalogQueryAccess); + $("#chkZoneOptionsCatalogOverrideZoneTransfer").prop("checked", (responseJSON.response.catalog != null) && responseJSON.response.overrideCatalogZoneTransfer); + $("#chkZoneOptionsCatalogOverrideNotify").prop("checked", (responseJSON.response.catalog != null) && responseJSON.response.overrideCatalogNotify); - case "AllowBothZoneAndSpecifiedNameServers": - $("#rdZoneTransferAllowBothZoneAndSpecifiedNameServers").prop("checked", true); - $("#txtZoneTransferNameServers").prop("disabled", false); - break; + $("#chkZoneOptionsCatalogOverrideQueryAccess").prop("disabled", (responseJSON.response.catalog == null)); + $("#chkZoneOptionsCatalogOverrideZoneTransfer").prop("disabled", (responseJSON.response.catalog == null)); + $("#chkZoneOptionsCatalogOverrideNotify").prop("disabled", (responseJSON.response.catalog == null)); - case "Deny": - default: - $("#rdZoneTransferDeny").prop("checked", true); - break; - } + $("#divZoneOptionsCatalogOverrideZoneTransfer").show(); + $("#divZoneOptionsCatalogOverrideNotify").show(); - { - var value = ""; + $("#divZoneOptionsCatalogOverrideOptions").show(); + $("#divZoneOptionsGeneralCatalogZone").show(); + $("#tabListZoneOptionsGeneral").show(); + } else { + $("#divZoneOptionsGeneralCatalogZone").hide(); + } + break; - for (var i = 0; i < responseJSON.response.zoneTransferNameServers.length; i++) - value += responseJSON.response.zoneTransferNameServers[i] + "\r\n"; + case "Stub": + if ((responseJSON.response.catalog != null) && responseJSON.response.isSecondaryCatalogMember) { + $("#optZoneOptionsCatalogZoneName").html(""); + $("#optZoneOptionsCatalogZoneName").prop("disabled", true); - $("#txtZoneTransferNameServers").val(value); - } + $("#divZoneOptionsCatalogOverrideOptions").hide(); + $("#divZoneOptionsGeneralCatalogZone").show(); + $("#tabListZoneOptionsGeneral").show(); + } else { + if (responseJSON.response.availableCatalogZoneNames.length > 0) { + loadCatalogZoneNamesFrom(responseJSON.response.availableCatalogZoneNames, $("#optZoneOptionsCatalogZoneName"), responseJSON.response.catalog); + $("#optZoneOptionsCatalogZoneName").prop("disabled", false); - { - var value = ""; + $("#chkZoneOptionsCatalogOverrideQueryAccess").prop("checked", (responseJSON.response.catalog != null) && responseJSON.response.overrideCatalogQueryAccess); + $("#chkZoneOptionsCatalogOverrideQueryAccess").prop("disabled", (responseJSON.response.catalog == null)); - if (responseJSON.response.zoneTransferTsigKeyNames != null) { - for (var i = 0; i < responseJSON.response.zoneTransferTsigKeyNames.length; i++) { - value += responseJSON.response.zoneTransferTsigKeyNames[i] + "\r\n"; + $("#divZoneOptionsCatalogOverrideZoneTransfer").hide(); + $("#divZoneOptionsCatalogOverrideNotify").hide(); + + $("#divZoneOptionsCatalogOverrideOptions").show(); + $("#divZoneOptionsGeneralCatalogZone").show(); + $("#tabListZoneOptionsGeneral").show(); + } else { + $("#divZoneOptionsGeneralCatalogZone").hide(); } } - $("#txtZoneOptionsZoneTransferTsigKeyNames").val(value); - } + break; - { - var options = ""; + case "Secondary": + case "SecondaryForwarder": + if (responseJSON.response.catalog != null) { + $("#optZoneOptionsCatalogZoneName").html(""); + $("#optZoneOptionsCatalogZoneName").prop("disabled", true); - if (responseJSON.response.availableTsigKeyNames != null) { - for (var i = 0; i < responseJSON.response.availableTsigKeyNames.length; i++) { - options += ""; + $("#divZoneOptionsCatalogOverrideOptions").hide(); + $("#divZoneOptionsGeneralCatalogZone").show(); + $("#tabListZoneOptionsGeneral").show(); + } else { + $("#divZoneOptionsGeneralCatalogZone").hide(); + } + break; + + default: + $("#divZoneOptionsGeneralCatalogZone").hide(); + break; + } + + //primary server + switch (responseJSON.response.type) { + case "Secondary": + case "SecondaryForwarder": + case "SecondaryCatalog": + { + var value = ""; + + for (var i = 0; i < responseJSON.response.primaryNameServerAddresses.length; i++) + value += responseJSON.response.primaryNameServerAddresses[i] + "\r\n"; + + $("#txtZoneOptionsPrimaryNameServerAddresses").val(value); + } + + switch (responseJSON.response.primaryZoneTransferProtocol) { + case "Tls": + $("#rdPrimaryZoneTransferProtocolTls").prop("checked", true); + break; + + case "Quic": + $("#rdPrimaryZoneTransferProtocolQuic").prop("checked", true); + break; + + case "Tcp": + default: + $("#rdPrimaryZoneTransferProtocolTcp").prop("checked", true); + break; + } + + loadTsigKeyNamesFrom(responseJSON.response.availableTsigKeyNames, $("#optZoneOptionsPrimaryZoneTransferTsigKeyName"), responseJSON.response.primaryZoneTransferTsigKeyName); + + if (responseJSON.response.type == "Secondary") { + $("#chkZoneOptionsValidateZone").prop("checked", responseJSON.response.validateZone); + $("#divZoneOptionsPrimaryServerValidateZone").show(); + } + else { + $("#divZoneOptionsPrimaryServerValidateZone").hide(); + } + + switch (responseJSON.response.type) { + case "SecondaryForwarder": + case "SecondaryCatalog": + $("#lblZoneOptionsPrimaryNameServerAddresses").text("Primary Name Server Addresses"); + $("#divZoneOptionsPrimaryNameServerAddressesInfo").text("Enter the primary name server addresses to sync the zone from."); + break; + } + + $("#divZoneOptionsPrimaryServerZoneTransferProtocol").show(); + $("#divZoneOptionsPrimaryServerZoneTransferTsigKeyName").show(); + + $("#txtZoneOptionsPrimaryNameServerAddresses").prop("disabled", responseJSON.response.catalog != null); + $("#rdPrimaryZoneTransferProtocolTcp").prop("disabled", responseJSON.response.catalog != null); + $("#rdPrimaryZoneTransferProtocolTls").prop("disabled", responseJSON.response.catalog != null); + $("#rdPrimaryZoneTransferProtocolQuic").prop("disabled", responseJSON.response.catalog != null); + $("#optZoneOptionsPrimaryZoneTransferTsigKeyName").prop("disabled", responseJSON.response.catalog != null); + + switch (responseJSON.response.type) { + case "Secondary": + case "SecondaryForwarder": + if (responseJSON.response.catalog == null) { + $("#divZoneOptionsGeneralPrimaryServer").show(); + $("#tabListZoneOptionsGeneral").show(); + } else if (responseJSON.response.overrideCatalogPrimaryNameServers) { + $("#divZoneOptionsPrimaryServerValidateZone").hide(); + $("#divZoneOptionsGeneralPrimaryServer").show(); + $("#tabListZoneOptionsGeneral").show(); + } else { + $("#divZoneOptionsGeneralPrimaryServer").hide(); + } + + break; + + default: + $("#divZoneOptionsGeneralPrimaryServer").show(); + $("#tabListZoneOptionsGeneral").show(); + break; + } + + break; + + case "Stub": + { + var value = ""; + + for (var i = 0; i < responseJSON.response.primaryNameServerAddresses.length; i++) + value += responseJSON.response.primaryNameServerAddresses[i] + "\r\n"; + + $("#txtZoneOptionsPrimaryNameServerAddresses").val(value); + } + + if ((responseJSON.response.catalog != null) && responseJSON.response.isSecondaryCatalogMember) + $("#txtZoneOptionsPrimaryNameServerAddresses").prop("disabled", true); + else + $("#txtZoneOptionsPrimaryNameServerAddresses").prop("disabled", false); + + $("#divZoneOptionsPrimaryServerZoneTransferProtocol").hide(); + $("#divZoneOptionsPrimaryServerZoneTransferTsigKeyName").hide(); + $("#divZoneOptionsPrimaryServerValidateZone").hide(); + $("#divZoneOptionsGeneralPrimaryServer").show(); + $("#tabListZoneOptionsGeneral").show(); + break; + + default: + $("#divZoneOptionsGeneralPrimaryServer").hide(); + break; + } + + //query access + switch (responseJSON.response.type) { + case "Primary": + case "Stub": + case "Forwarder": + case "Secondary": + case "SecondaryForwarder": + case "Catalog": + switch (responseJSON.response.queryAccess) { + case "Allow": + $("#rdQueryAccessAllow").prop("checked", true); + break; + + case "AllowOnlyPrivateNetworks": + $("#rdQueryAccessAllowOnlyPrivateNetworks").prop("checked", true); + break; + + case "AllowOnlyZoneNameServers": + $("#rdQueryAccessAllowOnlyZoneNameServers").prop("checked", true); + break; + + case "UseSpecifiedNetworkACL": + $("#rdQueryAccessUseSpecifiedNetworkACL").prop("checked", true); + $("#txtQueryAccessNetworkACL").prop("disabled", false); + break; + + case "AllowZoneNameServersAndUseSpecifiedNetworkACL": + $("#rdQueryAccessAllowZoneNameServersAndUseSpecifiedNetworkACL").prop("checked", true); + $("#txtQueryAccessNetworkACL").prop("disabled", false); + break; + + case "Deny": + default: + $("#rdQueryAccessDeny").prop("checked", true); + break; + } + + switch (responseJSON.response.type) { + case "Stub": + case "Forwarder": + case "SecondaryForwarder": + case "Catalog": + $("#divQueryAccessAllowOnlyZoneNameServers").hide(); + $("#divQueryAccessAllowZoneNameServersAndUseSpecifiedNetworkACL").hide(); + break; + + default: + $("#divQueryAccessAllowOnlyZoneNameServers").show(); + $("#divQueryAccessAllowZoneNameServersAndUseSpecifiedNetworkACL").show(); + break; + } + + { + var value = ""; + + for (var i = 0; i < responseJSON.response.queryAccessNetworkACL.length; i++) + value += responseJSON.response.queryAccessNetworkACL[i] + "\r\n"; + + $("#txtQueryAccessNetworkACL").val(value); + } + + switch (responseJSON.response.type) { + case "Primary": + case "Forwarder": + case "Catalog": + if ((responseJSON.response.catalog == null) || responseJSON.response.overrideCatalogQueryAccess) { + $("#rdQueryAccessDeny").prop("disabled", false); + $("#rdQueryAccessAllow").prop("disabled", false); + $("#rdQueryAccessAllowOnlyPrivateNetworks").prop("disabled", false); + $("#rdQueryAccessAllowOnlyZoneNameServers").prop("disabled", false); + $("#rdQueryAccessUseSpecifiedNetworkACL").prop("disabled", false); + $("#rdQueryAccessAllowZoneNameServersAndUseSpecifiedNetworkACL").prop("disabled", false); + + $("#tabListZoneOptionsQueryAccess").show(); + } + else { + $("#tabListZoneOptionsQueryAccess").hide(); + } + + break; + + case "Stub": + if ((responseJSON.response.catalog == null) || responseJSON.response.isSecondaryCatalogMember || responseJSON.response.overrideCatalogQueryAccess) { + $("#rdQueryAccessDeny").prop("disabled", responseJSON.response.isSecondaryCatalogMember == true); + $("#rdQueryAccessAllow").prop("disabled", responseJSON.response.isSecondaryCatalogMember == true); + $("#rdQueryAccessAllowOnlyPrivateNetworks").prop("disabled", responseJSON.response.isSecondaryCatalogMember == true); + $("#rdQueryAccessAllowOnlyZoneNameServers").prop("disabled", responseJSON.response.isSecondaryCatalogMember == true); + $("#rdQueryAccessUseSpecifiedNetworkACL").prop("disabled", responseJSON.response.isSecondaryCatalogMember == true); + $("#rdQueryAccessAllowZoneNameServersAndUseSpecifiedNetworkACL").prop("disabled", responseJSON.response.isSecondaryCatalogMember == true); + + if (responseJSON.response.isSecondaryCatalogMember == true) + $("#txtQueryAccessNetworkACL").prop("disabled", true); + + $("#tabListZoneOptionsQueryAccess").show(); + } + else { + $("#tabListZoneOptionsQueryAccess").hide(); + } + + break; + + case "Secondary": + case "SecondaryForwarder": + $("#rdQueryAccessDeny").prop("disabled", responseJSON.response.catalog != null); + $("#rdQueryAccessAllow").prop("disabled", responseJSON.response.catalog != null); + $("#rdQueryAccessAllowOnlyPrivateNetworks").prop("disabled", responseJSON.response.catalog != null); + $("#rdQueryAccessAllowOnlyZoneNameServers").prop("disabled", responseJSON.response.catalog != null); + $("#rdQueryAccessUseSpecifiedNetworkACL").prop("disabled", responseJSON.response.catalog != null); + $("#rdQueryAccessAllowZoneNameServersAndUseSpecifiedNetworkACL").prop("disabled", responseJSON.response.catalog != null); + + if (responseJSON.response.catalog != null) + $("#txtQueryAccessNetworkACL").prop("disabled", true); + + $("#tabListZoneOptionsQueryAccess").show(); + break; + + default: + $("#tabListZoneOptionsQueryAccess").hide(); + break; + } + + break; + + default: + $("#tabListZoneOptionsQueryAccess").hide(); + break; + } + + //zone transfer & notify + switch (responseJSON.response.type) { + case "Primary": + case "Secondary": + case "Forwarder": + case "Catalog": + //zone transfer + switch (responseJSON.response.zoneTransfer) { + case "Allow": + $("#rdZoneTransferAllow").prop("checked", true); + break; + + case "AllowOnlyZoneNameServers": + $("#rdZoneTransferAllowOnlyZoneNameServers").prop("checked", true); + break; + + case "UseSpecifiedNetworkACL": + $("#rdZoneTransferUseSpecifiedNetworkACL").prop("checked", true); + $("#txtZoneTransferNetworkACL").prop("disabled", false); + break; + + case "AllowZoneNameServersAndUseSpecifiedNetworkACL": + $("#rdZoneTransferAllowZoneNameServersAndUseSpecifiedNetworkACL").prop("checked", true); + $("#txtZoneTransferNetworkACL").prop("disabled", false); + break; + + case "Deny": + default: + $("#rdZoneTransferDeny").prop("checked", true); + break; + } + + { + var value = ""; + + for (var i = 0; i < responseJSON.response.zoneTransferNetworkACL.length; i++) + value += responseJSON.response.zoneTransferNetworkACL[i] + "\r\n"; + + $("#txtZoneTransferNetworkACL").val(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"; + } } + + $("#txtZoneOptionsZoneTransferTsigKeyNames").val(value); } - $("#optZoneOptionsQuickTsigKeyNames").html(options); - } + { + var options = ""; - //notify - switch (responseJSON.response.notify) { - case "ZoneNameServers": - $("#rdZoneNotifyZoneNameServers").prop("checked", true); - break; + if (responseJSON.response.availableTsigKeyNames != null) { + for (var i = 0; i < responseJSON.response.availableTsigKeyNames.length; i++) { + options += ""; + } + } - case "SpecifiedNameServers": - $("#rdZoneNotifySpecifiedNameServers").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]; + $("#optZoneOptionsQuickTsigKeyNames").html(options); } - $("#divZoneNotifyFailedNameServers").show(); - $("#lblZoneNotifyFailedNameServers").text(value); - } - else { - $("#divZoneNotifyFailedNameServers").hide(); - } + switch (responseJSON.response.type) { + case "Forwarder": + case "Catalog": + $("#divZoneTransferAllowOnlyZoneNameServers").hide(); + $("#divZoneTransferAllowZoneNameServersAndUseSpecifiedNetworkACL").hide(); + break; - $("#tabListZoneOptionsZoneTranfer").show(); - $("#tabListZoneOptionsNotify").show(); - } - else { - $("#tabListZoneOptionsZoneTranfer").hide(); - $("#tabListZoneOptionsNotify").hide(); - } - - if ((responseJSON.response.type == "Primary") || (responseJSON.response.type == "Secondary") || (responseJSON.response.type == "Forwarder")) { - //dynamic update - switch (responseJSON.response.update) { - case "Allow": - $("#rdDynamicUpdateAllow").prop("checked", true); - break; - - case "AllowOnlyZoneNameServers": - $("#rdDynamicUpdateAllowOnlyZoneNameServers").prop("checked", true); - break; - - case "AllowOnlySpecifiedIpAddresses": - $("#rdDynamicUpdateAllowOnlySpecifiedIpAddresses").prop("checked", true); - $("#txtDynamicUpdateIpAddresses").prop("disabled", false); - break; - - case "AllowBothZoneNameServersAndSpecifiedIpAddresses": - $("#rdDynamicUpdateAllowBothZoneNameServersAndSpecifiedIpAddresses").prop("checked", true); - $("#txtDynamicUpdateIpAddresses").prop("disabled", false); - break; - - case "Deny": - default: - $("#rdDynamicUpdateDeny").prop("checked", true); - break; - } - - { - var value = ""; - - for (var i = 0; i < responseJSON.response.updateIpAddresses.length; i++) - value += responseJSON.response.updateIpAddresses[i] + "\r\n"; - - $("#txtDynamicUpdateIpAddresses").val(value); - } - - $("#tbodyDynamicUpdateSecurityPolicy").html(""); - - if ((responseJSON.response.type == "Primary") || (responseJSON.response.type == "Forwarder")) { - zoneOptionsAvailableTsigKeyNames = responseJSON.response.availableTsigKeyNames; - - if (responseJSON.response.updateSecurityPolicies != null) { - for (var i = 0; i < responseJSON.response.updateSecurityPolicies.length; i++) - addZoneOptionsDynamicUpdatesSecurityPolicyRow(i, responseJSON.response.updateSecurityPolicies[i].tsigKeyName, responseJSON.response.updateSecurityPolicies[i].domain, responseJSON.response.updateSecurityPolicies[i].allowedTypes); + default: + $("#divZoneTransferAllowOnlyZoneNameServers").show(); + $("#divZoneTransferAllowZoneNameServersAndUseSpecifiedNetworkACL").show(); + break; } - } - if ((responseJSON.response.type == "Secondary") || (responseJSON.response.type == "Forwarder")) { - $("#divDynamicUpdateAllowOnlyZoneNameServers").hide(); - $("#divDynamicUpdateAllowBothZoneNameServersAndSpecifiedIpAddresses").hide(); - } - else { - $("#divDynamicUpdateAllowOnlyZoneNameServers").show(); - $("#divDynamicUpdateAllowBothZoneNameServersAndSpecifiedIpAddresses").show(); - } + //notify + switch (responseJSON.response.notify) { + case "ZoneNameServers": + $("#rdZoneNotifyZoneNameServers").prop("checked", true); + break; - if (responseJSON.response.type == "Secondary") - $("#divDynamicUpdateSecurityPolicy").hide(); - else - $("#divDynamicUpdateSecurityPolicy").show(); + case "SpecifiedNameServers": + $("#rdZoneNotifySpecifiedNameServers").prop("checked", true); + $("#txtZoneNotifyNameServers").prop("disabled", false); + break; - $("#tabListZoneOptionsUpdate").show(); - } - else { - $("#tabListZoneOptionsUpdate").hide(); - $("#rdDynamicUpdateDeny").prop("checked", true); - $("#txtDynamicUpdateIpAddresses").val(""); - $("#tbodyDynamicUpdateSecurityPolicy").html(""); + 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]; + } + + $("#divZoneOptionsCatalogNotifyFailedNameServers").show(); + $("#lblZoneOptionsCatalogNotifyFailedNameServers").text(value); + + $("#divZoneNotifyFailedNameServers").show(); + $("#lblZoneNotifyFailedNameServers").text(value); + } + else { + $("#divZoneNotifyFailedNameServers").hide(); + } + + switch (responseJSON.response.type) { + case "Forwarder": + case "Catalog": + $("#divZoneNotifyZoneNameServers").hide(); + $("#divZoneNotifyBothZoneAndSpecifiedNameServers").hide(); + break; + + default: + $("#divZoneNotifyZoneNameServers").show(); + $("#divZoneNotifyBothZoneAndSpecifiedNameServers").show(); + break; + } + + switch (responseJSON.response.type) { + case "Primary": + case "Forwarder": + if ((responseJSON.response.catalog == null) || responseJSON.response.overrideCatalogZoneTransfer) { + $("#rdZoneTransferDeny").prop("disabled", false); + $("#rdZoneTransferAllow").prop("disabled", false); + $("#rdZoneTransferAllowOnlyZoneNameServers").prop("disabled", false); + $("#rdZoneTransferUseSpecifiedNetworkACL").prop("disabled", false); + $("#rdZoneTransferAllowZoneNameServersAndUseSpecifiedNetworkACL").prop("disabled", false); + $("#txtZoneOptionsZoneTransferTsigKeyNames").prop("disabled", false); + $("#optZoneOptionsQuickTsigKeyNames").prop("disabled", false); + + $("#tabListZoneOptionsZoneTranfer").show(); + } + else { + $("#tabListZoneOptionsZoneTranfer").hide(); + } + + if ((responseJSON.response.catalog == null) || responseJSON.response.overrideCatalogNotify) + $("#tabListZoneOptionsNotify").show(); + else + $("#tabListZoneOptionsNotify").hide(); + + break; + + case "Secondary": + $("#rdZoneTransferDeny").prop("disabled", responseJSON.response.catalog != null); + $("#rdZoneTransferAllow").prop("disabled", responseJSON.response.catalog != null); + $("#rdZoneTransferAllowOnlyZoneNameServers").prop("disabled", responseJSON.response.catalog != null); + $("#rdZoneTransferUseSpecifiedNetworkACL").prop("disabled", responseJSON.response.catalog != null); + $("#rdZoneTransferAllowZoneNameServersAndUseSpecifiedNetworkACL").prop("disabled", responseJSON.response.catalog != null); + + if (responseJSON.response.catalog != null) + $("#txtZoneTransferNetworkACL").prop("disabled", true); + + $("#txtZoneOptionsZoneTransferTsigKeyNames").prop("disabled", responseJSON.response.catalog != null); + $("#optZoneOptionsQuickTsigKeyNames").prop("disabled", responseJSON.response.catalog != null); + + $("#tabListZoneOptionsZoneTranfer").show(); + $("#tabListZoneOptionsNotify").show(); + break; + + case "Catalog": + $("#rdZoneTransferDeny").prop("disabled", false); + $("#rdZoneTransferAllow").prop("disabled", false); + $("#rdZoneTransferAllowOnlyZoneNameServers").prop("disabled", false); + $("#rdZoneTransferUseSpecifiedNetworkACL").prop("disabled", false); + $("#rdZoneTransferAllowZoneNameServersAndUseSpecifiedNetworkACL").prop("disabled", false); + $("#txtZoneOptionsZoneTransferTsigKeyNames").prop("disabled", false); + $("#optZoneOptionsQuickTsigKeyNames").prop("disabled", false); + + $("#tabListZoneOptionsZoneTranfer").show(); + $("#tabListZoneOptionsNotify").show(); + break; + } + + break; + + default: + $("#tabListZoneOptionsZoneTranfer").hide(); + $("#tabListZoneOptionsNotify").hide(); + break; } - if (responseJSON.response.type == "Forwarder") { - $("#tabListZoneOptionsZoneTranfer").removeClass("active"); - $("#tabPaneZoneOptionsZoneTransfer").removeClass("active"); - $("#tabListZoneOptionsNotify").removeClass("active"); - $("#tabPaneZoneOptionsNotify").removeClass("active"); - $("#tabListZoneOptionsUpdate").addClass("active"); - $("#tabPaneZoneOptionsUpdate").addClass("active"); + //dynamic update + switch (responseJSON.response.type) { + case "Primary": + case "Secondary": + case "SecondaryForwarder": + case "Forwarder": + //dynamic update + switch (responseJSON.response.update) { + case "Allow": + $("#rdDynamicUpdateAllow").prop("checked", true); + break; + + case "AllowOnlyZoneNameServers": + $("#rdDynamicUpdateAllowOnlyZoneNameServers").prop("checked", true); + break; + + case "UseSpecifiedNetworkACL": + $("#rdDynamicUpdateUseSpecifiedNetworkACL").prop("checked", true); + $("#txtDynamicUpdateNetworkACL").prop("disabled", false); + break; + + case "AllowZoneNameServersAndUseSpecifiedNetworkACL": + $("#rdDynamicUpdateAllowZoneNameServersAndUseSpecifiedNetworkACL").prop("checked", true); + $("#txtDynamicUpdateNetworkACL").prop("disabled", false); + break; + + case "Deny": + default: + $("#rdDynamicUpdateDeny").prop("checked", true); + break; + } + + { + var value = ""; + + for (var i = 0; i < responseJSON.response.updateNetworkACL.length; i++) + value += responseJSON.response.updateNetworkACL[i] + "\r\n"; + + $("#txtDynamicUpdateNetworkACL").val(value); + } + + $("#tbodyDynamicUpdateSecurityPolicy").html(""); + + switch (responseJSON.response.type) { + case "Primary": + case "Forwarder": + zoneOptionsAvailableTsigKeyNames = responseJSON.response.availableTsigKeyNames; + + if (responseJSON.response.updateSecurityPolicies != null) { + for (var i = 0; i < responseJSON.response.updateSecurityPolicies.length; i++) + addZoneOptionsDynamicUpdatesSecurityPolicyRow(i, responseJSON.response.updateSecurityPolicies[i].tsigKeyName, responseJSON.response.updateSecurityPolicies[i].domain, responseJSON.response.updateSecurityPolicies[i].allowedTypes); + } + + $("#divDynamicUpdateSecurityPolicy").show(); + break; + + default: + $("#divDynamicUpdateSecurityPolicy").hide(); + break; + } + + switch (responseJSON.response.type) { + case "Secondary": + case "SecondaryForwarder": + case "Forwarder": + $("#divDynamicUpdateAllowOnlyZoneNameServers").hide(); + $("#divDynamicUpdateAllowZoneNameServersAndUseSpecifiedNetworkACL").hide(); + break; + + default: + $("#divDynamicUpdateAllowOnlyZoneNameServers").show(); + $("#divDynamicUpdateAllowZoneNameServersAndUseSpecifiedNetworkACL").show(); + break; + } + + $("#tabListZoneOptionsUpdate").show(); + break; + + default: + $("#tabListZoneOptionsUpdate").hide(); + break; } - else { - $("#tabListZoneOptionsZoneTranfer").addClass("active"); - $("#tabPaneZoneOptionsZoneTransfer").addClass("active"); - $("#tabListZoneOptionsNotify").removeClass("active"); - $("#tabPaneZoneOptionsNotify").removeClass("active"); - $("#tabListZoneOptionsUpdate").removeClass("active"); - $("#tabPaneZoneOptionsUpdate").removeClass("active"); + + //tab focus + switch (responseJSON.response.type) { + case "Secondary": + case "SecondaryForwarder": + case "SecondaryCatalog": + case "Stub": + $("#tabListZoneOptionsGeneral").addClass("active"); + $("#tabPaneZoneOptionsGeneral").addClass("active"); + $("#tabListZoneOptionsQueryAccess").removeClass("active"); + $("#tabPaneZoneOptionsQueryAccess").removeClass("active"); + $("#tabListZoneOptionsZoneTranfer").removeClass("active"); + $("#tabPaneZoneOptionsZoneTransfer").removeClass("active"); + $("#tabListZoneOptionsNotify").removeClass("active"); + $("#tabPaneZoneOptionsNotify").removeClass("active"); + $("#tabListZoneOptionsUpdate").removeClass("active"); + $("#tabPaneZoneOptionsUpdate").removeClass("active"); + break; + + case "Catalog": + $("#tabListZoneOptionsGeneral").removeClass("active"); + $("#tabPaneZoneOptionsGeneral").removeClass("active"); + $("#tabListZoneOptionsQueryAccess").addClass("active"); + $("#tabPaneZoneOptionsQueryAccess").addClass("active"); + $("#tabListZoneOptionsZoneTranfer").removeClass("active"); + $("#tabPaneZoneOptionsZoneTransfer").removeClass("active"); + $("#tabListZoneOptionsNotify").removeClass("active"); + $("#tabPaneZoneOptionsNotify").removeClass("active"); + $("#tabListZoneOptionsUpdate").removeClass("active"); + $("#tabPaneZoneOptionsUpdate").removeClass("active"); + break; + + case "Primary": + case "Forwarder": + if (responseJSON.response.availableCatalogZoneNames.length > 0) { + $("#tabListZoneOptionsGeneral").addClass("active"); + $("#tabPaneZoneOptionsGeneral").addClass("active"); + $("#tabListZoneOptionsQueryAccess").removeClass("active"); + $("#tabPaneZoneOptionsQueryAccess").removeClass("active"); + $("#tabListZoneOptionsZoneTranfer").removeClass("active"); + $("#tabPaneZoneOptionsZoneTransfer").removeClass("active"); + $("#tabListZoneOptionsNotify").removeClass("active"); + $("#tabPaneZoneOptionsNotify").removeClass("active"); + $("#tabListZoneOptionsUpdate").removeClass("active"); + $("#tabPaneZoneOptionsUpdate").removeClass("active"); + } + else { + $("#tabListZoneOptionsGeneral").removeClass("active"); + $("#tabPaneZoneOptionsGeneral").removeClass("active"); + $("#tabListZoneOptionsQueryAccess").addClass("active"); + $("#tabPaneZoneOptionsQueryAccess").addClass("active"); + $("#tabListZoneOptionsZoneTranfer").removeClass("active"); + $("#tabPaneZoneOptionsZoneTransfer").removeClass("active"); + $("#tabListZoneOptionsNotify").removeClass("active"); + $("#tabPaneZoneOptionsNotify").removeClass("active"); + $("#tabListZoneOptionsUpdate").removeClass("active"); + $("#tabPaneZoneOptionsUpdate").removeClass("active"); + } + break; } divZoneOptionsLoader.hide(); @@ -1197,16 +1824,50 @@ function saveZoneOptions() { var divZoneOptionsAlert = $("#divZoneOptionsAlert"); var divZoneOptionsLoader = $("#divZoneOptionsLoader"); var zone = $("#lblZoneOptionsZoneName").attr("data-zone"); + var zoneType = $("#lblZoneOptionsZoneName").attr("data-zone-type"); + + //general catalog zone name + var catalog = $("#optZoneOptionsCatalogZoneName").val(); + if (catalog == null) + catalog = ""; + + var overrideCatalogQueryAccess = $("#chkZoneOptionsCatalogOverrideQueryAccess").prop("checked"); + var overrideCatalogZoneTransfer = $("#chkZoneOptionsCatalogOverrideZoneTransfer").prop("checked"); + var overrideCatalogNotify = $("#chkZoneOptionsCatalogOverrideNotify").prop("checked"); + + //general primary name server for secondary & stub + var primaryNameServerAddresses = cleanTextList($("#txtZoneOptionsPrimaryNameServerAddresses").val()); + + switch (zoneType) { + case "SecondaryForwarder": + case "SecondaryCatalog": + if ((primaryNameServerAddresses.length === 0) || (primaryNameServerAddresses === ",")) { + showAlert("warning", "Missing!", "Please enter at least one primary name server address to proceed.", divZoneOptionsAlert); + $("#txtZoneOptionsPrimaryNameServerAddresses").focus(); + return; + } + + break; + } + + var primaryZoneTransferProtocol = $("input[name=rdPrimaryZoneTransferProtocol]:checked").val(); + var primaryZoneTransferTsigKeyName = $("#optZoneOptionsPrimaryZoneTransferTsigKeyName").val(); + var validateZone = $("#chkZoneOptionsValidateZone").prop("checked"); + + //query access + var queryAccess = $("input[name=rdQueryAccess]:checked").val(); + + var queryAccessNetworkACL = cleanTextList($("#txtQueryAccessNetworkACL").val()); //zone transfer var zoneTransfer = $("input[name=rdZoneTransfer]:checked").val(); - var zoneTransferNameServers = cleanTextList($("#txtZoneTransferNameServers").val()); + var zoneTransferNetworkACL = cleanTextList($("#txtZoneTransferNetworkACL").val()); - if ((zoneTransferNameServers.length === 0) || (zoneTransferNameServers === ",")) - zoneTransferNameServers = false; + if ((zoneTransferNetworkACL.length === 0) || (zoneTransferNetworkACL === ",")) + zoneTransferNetworkACL = false; else - $("#txtZoneTransferNameServers").val(zoneTransferNameServers.replace(/,/g, "\n")); + $("#txtZoneTransferNetworkACL").val(zoneTransferNetworkACL.replace(/,/g, "\n")); var zoneTransferTsigKeyNames = cleanTextList($("#txtZoneOptionsZoneTransferTsigKeyNames").val()); @@ -1228,12 +1889,12 @@ function saveZoneOptions() { //dynamic update var update = $("input[name=rdDynamicUpdate]:checked").val(); - var updateIpAddresses = cleanTextList($("#txtDynamicUpdateIpAddresses").val()); + var updateNetworkACL = cleanTextList($("#txtDynamicUpdateNetworkACL").val()); - if ((updateIpAddresses.length === 0) || (updateIpAddresses === ",")) - updateIpAddresses = false; + if ((updateNetworkACL.length === 0) || (updateNetworkACL === ",")) + updateNetworkACL = false; else - $("#txtDynamicUpdateIpAddresses").val(updateIpAddresses.replace(/,/g, "\n")); + $("#txtDynamicUpdateNetworkACL").val(updateNetworkACL.replace(/,/g, "\n")); var updateSecurityPolicies = serializeTableData($("#tableDynamicUpdateSecurityPolicy"), 3, divZoneOptionsAlert); if (updateSecurityPolicies === false) @@ -1247,13 +1908,37 @@ function saveZoneOptions() { HTTPRequest({ url: "/api/zones/options/set?token=" + sessionData.token + "&zone=" + zone - + "&zoneTransfer=" + zoneTransfer + "&zoneTransferNameServers=" + encodeURIComponent(zoneTransferNameServers) + "&zoneTransferTsigKeyNames=" + encodeURIComponent(zoneTransferTsigKeyNames) + + "&catalog=" + encodeURIComponent(catalog) + "&overrideCatalogQueryAccess=" + overrideCatalogQueryAccess + "&overrideCatalogZoneTransfer=" + overrideCatalogZoneTransfer + "&overrideCatalogNotify=" + overrideCatalogNotify + + "&primaryNameServerAddresses=" + encodeURIComponent(primaryNameServerAddresses) + "&primaryZoneTransferProtocol=" + primaryZoneTransferProtocol + "&primaryZoneTransferTsigKeyName=" + encodeURIComponent(primaryZoneTransferTsigKeyName) + "&validateZone=" + validateZone + + "&queryAccess=" + queryAccess + "&queryAccessNetworkACL=" + encodeURIComponent(queryAccessNetworkACL) + + "&zoneTransfer=" + zoneTransfer + "&zoneTransferNetworkACL=" + encodeURIComponent(zoneTransferNetworkACL) + "&zoneTransferTsigKeyNames=" + encodeURIComponent(zoneTransferTsigKeyNames) + "¬ify=" + notify + "¬ifyNameServers=" + encodeURIComponent(notifyNameServers) - + "&update=" + update + "&updateIpAddresses=" + encodeURIComponent(updateIpAddresses) + "&updateSecurityPolicies=" + encodeURIComponent(updateSecurityPolicies), + + "&update=" + update + "&updateNetworkACL=" + encodeURIComponent(updateNetworkACL) + "&updateSecurityPolicies=" + encodeURIComponent(updateSecurityPolicies), success: function (responseJSON) { btn.button("reset"); $("#modalZoneOptions").modal("hide"); + switch (zoneType) { + case "Catalog": + case "SecondaryCatalog": + $("#titleEditZoneCatalog").attr("class", "label label-info"); + $("#titleEditZoneCatalog").text(zone); + $("#titleEditZoneCatalog").show(); + break; + + default: + if ((catalog == null) || (catalog == "")) { + $("#titleEditZoneCatalog").hide(); + } + else { + $("#titleEditZoneCatalog").attr("class", "label label-default"); + $("#titleEditZoneCatalog").text(catalog); + $("#titleEditZoneCatalog").show(); + } + + break; + } + showAlert("success", "Options Saved!", "Zone options were saved successfully."); }, error: function () { @@ -1445,6 +2130,7 @@ function showAddZoneModal() { $("#txtAddZone").val(""); $("#rdAddZoneTypePrimary").prop("checked", true); + $("#divAddZoneCatalogZone").hide(); $("#chkAddZoneUseSoaSerialDateScheme").prop("checked", $("#chkUseSoaSerialDateScheme").prop("checked")); $("#txtAddZonePrimaryNameServerAddresses").val(""); $("#rdAddZoneZoneTransferProtocolTcp").prop("checked", true); @@ -1484,6 +2170,59 @@ function showAddZoneModal() { setTimeout(function () { $("#txtAddZone").focus(); }, 1000); + + loadCatalogZoneNames($("#optAddZoneCatalogZoneName"), null, $("#divAddZoneAlert"), $("#divAddZoneCatalogZone")); +} + +function loadCatalogZoneNames(jqDropDown, currentValue, divAlertPlaceholder, divCatalogZone) { + jqDropDown.prop("disabled", true); + jqDropDown.attr("hasItems", false); + + if (currentValue == null) + currentValue = ""; + + if (currentValue.length == 0) { + jqDropDown.html(""); + } + else { + jqDropDown.html(""); + jqDropDown.val(currentValue); + } + + HTTPRequest({ + url: "/api/zones/catalogs/list?token=" + sessionData.token, + success: function (responseJSON) { + loadCatalogZoneNamesFrom(responseJSON.response.catalogZoneNames, jqDropDown, currentValue); + + if ((divCatalogZone != null) && (responseJSON.response.catalogZoneNames.length > 0)) + divCatalogZone.show(); + }, + error: function () { + jqDropDown.prop("disabled", false); + }, + invalidToken: function () { + jqDropDown.prop("disabled", false); + showPageLogin(); + }, + objAlertPlaceholder: divAlertPlaceholder + }); +} + +function loadCatalogZoneNamesFrom(catalogZoneNames, jqDropDown, currentValue) { + var optionsHtml; + + if ((currentValue == null) || (currentValue.length == 0)) + optionsHtml = ""; + else + optionsHtml = ""; + + for (var i = 0; i < catalogZoneNames.length; i++) { + optionsHtml += "" + htmlEncode(catalogZoneNames[i]) + ""; + } + + jqDropDown.html(optionsHtml); + jqDropDown.prop("disabled", false); + jqDropDown.attr("hasItems", catalogZoneNames.length > 0); } function loadTsigKeyNames(jqDropDown, currentValue, divAlertPlaceholder) { @@ -1503,19 +2242,7 @@ function loadTsigKeyNames(jqDropDown, currentValue, divAlertPlaceholder) { HTTPRequest({ url: "/api/settings/getTsigKeyNames?token=" + sessionData.token, success: function (responseJSON) { - var optionsHtml; - - if (currentValue.length == 0) - optionsHtml = ""; - else - optionsHtml = ""; - - for (var i = 0; i < responseJSON.response.tsigKeyNames.length; i++) { - optionsHtml += "" + htmlEncode(responseJSON.response.tsigKeyNames[i]) + ""; - } - - jqDropDown.html(optionsHtml); - jqDropDown.prop("disabled", false); + loadTsigKeyNamesFrom(responseJSON.response.tsigKeyNames, jqDropDown, currentValue); }, error: function () { jqDropDown.prop("disabled", false); @@ -1528,6 +2255,22 @@ function loadTsigKeyNames(jqDropDown, currentValue, divAlertPlaceholder) { }); } +function loadTsigKeyNamesFrom(tsigKeyNames, jqDropDown, currentValue) { + var optionsHtml; + + if ((currentValue == null) || (currentValue.length == 0)) + optionsHtml = ""; + else + optionsHtml = ""; + + for (var i = 0; i < tsigKeyNames.length; i++) { + optionsHtml += "" + htmlEncode(tsigKeyNames[i]) + ""; + } + + jqDropDown.html(optionsHtml); + jqDropDown.prop("disabled", false); +} + function updateAddZoneFormForwarderThisServer() { var useThisServer = $("#chkAddZoneForwarderThisServer").prop('checked'); @@ -1567,36 +2310,39 @@ function addZone() { switch (type) { case "Primary": + var catalog = $("#optAddZoneCatalogZoneName").val(); var useSoaSerialDateScheme = $("#chkAddZoneUseSoaSerialDateScheme").prop("checked"); - parameters = "&useSoaSerialDateScheme=" + useSoaSerialDateScheme; + parameters = "&catalog=" + catalog + "&useSoaSerialDateScheme=" + useSoaSerialDateScheme; break; case "Secondary": - var tsigKeyName = $("#optAddZoneTsigKeyName").val(); - var validateZone = $("#chkAddZoneValidateZone").prop("checked"); - parameters = "&primaryNameServerAddresses=" + encodeURIComponent(cleanTextList($("#txtAddZonePrimaryNameServerAddresses").val())); parameters += "&zoneTransferProtocol=" + $("input[name=rdAddZoneZoneTransferProtocol]:checked").val(); - parameters += "&tsigKeyName=" + encodeURIComponent(tsigKeyName); - parameters += "&validateZone=" + validateZone; + parameters += "&tsigKeyName=" + encodeURIComponent($("#optAddZoneTsigKeyName").val()); + parameters += "&validateZone=" + $("#chkAddZoneValidateZone").prop("checked"); break; case "Stub": - parameters = "&primaryNameServerAddresses=" + encodeURIComponent(cleanTextList($("#txtAddZonePrimaryNameServerAddresses").val())); + var catalog = $("#optAddZoneCatalogZoneName").val(); + + parameters = "&catalog=" + catalog + "&primaryNameServerAddresses=" + encodeURIComponent(cleanTextList($("#txtAddZonePrimaryNameServerAddresses").val())); break; case "Forwarder": + var catalog = $("#optAddZoneCatalogZoneName").val(); + var protocol = $("input[name=rdAddZoneForwarderProtocol]:checked").val(); + var forwarder = $("#txtAddZoneForwarder").val(); if ((forwarder == null) || (forwarder === "")) { - showAlert("warning", "Missing!", "Please enter a forwarder server name to add zone.", divAddZoneAlert); + showAlert("warning", "Missing!", "Please enter a forwarder server address to add zone.", divAddZoneAlert); $("#txtAddZoneForwarder").focus(); return; } var dnssecValidation = $("#chkAddZoneForwarderDnssecValidation").prop("checked"); - parameters = "&protocol=" + $("input[name=rdAddZoneForwarderProtocol]:checked").val() + "&forwarder=" + encodeURIComponent(forwarder) + "&dnssecValidation=" + dnssecValidation; + parameters = "&catalog=" + catalog + "&protocol=" + protocol + "&forwarder=" + encodeURIComponent(forwarder) + "&dnssecValidation=" + dnssecValidation; if (forwarder !== "this-server") { var proxyType = $("input[name=rdAddZoneForwarderProxyType]:checked").val(); @@ -1629,6 +2375,20 @@ function addZone() { } break; + case "SecondaryForwarder": + case "SecondaryCatalog": + var primaryNameServerAddresses = cleanTextList($("#txtAddZonePrimaryNameServerAddresses").val()); + if ((primaryNameServerAddresses.length === 0) || (primaryNameServerAddresses === ",")) { + showAlert("warning", "Missing!", "Please enter at least one primary name server address to proceed.", divAddZoneAlert); + $("#txtAddZonePrimaryNameServerAddresses").focus(); + return; + } + + parameters = "&primaryNameServerAddresses=" + encodeURIComponent(primaryNameServerAddresses); + parameters += "&zoneTransferProtocol=" + $("input[name=rdAddZoneZoneTransferProtocol]:checked").val(); + parameters += "&tsigKeyName=" + encodeURIComponent($("#optAddZoneTsigKeyName").val()); + break; + default: parameters = ""; break; @@ -1697,11 +2457,11 @@ function showEditZone(zone, showPageNumber) { switch (responseJSON.response.zone.dnssecStatus) { case "SignedWithNSEC": case "SignedWithNSEC3": - $("#titleDnssecStatusEditZone").show(); + $("#titleEditZoneDnssecStatus").show(); break; default: - $("#titleDnssecStatusEditZone").hide(); + $("#titleEditZoneDnssecStatus").hide(); break; } @@ -1719,14 +2479,47 @@ function showEditZone(zone, showPageNumber) { else status = "Enabled"; + if (responseJSON.response.zone.catalog != null) { + $("#titleEditZoneCatalog").attr("class", "label label-default"); + $("#titleEditZoneCatalog").text(responseJSON.response.zone.catalog); + $("#titleEditZoneCatalog").show(); + } + else { + switch (zoneType) { + case "Catalog": + case "SecondaryCatalog": + $("#titleEditZoneCatalog").attr("class", "label label-info"); + $("#titleEditZoneCatalog").text(zone); + $("#titleEditZoneCatalog").show(); + break; + + default: + $("#titleEditZoneCatalog").hide(); + break; + } + } + var expiry = responseJSON.response.zone.expiry; if (expiry == null) expiry = " "; else expiry = "Expiry: " + moment(expiry).local().format("YYYY-MM-DD HH:mm:ss"); - $("#titleEditZoneType").html(zoneType); - $("#titleStatusEditZone").html(status); + switch (zoneType) { + case "SecondaryForwarder": + $("#titleEditZoneType").html("Secondary Forwarder"); + break; + + case "SecondaryCatalog": + $("#titleEditZoneType").html("Secondary Catalog"); + break; + + default: + $("#titleEditZoneType").html(zoneType); + break; + } + + $("#titleEditZoneStatus").html(status); $("#titleEditZoneExpiry").html(expiry); if (responseJSON.response.zone.internal) @@ -1738,23 +2531,26 @@ function showEditZone(zone, showPageNumber) { case "Disabled": case "Sync Failed": case "Notify Failed": - $("#titleStatusEditZone").attr("class", "label label-warning"); + $("#titleEditZoneStatus").attr("class", "label label-warning"); break; case "Expired": case "Validation Failed": - $("#titleStatusEditZone").attr("class", "label label-danger"); + $("#titleEditZoneStatus").attr("class", "label label-danger"); break; default: - $("#titleStatusEditZone").attr("class", "label label-success"); + $("#titleEditZoneStatus").attr("class", "label label-success"); break; } switch (zoneType) { case "Internal": case "Secondary": + case "SecondaryForwarder": + case "SecondaryCatalog": case "Stub": + case "Catalog": $("#btnEditZoneAddRecord").hide(); break; @@ -1811,6 +2607,8 @@ function showEditZone(zone, showPageNumber) { switch (zoneType) { case "Secondary": + case "SecondaryForwarder": + case "SecondaryCatalog": case "Stub": $("#btnZoneResync").show(); break; @@ -1823,7 +2621,11 @@ function showEditZone(zone, showPageNumber) { switch (zoneType) { case "Primary": case "Secondary": + case "SecondaryForwarder": + case "SecondaryCatalog": + case "Stub": case "Forwarder": + case "Catalog": $("#divOptionsMenu").show(); break; @@ -1840,6 +2642,9 @@ function showEditZone(zone, showPageNumber) { break; case "Secondary": + case "SecondaryForwarder": + case "SecondaryCatalog": + case "Catalog": $("#lnkImportZone").hide(); $("#lnkExportZone").show(); break; @@ -1853,6 +2658,7 @@ function showEditZone(zone, showPageNumber) { switch (zoneType) { case "Primary": case "Secondary": + case "SecondaryForwarder": case "Forwarder": $("#lnkZoneConvert").show(); break; @@ -1865,7 +2671,11 @@ function showEditZone(zone, showPageNumber) { switch (zoneType) { case "Primary": case "Secondary": + case "SecondaryForwarder": + case "SecondaryCatalog": + case "Stub": case "Forwarder": + case "Catalog": $("#lnkZoneOptions").show(); break; @@ -1877,8 +2687,11 @@ function showEditZone(zone, showPageNumber) { switch (zoneType) { case "Primary": case "Secondary": + case "SecondaryForwarder": + case "SecondaryCatalog": case "Stub": case "Forwarder": + case "Catalog": $("#btnZonePermissions").show(); break; @@ -2086,11 +2899,11 @@ function showEditZonePage(pageNumber) { } function getZoneRecordRowHtml(index, zone, zoneType, record) { - var name = record.name.toLowerCase(); + var name = record.name; if (name === "") name = "."; - if (name === zone) + if (name.toLowerCase() === zone) name = "@"; else name = name.replace("." + zone, ""); @@ -2099,26 +2912,15 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { tableHtmlRow += "" + record.type + ""; tableHtmlRow += "" + record.ttl + ""; - var lastUsedOn; - - if (record.lastUsedOn == "0001-01-01T00:00:00") - lastUsedOn = moment(record.lastUsedOn).local().format("YYYY-MM-DD HH:mm:ss") + " (never)"; - else - lastUsedOn = moment(record.lastUsedOn).local().format("YYYY-MM-DD HH:mm:ss") + " (" + moment(record.lastUsedOn).fromNow() + ")"; - var additionalDataAttributes = ""; + tableHtmlRow += ""; + switch (record.type.toUpperCase()) { case "A": case "AAAA": - tableHtmlRow += "" + htmlEncode(record.rData.ipAddress); - - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += htmlEncode(record.rData.ipAddress); + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-ip-address=\"" + htmlEncode(record.rData.ipAddress) + "\" "; break; @@ -2135,7 +2937,7 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { } } - tableHtmlRow += "Name Server: " + htmlEncode(record.rData.nameServer); + tableHtmlRow += "Name Server: " + htmlEncode(record.rData.nameServer); if (notifyFailed) tableHtmlRow += "Notify Failed"; @@ -2157,31 +2959,20 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { additionalDataAttributes = "data-record-glue=\"\" "; } - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes += "data-record-name-server=\"" + htmlEncode(record.rData.nameServer) + "\" "; break; case "CNAME": - tableHtmlRow += "" + htmlEncode(record.rData.cname); - - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += htmlEncode(record.rData.cname); + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-cname=\"" + htmlEncode(record.rData.cname) + "\" "; break; case "SOA": - tableHtmlRow += "Primary Name Server: " + htmlEncode(record.rData.primaryNameServer) + + tableHtmlRow += "Primary Name Server: " + htmlEncode(record.rData.primaryNameServer) + "
    Responsible Person: " + htmlEncode(record.rData.responsiblePerson) + "
    Serial: " + htmlEncode(record.rData.serial) + "
    Refresh: " + htmlEncode(record.rData.refresh) + @@ -2198,45 +2989,7 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { additionalDataAttributes = "data-record-serial-scheme=\"false\" "; } - if (record.rData.primaryAddresses != null) { - tableHtmlRow += "

    Primary Name Server Addresses: " + record.rData.primaryAddresses; - - additionalDataAttributes += "data-record-paddresses=\"" + htmlEncode(record.rData.primaryAddresses) + "\" "; - } else { - additionalDataAttributes += "data-record-paddresses=\"\" "; - } - - if (record.rData.zoneTransferProtocol != null) { - tableHtmlRow += "
    Zone Transfer Protocol: XFR-over-" + record.rData.zoneTransferProtocol.toUpperCase(); - - additionalDataAttributes += "data-record-zonetransferprotocol=\"" + htmlEncode(record.rData.zoneTransferProtocol) + "\" "; - } else { - additionalDataAttributes += "data-record-zonetransferprotocol=\"\" "; - } - - if (record.rData.tsigKeyName != null) { - tableHtmlRow += "
    TSIG Key Name: " + record.rData.tsigKeyName; - - additionalDataAttributes += "data-record-tsigkeyname=\"" + htmlEncode(record.rData.tsigKeyName) + "\" "; - } else { - additionalDataAttributes += "data-record-tsigkeyname=\"\" "; - } - - if (record.rData.validateZone != null) { - tableHtmlRow += "
    Use ZONEMD to Validate Zone: " + record.rData.validateZone; - - additionalDataAttributes += "data-record-validate-zone=\"" + htmlEncode(record.rData.validateZone) + "\" "; - } - else { - additionalDataAttributes += "data-record-validate-zone=\"false\" "; - } - - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes += "data-record-pname=\"" + htmlEncode(record.rData.primaryNameServer) + "\" " + "data-record-rperson=\"" + htmlEncode(record.rData.responsiblePerson) + "\" " + @@ -2248,36 +3001,23 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { break; case "PTR": - tableHtmlRow += "" + htmlEncode(record.rData.ptrName); - - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += htmlEncode(record.rData.ptrName); + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-ptr-name=\"" + htmlEncode(record.rData.ptrName) + "\" "; break; case "MX": - tableHtmlRow += "Preference: " + htmlEncode(record.rData.preference) + + tableHtmlRow += "Preference: " + htmlEncode(record.rData.preference) + "
    Exchange: " + htmlEncode(record.rData.exchange); - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-preference=\"" + htmlEncode(record.rData.preference) + "\" " + "data-record-exchange=\"" + htmlEncode(record.rData.exchange) + "\" "; break; case "TXT": - tableHtmlRow += ""; - var text; if (record.rData.splitText) { @@ -2299,29 +3039,29 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { text = record.rData.text; } - tableHtmlRow += "
    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "
    "; additionalDataAttributes = "data-record-text=\"" + htmlEncode(text) + "\" " + "data-record-split-text=\"" + htmlEncode(record.rData.splitText) + "\" "; break; + case "RP": + tableHtmlRow += "Mailbox: " + htmlEncode(record.rData.mailbox) + + "
    TXT Domain: " + htmlEncode(record.rData.txtDomain); + + tableHtmlRow += "

    "; + + additionalDataAttributes = "data-record-mailbox=\"" + htmlEncode(record.rData.mailbox) + "\" " + + "data-record-txt-domain=\"" + htmlEncode(record.rData.txtDomain) + "\" "; + break; + case "SRV": - tableHtmlRow += "Priority: " + htmlEncode(record.rData.priority) + + tableHtmlRow += "Priority: " + htmlEncode(record.rData.priority) + "
    Weight: " + htmlEncode(record.rData.weight) + "
    Port: " + htmlEncode(record.rData.port) + "
    Target: " + htmlEncode(record.rData.target); - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-priority=\"" + htmlEncode(record.rData.priority) + "\" " + "data-record-weight=\"" + htmlEncode(record.rData.weight) + "\" " + @@ -2330,19 +3070,14 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { break; case "NAPTR": - tableHtmlRow += "Order: " + htmlEncode(record.rData.order) + + tableHtmlRow += "Order: " + htmlEncode(record.rData.order) + "
    Preference: " + htmlEncode(record.rData.preference) + "
    Flags: " + htmlEncode(record.rData.flags) + "
    Services: " + htmlEncode(record.rData.services) + "
    Regular Expression: " + htmlEncode(record.rData.regexp) + "
    Replacement: " + htmlEncode(record.rData.replacement); - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-order=\"" + htmlEncode(record.rData.order) + "\" " + "data-record-preference=\"" + htmlEncode(record.rData.preference) + "\" " + @@ -2353,30 +3088,34 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { break; case "DNAME": - tableHtmlRow += "" + htmlEncode(record.rData.dname); - - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += htmlEncode(record.rData.dname); + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-dname=\"" + htmlEncode(record.rData.dname) + "\" "; break; + case "APL": + tableHtmlRow += ""; + + for (var i = 0; i < record.rData.addressPrefixes.length; i++) { + tableHtmlRow += ""; + tableHtmlRow += ""; + tableHtmlRow += ""; + tableHtmlRow += ""; + } + + tableHtmlRow += "
    FamilyNegationAFD PartPrefix
    " + record.rData.addressPrefixes[i].addressFamily + "" + record.rData.addressPrefixes[i].negation + "" + record.rData.addressPrefixes[i].afdPart + "" + record.rData.addressPrefixes[i].prefix + "
    "; + + additionalDataAttributes = ""; + break; + case "DS": - tableHtmlRow += "Key Tag: " + htmlEncode(record.rData.keyTag) + + tableHtmlRow += "Key Tag: " + htmlEncode(record.rData.keyTag) + "
    Algorithm: " + htmlEncode(record.rData.algorithm) + "
    Digest Type: " + htmlEncode(record.rData.digestType) + "
    Digest: " + htmlEncode(record.rData.digest); - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-key-tag=\"" + htmlEncode(record.rData.keyTag) + "\" " + "data-record-algorithm=\"" + htmlEncode(record.rData.algorithm) + "\" " + @@ -2385,16 +3124,11 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { break; case "SSHFP": - tableHtmlRow += "Algorithm: " + htmlEncode(record.rData.algorithm) + + tableHtmlRow += "Algorithm: " + htmlEncode(record.rData.algorithm) + "
    Fingerprint Type: " + htmlEncode(record.rData.fingerprintType) + "
    Fingerprint: " + htmlEncode(record.rData.fingerprint); - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-algorithm=\"" + htmlEncode(record.rData.algorithm) + "\" " + "data-record-fingerprint-type=\"" + htmlEncode(record.rData.fingerprintType) + "\" " + @@ -2402,7 +3136,7 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { break; case "RRSIG": - tableHtmlRow += "Type Covered: " + htmlEncode(record.rData.typeCovered) + + tableHtmlRow += "Type Covered: " + htmlEncode(record.rData.typeCovered) + "
    Algorithm: " + htmlEncode(record.rData.algorithm) + "
    Labels: " + htmlEncode(record.rData.labels) + "
    Original TTL: " + htmlEncode(record.rData.originalTtl) + @@ -2412,12 +3146,7 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { "
    Signer's Name: " + htmlEncode(record.rData.signersName) + "
    Signature: " + htmlEncode(record.rData.signature); - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = ""; break; @@ -2432,21 +3161,16 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { nsecTypes += ", " + record.rData.types[j]; } - tableHtmlRow += "Next Domain Name: " + htmlEncode(record.rData.nextDomainName) + + tableHtmlRow += "Next Domain Name: " + htmlEncode(record.rData.nextDomainName) + "
    Types: " + htmlEncode(nsecTypes); - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = ""; break; case "DNSKEY": - tableHtmlRow += "Flags: " + htmlEncode(record.rData.flags) + + tableHtmlRow += "Flags: " + htmlEncode(record.rData.flags) + "
    Protocol: " + htmlEncode(record.rData.protocol) + "
    Algorithm: " + htmlEncode(record.rData.algorithm) + "
    Public Key: " + htmlEncode(record.rData.publicKey); @@ -2471,12 +3195,7 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { } } - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = ""; break; @@ -2491,51 +3210,36 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { nsec3Types += ", " + record.rData.types[j]; } - tableHtmlRow += "Hash Algorithm: " + htmlEncode(record.rData.hashAlgorithm) + + tableHtmlRow += "Hash Algorithm: " + htmlEncode(record.rData.hashAlgorithm) + "
    Flags: " + htmlEncode(record.rData.flags) + "
    Iterations: " + htmlEncode(record.rData.iterations) + "
    Salt: " + htmlEncode(record.rData.salt) + "
    Next Hashed Owner Name: " + htmlEncode(record.rData.nextHashedOwnerName) + "
    Types: " + htmlEncode(nsec3Types); - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = ""; break; case "NSEC3PARAM": - tableHtmlRow += "Hash Algorithm: " + htmlEncode(record.rData.hashAlgorithm) + + tableHtmlRow += "Hash Algorithm: " + htmlEncode(record.rData.hashAlgorithm) + "
    Flags: " + htmlEncode(record.rData.flags) + "
    Iterations: " + htmlEncode(record.rData.iterations) + "
    Salt: " + htmlEncode(record.rData.salt); - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = ""; break; case "TLSA": - tableHtmlRow += "Certificate Usage: " + htmlEncode(record.rData.certificateUsage) + + tableHtmlRow += "Certificate Usage: " + htmlEncode(record.rData.certificateUsage) + "
    Selector: " + htmlEncode(record.rData.selector) + "
    Matching Type: " + htmlEncode(record.rData.matchingType) + "
    Certificate Association Data: " + (record.rData.certificateAssociationData == "" ? "
    " : "
    " + htmlEncode(record.rData.certificateAssociationData) + "
    "); - tableHtmlRow += "
    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "
    "; additionalDataAttributes = "data-record-certificate-usage=\"" + htmlEncode(record.rData.certificateUsage) + "\" " + "data-record-selector=\"" + htmlEncode(record.rData.selector) + "\" " + @@ -2544,13 +3248,12 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { break; case "ZONEMD": - tableHtmlRow += "Serial: " + htmlEncode(record.rData.serial) + + tableHtmlRow += "Serial: " + htmlEncode(record.rData.serial) + "
    Scheme: " + htmlEncode(record.rData.scheme) + "
    Hash Algorithm: " + htmlEncode(record.rData.hashAlgorithm) + "
    Digest: " + record.rData.digest; - tableHtmlRow += "

    Last Used: " + lastUsedOn; - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = ""; break; @@ -2591,19 +3294,14 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { tableHtmlSvcParams += ""; } - tableHtmlRow += "Priority: " + htmlEncode(record.rData.svcPriority) + (record.rData.svcPriority == 0 ? " (alias mode)" : " (service mode)") + + tableHtmlRow += "Priority: " + htmlEncode(record.rData.svcPriority) + (record.rData.svcPriority == 0 ? " (alias mode)" : " (service mode)") + "
    Target Name: " + (record.rData.svcTargetName == "" ? "." : htmlEncode(record.rData.svcTargetName)) + tableHtmlSvcParams + "
    Use Automatic IPv4 Hint: " + record.rData.autoIpv4Hint + "
    Use Automatic IPv6 Hint: " + record.rData.autoIpv6Hint + "
    "; - tableHtmlRow += "
    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "
    "; additionalDataAttributes = "data-record-svc-priority=\"" + htmlEncode(record.rData.svcPriority) + "\"" + "data-record-svc-target-name=\"" + (record.rData.svcTargetName == "" ? "." : htmlEncode(record.rData.svcTargetName)) + "\"" + @@ -2613,16 +3311,11 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { break; case "URI": - tableHtmlRow += "Priority: " + htmlEncode(record.rData.priority) + + tableHtmlRow += "Priority: " + htmlEncode(record.rData.priority) + "
    Weight: " + htmlEncode(record.rData.weight) + "
    URI: " + htmlEncode(record.rData.uri); - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-priority=\"" + htmlEncode(record.rData.priority) + "\" " + "data-record-weight=\"" + htmlEncode(record.rData.weight) + "\" " + @@ -2630,16 +3323,11 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { break; case "CAA": - tableHtmlRow += "Flags: " + htmlEncode(record.rData.flags) + + tableHtmlRow += "Flags: " + htmlEncode(record.rData.flags) + "
    Tag: " + htmlEncode(record.rData.tag) + "
    Authority: " + htmlEncode(record.rData.value); - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-flags=\"" + htmlEncode(record.rData.flags) + "\" " + "data-record-tag=\"" + htmlEncode(record.rData.tag) + "\" " + @@ -2647,21 +3335,16 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { break; case "ANAME": - tableHtmlRow += "" + htmlEncode(record.rData.aname); - - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "" + htmlEncode(record.rData.aname); + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-aname=\"" + htmlEncode(record.rData.aname) + "\" "; break; case "FWD": - tableHtmlRow += "Protocol: " + htmlEncode(record.rData.protocol) + + tableHtmlRow += "Protocol: " + htmlEncode(record.rData.protocol) + "
    Forwarder: " + htmlEncode(record.rData.forwarder) + + "
    Priority: " + htmlEncode(record.rData.priority) + "
    Enable DNSSEC Validation: " + htmlEncode(record.rData.dnssecValidation) + "
    Proxy Type: " + htmlEncode(record.rData.proxyType); @@ -2675,15 +3358,11 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { break; } - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-protocol=\"" + htmlEncode(record.rData.protocol) + "\" " + "data-record-forwarder=\"" + htmlEncode(record.rData.forwarder) + "\" " + + "data-record-priority=\"" + htmlEncode(record.rData.priority) + "\" " + "data-record-dnssec-validation=\"" + htmlEncode(record.rData.dnssecValidation) + "\" " + "data-record-proxy-type=\"" + htmlEncode(record.rData.proxyType) + "\" "; @@ -2699,16 +3378,11 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { break; case "APP": - tableHtmlRow += "App Name: " + htmlEncode(record.rData.appName) + + tableHtmlRow += "App Name: " + htmlEncode(record.rData.appName) + "
    Class Path: " + htmlEncode(record.rData.classPath) + "
    Record Data: " + (record.rData.data == "" ? "
    " : "
    " + htmlEncode(record.rData.data) + "
    "); - tableHtmlRow += "
    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "
    "; additionalDataAttributes = "data-record-app-name=\"" + htmlEncode(record.rData.appName) + "\" " + "data-record-classpath=\"" + htmlEncode(record.rData.classPath) + "\" " + @@ -2716,40 +3390,57 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { break; case "ALIAS": - tableHtmlRow += "Type: " + htmlEncode(record.rData.type) + + tableHtmlRow += "Type: " + htmlEncode(record.rData.type) + "
    Alias: " + htmlEncode(record.rData.alias); - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "

    "; break; default: - tableHtmlRow += "RDATA: " + htmlEncode(record.rData.value); - - tableHtmlRow += "

    Last Used: " + lastUsedOn; - - if ((record.comments != null) && (record.comments.length > 0)) - tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; - - tableHtmlRow += ""; + tableHtmlRow += "RDATA: " + htmlEncode(record.rData.value); + tableHtmlRow += "

    "; additionalDataAttributes = "data-record-rdata=\"" + htmlEncode(record.rData.value) + "\""; break; } + if (record.expiryTtl > 0) { + var expiresOn = moment(record.lastModified).add(record.expiryTtl, "s"); + tableHtmlRow += "Expiry TTL: " + record.expiryTtl; + tableHtmlRow += "
    Expires On: " + expiresOn.local().format("YYYY-MM-DD HH:mm:ss") + " (" + expiresOn.fromNow() + ")"; + tableHtmlRow += "
    "; + } + + var lastUsedOn; + + if (record.lastUsedOn == "0001-01-01T00:00:00") + lastUsedOn = moment(record.lastUsedOn).local().format("YYYY-MM-DD HH:mm:ss") + " (never)"; + else + lastUsedOn = moment(record.lastUsedOn).local().format("YYYY-MM-DD HH:mm:ss") + " (" + moment(record.lastUsedOn).fromNow() + ")"; + + tableHtmlRow += "Last Used: " + lastUsedOn; + + if ((record.lastModified != "0001-01-01T00:00:00") && (record.lastModified != "0001-01-01T00:00:00Z")) + tableHtmlRow += "
    Last Modified: " + moment(record.lastModified).local().format("YYYY-MM-DD HH:mm:ss") + " (" + moment(record.lastModified).fromNow() + ")";; + + if ((record.comments != null) && (record.comments.length > 0)) + tableHtmlRow += "
    Comments:
    " + htmlEncode(record.comments) + "
    "; + + tableHtmlRow += ""; + var hideActionButtons = false; var disableEnableDisableDeleteButtons = false; switch (zoneType) { case "Internal": + case "Secondary": + case "SecondaryForwarder": + case "SecondaryCatalog": + case "Stub": hideActionButtons = true; break; - case "Secondary": + case "Catalog": switch (record.type) { case "SOA": disableEnableDisableDeleteButtons = true; @@ -2761,20 +3452,6 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { } break; - case "Stub": - switch (record.type) { - case "SOA": - disableEnableDisableDeleteButtons = true; - break; - - case "NS": - if (name == "@") - hideActionButtons = true; - - break; - } - break; - default: switch (record.type) { case "SOA": @@ -2798,7 +3475,7 @@ function getZoneRecordRowHtml(index, zone, zoneType, record) { } else { tableHtmlRow += ""; - tableHtmlRow += "
    "; + tableHtmlRow += "
    "; tableHtmlRow += ""; tableHtmlRow += ""; tableHtmlRow += ""; @@ -2817,7 +3494,6 @@ function clearAddEditRecordForm() { $("#txtAddEditRecordName").prop("disabled", false); $("#optAddEditRecordType").prop("disabled", false); $("#txtAddEditRecordTtl").prop("disabled", false); - $("#divAddEditRecordTtl").show(); $("#txtAddEditRecordName").val(""); $("#optAddEditRecordType").val("A"); @@ -2919,6 +3595,7 @@ function clearAddEditRecordForm() { $('#txtAddEditRecordDataForwarder').prop('disabled', false); $("#txtAddEditRecordDataForwarder").attr("placeholder", "8.8.8.8 or [2620:fe::10]") $("#txtAddEditRecordDataForwarder").val(""); + $("#txtAddEditRecordDataForwarderPriority").val(""); $("#chkAddEditRecordDataForwarderDnssecValidation").prop("checked", $("#chkDnssecValidation").prop("checked")); $("#rdAddEditRecordDataForwarderProxyTypeDefaultProxy").prop("checked", true); $("#txtAddEditRecordDataForwarderProxyAddress").prop("disabled", true); @@ -2942,6 +3619,9 @@ function clearAddEditRecordForm() { $("#txtAddEditRecordComments").val(""); + $("#divAddEditRecordExpiryTtl").show(); + $("#txtAddEditRecordExpiryTtl").val(""); + $("#btnAddEditRecord").button("reset"); } @@ -3024,7 +3704,8 @@ function modifyAddRecordFormByType(addMode) { $("#divAddEditRecordAlert").html(""); $("#txtAddEditRecordName").prop("placeholder", "@"); - $("#divAddEditRecordTtl").show(); + $("#txtAddEditRecordTtl").prop("disabled", false); + $("#txtAddEditRecordTtl").val(""); $("#txtAddEditRecordDataValue").attr("placeholder", ""); var type = $("#optAddEditRecordType").val(); @@ -3036,6 +3717,7 @@ function modifyAddRecordFormByType(addMode) { $("#divEditRecordDataSoa").hide(); $("#divAddEditRecordDataMx").hide(); $("#divAddEditRecordDataTxt").hide(); + $("#divAddEditRecordDataRp").hide(); $("#divAddEditRecordDataSrv").hide(); $("#divAddEditRecordDataNaptr").hide(); $("#divAddEditRecordDataDs").hide(); @@ -3084,9 +3766,6 @@ function modifyAddRecordFormByType(addMode) { $("#txtEditRecordDataSoaRetry").val(""); $("#txtEditRecordDataSoaExpire").val(""); $("#txtEditRecordDataSoaMinimum").val(""); - $("#txtEditRecordDataSoaPrimaryAddresses").val(""); - $("#rdEditRecordDataSoaZoneTransferProtocolTcp").prop("checked", true); - $("#optEditRecordDataSoaTsigKeyName").val(""); $("#divEditRecordDataSoa").show(); break; @@ -3111,6 +3790,12 @@ function modifyAddRecordFormByType(addMode) { $("#divAddEditRecordDataTxt").show(); break; + case "RP": + $("#txtAddEditRecordDataRpMailbox").val(""); + $("#txtAddEditRecordDataRpTxtDomain").val(""); + $("#divAddEditRecordDataRp").show(); + break; + case "SRV": $("#txtAddEditRecordName").prop("placeholder", "_service._protocol.name"); $("#txtAddEditRecordDataSrvPriority").val(""); @@ -3180,12 +3865,14 @@ function modifyAddRecordFormByType(addMode) { break; case "FWD": - $("#divAddEditRecordTtl").hide(); + $("#txtAddEditRecordTtl").prop("disabled", true); + $("#txtAddEditRecordTtl").val("0"); $("input[name=rdAddEditRecordDataForwarderProtocol]:radio").attr("disabled", false); $("#rdAddEditRecordDataForwarderProtocolUdp").prop("checked", true); $("#chkAddEditRecordDataForwarderThisServer").prop("checked", false); - $('#txtAddEditRecordDataForwarder').prop('disabled', false); + $("#txtAddEditRecordDataForwarder").prop("disabled", false); $("#txtAddEditRecordDataForwarder").val(""); + $("#txtAddEditRecordDataForwarderPriority").val(""); $("#chkAddEditRecordDataForwarderDnssecValidation").prop("checked", $("#chkDnssecValidation").prop("checked")); $("#rdAddEditRecordDataForwarderProxyTypeDefaultProxy").prop("checked", true); $("#txtAddEditRecordDataForwarderProxyAddress").prop("disabled", true); @@ -3266,6 +3953,7 @@ function addRecord() { var ttl = $("#txtAddEditRecordTtl").val(); var overwrite = $("#chkAddEditRecordOverwrite").prop("checked"); var comments = $("#txtAddEditRecordComments").val(); + var expiryTtl = $("#txtAddEditRecordExpiryTtl").val(); var apiUrl = ""; @@ -3300,7 +3988,7 @@ function addRecord() { case "CNAME": var subDomainName = $("#txtAddEditRecordName").val(); if ((subDomainName === "") || (subDomainName === "@")) { - showAlert("warning", "Missing!", "Please enter a name for the CNAME record.", divAddEditRecordAlert); + showAlert("warning", "Missing!", "Please enter a name for the CNAME record since DNS protocol does not allow CNAME at zone's apex. If you need CNAME like function at the zone's apex then use ANAME record instead.", divAddEditRecordAlert); $("#txtAddEditRecordName").focus(); return; } @@ -3354,6 +4042,18 @@ function addRecord() { apiUrl += "&text=" + encodeURIComponent(text) + "&splitText=" + splitText; break; + case "RP": + var mailbox = $("#txtAddEditRecordDataRpMailbox").val(); + if (mailbox === "") + mailbox = "."; + + var txtDomain = $("#txtAddEditRecordDataRpTxtDomain").val(); + if (txtDomain === "") + txtDomain = "."; + + apiUrl += "&mailbox=" + encodeURIComponent(mailbox) + "&txtDomain=" + encodeURIComponent(txtDomain); + break; + case "SRV": if ($("#txtAddEditRecordName").val() === "") { showAlert("warning", "Missing!", "Please enter a name that includes service and protocol labels.", divAddEditRecordAlert); @@ -3620,11 +4320,12 @@ function addRecord() { return; } + var forwarderPriority = $("#txtAddEditRecordDataForwarderPriority").val(); var dnssecValidation = $("#chkAddEditRecordDataForwarderDnssecValidation").prop("checked"); var proxyType = $("input[name=rdAddEditRecordDataForwarderProxyType]:checked").val(); apiUrl += "&protocol=" + $('input[name=rdAddEditRecordDataForwarderProtocol]:checked').val() + "&forwarder=" + encodeURIComponent(forwarder); - apiUrl += "&dnssecValidation=" + dnssecValidation + "&proxyType=" + proxyType; + apiUrl += "&forwarderPriority=" + forwarderPriority + "&dnssecValidation=" + dnssecValidation + "&proxyType=" + proxyType; switch (proxyType) { case "Http": @@ -3692,7 +4393,7 @@ function addRecord() { break; } - apiUrl = "/api/zones/records/add?token=" + sessionData.token + "&zone=" + encodeURIComponent(zone) + "&domain=" + encodeURIComponent(domain) + "&type=" + encodeURIComponent(type) + "&ttl=" + ttl + "&overwrite=" + overwrite + "&comments=" + encodeURIComponent(comments) + apiUrl; + apiUrl = "/api/zones/records/add?token=" + sessionData.token + "&zone=" + encodeURIComponent(zone) + "&domain=" + encodeURIComponent(domain) + "&type=" + encodeURIComponent(type) + "&ttl=" + ttl + "&overwrite=" + overwrite + "&comments=" + encodeURIComponent(comments) + "&expiryTtl=" + expiryTtl + apiUrl; btn.button("loading"); @@ -3818,6 +4519,7 @@ function showEditRecordModal(objBtn) { var type = divData.attr("data-record-type"); var ttl = divData.attr("data-record-ttl"); var comments = divData.attr("data-record-comments"); + var expiryTtl = divData.attr("data-record-expiry-ttl"); if (name === zone) name = "@"; @@ -3835,45 +4537,7 @@ function showEditRecordModal(objBtn) { $("#txtAddEditRecordName").val(name); $("#txtAddEditRecordTtl").val(ttl) $("#txtAddEditRecordComments").val(comments); - - var disableSoaRecordModalFields = false; - var hideSoaRecordUseSerialDateSchemeField = false; - var hideSoaRecordPrimaryAddressesField = false; - var hideSoaRecordXfrAndTsigFields = false; - var hideSoaRecordValidateZoneField = false; - - var zoneType = $("#titleEditZoneType").text(); - switch (zoneType) { - case "Primary": - switch (type) { - case "SOA": - hideSoaRecordPrimaryAddressesField = true; - hideSoaRecordXfrAndTsigFields = true; - hideSoaRecordValidateZoneField = true; - break; - } - break; - - case "Secondary": - switch (type) { - case "SOA": - disableSoaRecordModalFields = true; - hideSoaRecordUseSerialDateSchemeField = true; - break; - } - break; - - case "Stub": - switch (type) { - case "SOA": - disableSoaRecordModalFields = true; - hideSoaRecordUseSerialDateSchemeField = true; - hideSoaRecordXfrAndTsigFields = true; - hideSoaRecordValidateZoneField = true - break; - } - break; - } + $("#txtAddEditRecordExpiryTtl").val(expiryTtl); switch (type) { case "A": @@ -3904,64 +4568,29 @@ function showEditRecordModal(objBtn) { $("#txtEditRecordDataSoaExpire").val(divData.attr("data-record-expire")); $("#txtEditRecordDataSoaMinimum").val(divData.attr("data-record-minimum")); $("#chkEditRecordDataSoaUseSerialDateScheme").prop("checked", divData.attr("data-record-serial-scheme") === "true"); - $("#txtEditRecordDataSoaPrimaryAddresses").val(divData.attr("data-record-paddresses").replace(/, /g, "\n")); - $("#chkEditRecordDataSoaValidateZone").prop("checked", divData.attr("data-record-validate-zone") === "true"); - - switch (divData.attr("data-record-zonetransferprotocol").toLowerCase()) { - case "tls": - $("#rdEditRecordDataSoaZoneTransferProtocolTls").prop("checked", true); - break; - - case "quic": - $("#rdEditRecordDataSoaZoneTransferProtocolQuic").prop("checked", true); - break; - - case "tcp": - default: - $("#rdEditRecordDataSoaZoneTransferProtocolTcp").prop("checked", true); - break; - } $("#txtAddEditRecordName").prop("disabled", true); + $("#divAddEditRecordExpiryTtl").hide(); - if (disableSoaRecordModalFields) { - $("#txtAddEditRecordTtl").prop("disabled", true); + switch ($("#titleEditZoneType").text()) { + case "Forwarder": + $("#txtAddEditRecordTtl").prop("disabled", true); + $("#txtEditRecordDataSoaResponsiblePerson").prop("disabled", true); + break; - $("#txtEditRecordDataSoaPrimaryNameServer").prop("disabled", true); - $("#txtEditRecordDataSoaResponsiblePerson").prop("disabled", true); - $("#txtEditRecordDataSoaSerial").prop("disabled", true); - $("#txtEditRecordDataSoaRefresh").prop("disabled", true); - $("#txtEditRecordDataSoaRetry").prop("disabled", true); - $("#txtEditRecordDataSoaExpire").prop("disabled", true); - $("#txtEditRecordDataSoaMinimum").prop("disabled", true); + case "Catalog": + $("#txtAddEditRecordTtl").prop("disabled", true); + $("#txtEditRecordDataSoaPrimaryNameServer").prop("disabled", true); + $("#txtEditRecordDataSoaResponsiblePerson").prop("disabled", true); + break; + + default: + $("#txtAddEditRecordTtl").prop("disabled", false); + $("#txtEditRecordDataSoaPrimaryNameServer").prop("disabled", false); + $("#txtEditRecordDataSoaResponsiblePerson").prop("disabled", false); + break; } - if (hideSoaRecordUseSerialDateSchemeField) - $("#divEditRecordDataSoaUseSerialDateScheme").hide(); - else - $("#divEditRecordDataSoaUseSerialDateScheme").show(); - - if (hideSoaRecordPrimaryAddressesField) { - $("#divEditRecordDataSoaPrimaryAddresses").hide(); - } else { - $("#divEditRecordDataSoaPrimaryAddresses").show(); - } - - if (hideSoaRecordXfrAndTsigFields) { - $("#divEditRecordDataSoaZoneTransferProtocol").hide(); - $("#divEditRecordDataSoaTsigKeyName").hide(); - } else { - $("#divEditRecordDataSoaZoneTransferProtocol").show(); - $("#divEditRecordDataSoaTsigKeyName").show(); - - loadTsigKeyNames($("#optEditRecordDataSoaTsigKeyName"), divData.attr("data-record-tsigkeyname"), $("#divAddEditRecordAlert")); - } - - if (hideSoaRecordValidateZoneField) - $("#divEditRecordDataSoaValidateZone").hide(); - else - $("#divEditRecordDataSoaValidateZone").show(); - break; case "PTR": @@ -3978,6 +4607,11 @@ function showEditRecordModal(objBtn) { $("#chkAddEditRecordDataTxtSplitText").prop("checked", divData.attr("data-record-split-text") === "true"); break; + case "RP": + $("#txtAddEditRecordDataRpMailbox").val(divData.attr("data-record-mailbox")); + $("#txtAddEditRecordDataRpTxtDomain").val(divData.attr("data-record-txt-domain")); + break; + case "SRV": $("#txtAddEditRecordDataSrvPriority").val(divData.attr("data-record-priority")); $("#txtAddEditRecordDataSrvWeight").val(divData.attr("data-record-weight")); @@ -4066,7 +4700,7 @@ function showEditRecordModal(objBtn) { break; case "FWD": - $("#divAddEditRecordTtl").hide(); + $("#txtAddEditRecordTtl").prop("disabled", true); $("#rdAddEditRecordDataForwarderProtocol" + divData.attr("data-record-protocol")).prop("checked", true); var forwarder = divData.attr("data-record-forwarder"); @@ -4084,6 +4718,7 @@ function showEditRecordModal(objBtn) { $("#divAddEditRecordDataForwarderProxy").show(); } + $("#txtAddEditRecordDataForwarderPriority").val(divData.attr("data-record-priority")); $("#chkAddEditRecordDataForwarderDnssecValidation").prop("checked", divData.attr("data-record-dnssec-validation") === "true"); var proxyType = divData.attr("data-record-proxy-type"); @@ -4175,6 +4810,7 @@ function updateRecord() { var ttl = $("#txtAddEditRecordTtl").val(); var disable = (divData.attr("data-record-disabled") === "true"); var comments = $("#txtAddEditRecordComments").val(); + var expiryTtl = $("#txtAddEditRecordExpiryTtl").val(); var apiUrl = ""; @@ -4213,7 +4849,7 @@ function updateRecord() { case "CNAME": var subDomainName = $("#txtAddEditRecordName").val(); if ((subDomainName === "") || (subDomainName === "@")) { - showAlert("warning", "Missing!", "Please enter a name for the CNAME record.", divAddEditRecordAlert); + showAlert("warning", "Missing!", "Please enter a name for the CNAME record since DNS protocol does not allow CNAME at zone's apex. If you need CNAME like function at the zone's apex then use ANAME record instead.", divAddEditRecordAlert); $("#txtAddEditRecordName").focus(); return; } @@ -4279,10 +4915,6 @@ function updateRecord() { } var useSerialDateScheme = $("#chkEditRecordDataSoaUseSerialDateScheme").prop("checked"); - var primaryAddresses = cleanTextList($("#txtEditRecordDataSoaPrimaryAddresses").val()); - var zoneTransferProtocol = $('input[name=rdEditRecordDataSoaZoneTransferProtocol]:checked').val(); - var tsigKeyName = $("#optEditRecordDataSoaTsigKeyName").val(); - var validateZone = $("#chkEditRecordDataSoaValidateZone").prop("checked"); apiUrl += "&primaryNameServer=" + encodeURIComponent(primaryNameServer) + "&responsiblePerson=" + encodeURIComponent(responsiblePerson) + @@ -4291,11 +4923,7 @@ function updateRecord() { "&retry=" + encodeURIComponent(retry) + "&expire=" + encodeURIComponent(expire) + "&minimum=" + encodeURIComponent(minimum) + - "&useSerialDateScheme=" + encodeURIComponent(useSerialDateScheme) + - "&primaryAddresses=" + encodeURIComponent(primaryAddresses) + - "&zoneTransferProtocol=" + encodeURIComponent(zoneTransferProtocol) + - "&tsigKeyName=" + encodeURIComponent(tsigKeyName) + - "&validateZone=" + validateZone; + "&useSerialDateScheme=" + encodeURIComponent(useSerialDateScheme); break; @@ -4347,6 +4975,22 @@ function updateRecord() { apiUrl += "&text=" + encodeURIComponent(text) + "&newText=" + encodeURIComponent(newText) + "&splitText=" + splitText + "&newSplitText=" + newSplitText; break; + case "RP": + var mailbox = divData.attr("data-record-mailbox"); + + var newMailbox = $("#txtAddEditRecordDataRpMailbox").val(); + if (newMailbox === "") + newMailbox = "."; + + var txtDomain = divData.attr("data-record-txt-domain"); + + var newTxtDomain = $("#txtAddEditRecordDataRpTxtDomain").val(); + if (newTxtDomain === "") + newTxtDomain = "."; + + apiUrl += "&mailbox=" + encodeURIComponent(mailbox) + "&newMailbox=" + encodeURIComponent(newMailbox) + "&txtDomain=" + encodeURIComponent(txtDomain) + "&newTxtDomain=" + encodeURIComponent(newTxtDomain); + break; + case "SRV": if ($("#txtAddEditRecordName").val() === "") { showAlert("warning", "Missing!", "Please enter a name that includes service and protocol labels.", divAddEditRecordAlert); @@ -4675,9 +5319,10 @@ function updateRecord() { return; } + var forwarderPriority = $("#txtAddEditRecordDataForwarderPriority").val(); var dnssecValidation = $("#chkAddEditRecordDataForwarderDnssecValidation").prop("checked"); - apiUrl += "&protocol=" + protocol + "&newProtocol=" + newProtocol + "&forwarder=" + encodeURIComponent(forwarder) + "&newForwarder=" + encodeURIComponent(newForwarder) + "&dnssecValidation=" + dnssecValidation; + apiUrl += "&protocol=" + protocol + "&newProtocol=" + newProtocol + "&forwarder=" + encodeURIComponent(forwarder) + "&newForwarder=" + encodeURIComponent(newForwarder) + "&forwarderPriority=" + forwarderPriority + "&dnssecValidation=" + dnssecValidation; if (newForwarder !== "this-server") { var proxyType = $("input[name=rdAddEditRecordDataForwarderProxyType]:checked").val(); @@ -4729,7 +5374,7 @@ function updateRecord() { break; } - apiUrl = "/api/zones/records/update?token=" + sessionData.token + "&zone=" + encodeURIComponent(zone) + "&type=" + encodeURIComponent(type) + "&domain=" + encodeURIComponent(domain) + "&newDomain=" + encodeURIComponent(newDomain) + "&ttl=" + ttl + "&disable=" + disable + "&comments=" + encodeURIComponent(comments) + apiUrl; + apiUrl = "/api/zones/records/update?token=" + sessionData.token + "&zone=" + encodeURIComponent(zone) + "&type=" + encodeURIComponent(type) + "&domain=" + encodeURIComponent(domain) + "&newDomain=" + encodeURIComponent(newDomain) + "&ttl=" + ttl + "&disable=" + disable + "&comments=" + encodeURIComponent(comments) + "&expiryTtl=" + expiryTtl + apiUrl; btn.button("loading"); @@ -4742,7 +5387,7 @@ function updateRecord() { editZoneInfo = responseJSON.response.zone; editZoneRecords[index] = responseJSON.response.updatedRecord; - //show record + //show updated record var zoneType; if (responseJSON.response.zone.internal) zoneType = "Internal"; @@ -4775,6 +5420,7 @@ function updateRecordState(objBtn, disable) { var domain = divData.attr("data-record-name"); var ttl = divData.attr("data-record-ttl"); var comments = divData.attr("data-record-comments"); + var expiryTtl = $("#txtAddEditRecordExpiryTtl").val(); if (domain === "") domain = "."; @@ -4782,7 +5428,7 @@ function updateRecordState(objBtn, disable) { if (disable && !confirm("Are you sure to disable the " + type + " record '" + domain + "'?")) return; - var apiUrl = "/api/zones/records/update?token=" + sessionData.token + "&zone=" + encodeURIComponent(zone) + "&type=" + encodeURIComponent(type) + "&domain=" + encodeURIComponent(domain) + "&ttl=" + ttl + "&disable=" + disable + "&comments=" + encodeURIComponent(comments); + var apiUrl = "/api/zones/records/update?token=" + sessionData.token + "&zone=" + encodeURIComponent(zone) + "&type=" + encodeURIComponent(type) + "&domain=" + encodeURIComponent(domain) + "&ttl=" + ttl + "&disable=" + disable + "&comments=" + encodeURIComponent(comments) + "&expiryTtl=" + expiryTtl; switch (type) { case "A": @@ -4812,6 +5458,10 @@ function updateRecordState(objBtn, disable) { apiUrl += "&text=" + encodeURIComponent(divData.attr("data-record-text")) + "&splitText=" + divData.attr("data-record-split-text"); break; + case "RP": + apiUrl += "&mailbox=" + encodeURIComponent(divData.attr("data-record-mailbox")) + "&txtDomain=" + encodeURIComponent(divData.attr("data-record-txt-domain")); + break; + case "SRV": apiUrl += "&priority=" + divData.attr("data-record-priority") + "&weight=" + divData.attr("data-record-weight") + "&port=" + divData.attr("data-record-port") + "&target=" + encodeURIComponent(divData.attr("data-record-target")); break; @@ -4878,7 +5528,7 @@ function updateRecordState(objBtn, disable) { var proxyType = divData.attr("data-record-proxy-type"); - apiUrl += "&dnssecValidation=" + divData.attr("data-record-dnssec-validation") + "&proxyType=" + proxyType; + apiUrl += "&forwarderPriority=" + divData.attr("data-record-priority") + "&dnssecValidation=" + divData.attr("data-record-dnssec-validation") + "&proxyType=" + proxyType; switch (proxyType) { case "Http": @@ -4904,24 +5554,24 @@ function updateRecordState(objBtn, disable) { success: function (responseJSON) { btn.button("reset"); - //update local arrays + //update local data + editZoneInfo = responseJSON.response.zone; editZoneRecords[index] = responseJSON.response.updatedRecord; - //set new state - divData.attr("data-record-disabled", disable); + //show updated record + var zoneType; + if (responseJSON.response.zone.internal) + zoneType = "Internal"; + else + zoneType = responseJSON.response.zone.type; - if (disable) { - $("#btnEnableRecord" + index).show(); - $("#btnDisableRecord" + index).hide(); + var tableHtmlRow = getZoneRecordRowHtml(index, zone, zoneType, responseJSON.response.updatedRecord); + $("#trZoneRecord" + index).replaceWith(tableHtmlRow); + if (disable) showAlert("success", "Record Disabled!", "Resource record was disabled successfully."); - } - else { - $("#btnEnableRecord" + index).hide(); - $("#btnDisableRecord" + index).show(); - + else showAlert("success", "Record Enabled!", "Resource record was enabled successfully."); - } }, error: function () { btn.button("reset"); @@ -4973,6 +5623,10 @@ function deleteRecord(objBtn) { apiUrl += "&text=" + encodeURIComponent(divData.attr("data-record-text")) + "&splitText=" + divData.attr("data-record-split-text"); break; + case "RP": + apiUrl += "&mailbox=" + encodeURIComponent(divData.attr("data-record-mailbox")) + "&txtDomain=" + encodeURIComponent(divData.attr("data-record-txt-domain")); + break; + case "SRV": apiUrl += "&priority=" + divData.attr("data-record-priority") + "&weight=" + divData.attr("data-record-weight") + "&port=" + divData.attr("data-record-port") + "&target=" + encodeURIComponent(divData.attr("data-record-target")); break; @@ -5129,7 +5783,7 @@ function signPrimaryZone() { var zoneHideDnssecRecords = (localStorage.getItem("zoneHideDnssecRecords") == "true"); if (zoneHideDnssecRecords) { - $("#titleDnssecStatusEditZone").show(); + $("#titleEditZoneDnssecStatus").show(); $("#lnkZoneDnssecSignZone").hide(); @@ -5187,7 +5841,7 @@ function unsignPrimaryZone() { var zoneHideDnssecRecords = (localStorage.getItem("zoneHideDnssecRecords") == "true"); if (zoneHideDnssecRecords) { - $("#titleDnssecStatusEditZone").hide(); + $("#titleEditZoneDnssecStatus").hide(); $("#lnkZoneDnssecSignZone").show(); @@ -5689,6 +6343,8 @@ function changeDnssecNxProof(objBtn) { btn.button("reset"); + $("#titleEditZoneDnssecStatus").text(nxProof); + var zoneHideDnssecRecords = (localStorage.getItem("zoneHideDnssecRecords") == "true"); if (!zoneHideDnssecRecords) showEditZone(zone);