zone.js 147 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442
  1. /*
  2. Technitium DNS Server
  3. Copyright (C) 2022 Shreyas Zare (shreyas@technitium.com)
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. $(function () {
  16. $("input[type=radio][name=rdAddZoneType]").change(function () {
  17. $("#divAddZonePrimaryNameServerAddresses").hide();
  18. $("#divAddZoneZoneTransferProtocol").hide();
  19. $("#divAddZoneTsigKeyName").hide();
  20. $("#divAddZoneForwarderProtocol").hide();
  21. $("#divAddZoneForwarder").hide();
  22. $("#divAddZoneForwarderDnssecValidation").hide();
  23. $("#divAddZoneForwarderProxy").hide();
  24. var zoneType = $('input[name=rdAddZoneType]:checked').val();
  25. switch (zoneType) {
  26. case "Primary":
  27. break;
  28. case "Secondary":
  29. $("#divAddZonePrimaryNameServerAddresses").show();
  30. $("#divAddZoneZoneTransferProtocol").show();
  31. $("#divAddZoneTsigKeyName").show();
  32. break;
  33. case "Stub":
  34. $("#divAddZonePrimaryNameServerAddresses").show();
  35. break;
  36. case "Forwarder":
  37. $("#divAddZoneForwarderProtocol").show();
  38. $("#divAddZoneForwarder").show();
  39. $("#divAddZoneForwarderDnssecValidation").show();
  40. $("#divAddZoneForwarderProxy").show();
  41. break;
  42. }
  43. });
  44. $("input[type=radio][name=rdAddZoneForwarderProtocol]").change(function () {
  45. var protocol = $('input[name=rdAddZoneForwarderProtocol]:checked').val();
  46. switch (protocol) {
  47. case "Udp":
  48. case "Tcp":
  49. $("#txtAddZoneForwarder").attr("placeholder", "8.8.8.8 or [2620:fe::10]")
  50. break;
  51. case "Tls":
  52. $("#txtAddZoneForwarder").attr("placeholder", "dns.quad9.net (9.9.9.9:853)")
  53. break;
  54. case "Https":
  55. case "HttpsJson":
  56. $("#txtAddZoneForwarder").attr("placeholder", "https://cloudflare-dns.com/dns-query (1.1.1.1)")
  57. break;
  58. }
  59. });
  60. $("input[type=radio][name=rdAddZoneForwarderProxyType]").change(function () {
  61. var proxyType = $('input[name=rdAddZoneForwarderProxyType]:checked').val();
  62. $("#txtAddZoneForwarderProxyAddress").prop("disabled", (proxyType === "None"));
  63. $("#txtAddZoneForwarderProxyPort").prop("disabled", (proxyType === "None"));
  64. $("#txtAddZoneForwarderProxyUsername").prop("disabled", (proxyType === "None"));
  65. $("#txtAddZoneForwarderProxyPassword").prop("disabled", (proxyType === "None"));
  66. });
  67. $("input[type=radio][name=rdZoneTransfer]").change(function () {
  68. var zoneTransfer = $('input[name=rdZoneTransfer]:checked').val();
  69. if (zoneTransfer === "AllowOnlySpecifiedNameServers") {
  70. $("#txtZoneTransferNameServers").prop("disabled", false);
  71. }
  72. else {
  73. $("#txtZoneTransferNameServers").prop("disabled", true);
  74. }
  75. });
  76. $("input[type=radio][name=rdZoneNotify]").change(function () {
  77. var zoneTransfer = $('input[name=rdZoneNotify]:checked').val();
  78. if (zoneTransfer === "SpecifiedNameServers") {
  79. $("#txtZoneNotifyNameServers").prop("disabled", false);
  80. }
  81. else {
  82. $("#txtZoneNotifyNameServers").prop("disabled", true);
  83. }
  84. });
  85. $("input[type=radio][name=rdDnssecSignZoneAlgorithm]").change(function () {
  86. var algorithm = $("input[name=rdDnssecSignZoneAlgorithm]:checked").val();
  87. switch (algorithm) {
  88. case "RSA":
  89. $("#divDnssecSignZoneRsaParameters").show();
  90. $("#divDnssecSignZoneEcdsaParameters").hide();
  91. break;
  92. case "ECDSA":
  93. $("#divDnssecSignZoneRsaParameters").hide();
  94. $("#divDnssecSignZoneEcdsaParameters").show();
  95. break;
  96. }
  97. });
  98. $("input[type=radio][name=rdDnssecSignZoneNxProof]").change(function () {
  99. var nxProof = $("input[name=rdDnssecSignZoneNxProof]:checked").val();
  100. switch (nxProof) {
  101. case "NSEC":
  102. $("#divDnssecSignZoneNSEC3Parameters").hide();
  103. break;
  104. case "NSEC3":
  105. $("#divDnssecSignZoneNSEC3Parameters").show();
  106. break;
  107. }
  108. });
  109. $("#optDnssecPropertiesGenerateKeyKeyType").change(function () {
  110. var keyType = $("#optDnssecPropertiesGenerateKeyKeyType").val();
  111. switch (keyType) {
  112. case "ZoneSigningKey":
  113. $("#divDnssecPropertiesGenerateKeyAutomaticRollover").show();
  114. $("#txtDnssecPropertiesGenerateKeyAutomaticRollover").val(90);
  115. break;
  116. default:
  117. $("#divDnssecPropertiesGenerateKeyAutomaticRollover").hide();
  118. $("#txtDnssecPropertiesGenerateKeyAutomaticRollover").val(0);
  119. break;
  120. }
  121. });
  122. $("#optDnssecPropertiesGenerateKeyAlgorithm").change(function () {
  123. var algorithm = $("#optDnssecPropertiesGenerateKeyAlgorithm").val();
  124. switch (algorithm) {
  125. case "RSA":
  126. $("#divDnssecPropertiesGenerateKeyRsaParameters").show();
  127. $("#divDnssecPropertiesGenerateKeyEcdsaParameters").hide();
  128. break;
  129. case "ECDSA":
  130. $("#divDnssecPropertiesGenerateKeyRsaParameters").hide();
  131. $("#divDnssecPropertiesGenerateKeyEcdsaParameters").show();
  132. break;
  133. }
  134. });
  135. $("input[type=radio][name=rdDnssecPropertiesNxProof]").change(function () {
  136. var nxProof = $("input[name=rdDnssecPropertiesNxProof]:checked").val();
  137. switch (nxProof) {
  138. case "NSEC":
  139. $("#divDnssecPropertiesNSEC3Parameters").hide();
  140. break;
  141. case "NSEC3":
  142. $("#divDnssecPropertiesNSEC3Parameters").show();
  143. break;
  144. }
  145. });
  146. $("#chkAddEditRecordDataPtr").click(function () {
  147. var addPtrRecord = $("#chkAddEditRecordDataPtr").prop('checked');
  148. $("#chkAddEditRecordDataCreatePtrZone").prop('disabled', !addPtrRecord);
  149. });
  150. $("input[type=radio][name=rdAddEditRecordDataForwarderProtocol]").change(updateAddEditFormForwarderPlaceholder);
  151. $("input[type=radio][name=rdAddEditRecordDataForwarderProxyType]").change(updateAddEditFormForwarderProxyType);
  152. $("#optAddEditRecordDataAppName").change(function () {
  153. if (appsList == null)
  154. return;
  155. var appName = $("#optAddEditRecordDataAppName").val();
  156. var optClassPaths = "<option></option>";
  157. for (var i = 0; i < appsList.length; i++) {
  158. if (appsList[i].name == appName) {
  159. for (var j = 0; j < appsList[i].dnsApps.length; j++) {
  160. if (appsList[i].dnsApps[j].isAppRecordRequestHandler)
  161. optClassPaths += "<option>" + appsList[i].dnsApps[j].classPath + "</option>";
  162. }
  163. break;
  164. }
  165. }
  166. $("#optAddEditRecordDataClassPath").html(optClassPaths);
  167. $("#txtAddEditRecordDataData").val("");
  168. });
  169. $("#optAddEditRecordDataClassPath").change(function () {
  170. if (appsList == null)
  171. return;
  172. var appName = $("#optAddEditRecordDataAppName").val();
  173. var classPath = $("#optAddEditRecordDataClassPath").val();
  174. for (var i = 0; i < appsList.length; i++) {
  175. if (appsList[i].name == appName) {
  176. for (var j = 0; j < appsList[i].dnsApps.length; j++) {
  177. if (appsList[i].dnsApps[j].classPath == classPath) {
  178. $("#txtAddEditRecordDataData").val(appsList[i].dnsApps[j].recordDataTemplate);
  179. return;
  180. }
  181. }
  182. }
  183. }
  184. $("#txtAddEditRecordDataData").val("");
  185. });
  186. $("#optZoneOptionsQuickTsigKeyNames").change(function () {
  187. var selectedOption = $("#optZoneOptionsQuickTsigKeyNames").val();
  188. switch (selectedOption) {
  189. case "blank":
  190. break;
  191. case "none":
  192. $("#txtZoneOptionsZoneTransferTsigKeyNames").val("");
  193. break;
  194. default:
  195. var existingList = $("#txtZoneOptionsZoneTransferTsigKeyNames").val();
  196. if (existingList.indexOf(selectedOption) < 0) {
  197. existingList += selectedOption + "\n";
  198. $("#txtZoneOptionsZoneTransferTsigKeyNames").val(existingList);
  199. }
  200. break;
  201. }
  202. });
  203. });
  204. function refreshZones(checkDisplay) {
  205. if (checkDisplay == null)
  206. checkDisplay = false;
  207. var divViewZones = $("#divViewZones");
  208. if (checkDisplay && (divViewZones.css('display') === "none"))
  209. return;
  210. var divViewZonesLoader = $("#divViewZonesLoader");
  211. var divEditZone = $("#divEditZone");
  212. divViewZones.hide();
  213. divEditZone.hide();
  214. divViewZonesLoader.show();
  215. HTTPRequest({
  216. url: "/api/zone/list?token=" + token,
  217. success: function (responseJSON) {
  218. var zones = responseJSON.response.zones;
  219. var tableHtmlRows = "";
  220. for (var i = 0; i < zones.length; i++) {
  221. var id = Math.floor(Math.random() * 10000);
  222. var name = zones[i].name;
  223. if (name === "")
  224. name = ".";
  225. var type;
  226. if (zones[i].internal)
  227. type = "<span class=\"label label-default\">Internal</span>";
  228. else
  229. type = "<span class=\"label label-primary\">" + zones[i].type + "</span>";
  230. var dnssecStatus = "";
  231. switch (zones[i].dnssecStatus) {
  232. case "SignedWithNSEC":
  233. case "SignedWithNSEC3":
  234. dnssecStatus = "<span class=\"label label-default\">DNSSEC</span>";
  235. break;
  236. }
  237. var status = "";
  238. if (zones[i].disabled)
  239. status = "<span id=\"tdStatus" + id + "\" class=\"label label-warning\">Disabled</span>";
  240. else if (zones[i].isExpired)
  241. status = "<span id=\"tdStatus" + id + "\" class=\"label label-danger\">Expired</span>";
  242. else
  243. status = "<span id=\"tdStatus" + id + "\" class=\"label label-success\">Enabled</span>";
  244. var expiry = zones[i].expiry;
  245. if (expiry == null)
  246. expiry = "&nbsp;";
  247. else
  248. expiry = moment(expiry).local().format("YYYY-MM-DD HH:mm");
  249. var isReadOnlyZone = zones[i].internal;
  250. var disableOptions;
  251. switch (zones[i].type) {
  252. case "Primary":
  253. case "Secondary":
  254. disableOptions = zones[i].internal;
  255. break;
  256. default:
  257. disableOptions = true;
  258. break;
  259. }
  260. tableHtmlRows += "<tr id=\"trZone" + id + "\"><td>" + htmlEncode(name) + "</td>";
  261. tableHtmlRows += "<td>" + type + "</td>";
  262. tableHtmlRows += "<td>" + dnssecStatus + "</td>";
  263. tableHtmlRows += "<td>" + status + "</td>";
  264. tableHtmlRows += "<td>" + expiry + "</td>";
  265. tableHtmlRows += "<td align=\"right\" style=\"width: 290px;\"><button type=\"button\" class=\"btn btn-primary\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 0 0;\" onclick=\"showEditZone('" + name + "');\">" + (isReadOnlyZone ? "View" : "Edit") + "</button>";
  266. tableHtmlRows += "<button type=\"button\" data-id=\"" + id + "\" id=\"btnEnableZone" + id + "\" class=\"btn btn-default\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 0 0;" + (zones[i].disabled ? "" : " display: none;") + "\" onclick=\"enableZone(this, '" + name + "');\" data-loading-text=\"Enabling...\"" + (zones[i].internal ? " disabled" : "") + ">Enable</button>";
  267. tableHtmlRows += "<button type=\"button\" data-id=\"" + id + "\" id=\"btnDisableZone" + id + "\" class=\"btn btn-warning\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 0 0;" + (!zones[i].disabled ? "" : " display: none;") + "\" onclick=\"disableZone(this, '" + name + "');\" data-loading-text=\"Disabling...\"" + (zones[i].internal ? " disabled" : "") + ">Disable</button>";
  268. tableHtmlRows += "<button type=\"button\" data-id=\"" + id + "\" class=\"btn btn-danger\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 0 0;\" onclick=\"deleteZone(this, '" + name + "');\" data-loading-text=\"Deleting...\"" + (zones[i].internal ? " disabled" : "") + ">Delete</button>";
  269. tableHtmlRows += "<button type=\"button\" class=\"btn btn-primary\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 0 0;\" onclick=\"showZoneOptionsModal('" + name + "');\"" + (disableOptions ? " disabled" : "") + ">Options</button></td></tr>";
  270. }
  271. $("#tableZonesBody").html(tableHtmlRows);
  272. if (zones.length > 0)
  273. $("#tableZonesFooter").html("<tr><td colspan=\"6\"><b>Total Zones: " + zones.length + "</b></td></tr>");
  274. else
  275. $("#tableZonesFooter").html("<tr><td colspan=\"6\" align=\"center\">No Zones Found</td></tr>");
  276. divViewZonesLoader.hide();
  277. divViewZones.show();
  278. },
  279. error: function () {
  280. divViewZonesLoader.hide();
  281. divViewZones.show();
  282. },
  283. invalidToken: function () {
  284. showPageLogin();
  285. },
  286. objLoaderPlaceholder: divViewZonesLoader
  287. });
  288. }
  289. function enableZone(objBtn, zone) {
  290. var btn = $(objBtn);
  291. var id = btn.attr("data-id");
  292. btn.button('loading');
  293. HTTPRequest({
  294. url: "/api/zone/enable?token=" + token + "&zone=" + zone,
  295. success: function (responseJSON) {
  296. btn.button('reset');
  297. $("#btnEnableZone" + id).hide();
  298. $("#btnDisableZone" + id).show();
  299. $("#tdStatus" + id).attr("class", "label label-success");
  300. $("#tdStatus" + id).html("Enabled");
  301. showAlert("success", "Zone Enabled!", "Zone '" + zone + "' was enabled successfully.");
  302. },
  303. error: function () {
  304. btn.button('reset');
  305. },
  306. invalidToken: function () {
  307. showPageLogin();
  308. }
  309. });
  310. }
  311. function disableZone(objBtn, zone) {
  312. if (!confirm("Are you sure you want to disable the zone '" + zone + "'?"))
  313. return;
  314. var btn = $(objBtn);
  315. var id = btn.attr("data-id");
  316. btn.button('loading');
  317. HTTPRequest({
  318. url: "/api/zone/disable?token=" + token + "&zone=" + zone,
  319. success: function (responseJSON) {
  320. btn.button('reset');
  321. $("#btnEnableZone" + id).show();
  322. $("#btnDisableZone" + id).hide();
  323. $("#tdStatus" + id).attr("class", "label label-warning");
  324. $("#tdStatus" + id).html("Disabled");
  325. showAlert("success", "Zone Disabled!", "Zone '" + zone + "' was disabled successfully.");
  326. },
  327. error: function () {
  328. btn.button('reset');
  329. },
  330. invalidToken: function () {
  331. showPageLogin();
  332. }
  333. });
  334. }
  335. function deleteZone(objBtn, zone, editZone) {
  336. if (!confirm("Are you sure you want to permanently delete the zone '" + zone + "' and all its records?"))
  337. return;
  338. if (editZone == null)
  339. editZone = false;
  340. var btn = $(objBtn);
  341. var id = btn.attr("data-id");
  342. btn.button('loading');
  343. HTTPRequest({
  344. url: "/api/zone/delete?token=" + token + "&zone=" + zone,
  345. success: function (responseJSON) {
  346. if (editZone) {
  347. btn.button('reset');
  348. refreshZones();
  349. }
  350. else {
  351. $("#trZone" + id).remove();
  352. var totalZones = $('#tableZones >tbody >tr').length;
  353. if (totalZones > 0)
  354. $("#tableZonesFooter").html("<tr><td colspan=\"6\"><b>Total Zones: " + totalZones + "</b></td></tr>");
  355. else
  356. $("#tableZonesFooter").html("<tr><td colspan=\"6\" align=\"center\">No Zones Found</td></tr>");
  357. }
  358. showAlert("success", "Zone Deleted!", "Zone '" + zone + "' was deleted successfully.");
  359. },
  360. error: function () {
  361. btn.button('reset');
  362. },
  363. invalidToken: function () {
  364. showPageLogin();
  365. }
  366. });
  367. }
  368. function showZoneOptionsModal(zone) {
  369. var divZoneOptionsAlert = $("#divZoneOptionsAlert");
  370. var divZoneOptionsLoader = $("#divZoneOptionsLoader");
  371. var divZoneOptions = $("#divZoneOptions");
  372. $("#lblZoneOptionsZoneName").text(zone);
  373. divZoneOptionsLoader.show();
  374. divZoneOptions.hide();
  375. $("#modalZoneOptions").modal("show");
  376. HTTPRequest({
  377. url: "/api/zone/options/get?token=" + token + "&zone=" + zone,
  378. success: function (responseJSON) {
  379. $("#txtZoneTransferNameServers").prop("disabled", true);
  380. $("#txtZoneNotifyNameServers").prop("disabled", true);
  381. switch (responseJSON.response.zoneTransfer) {
  382. case "Allow":
  383. $("#rdZoneTransferAllow").prop("checked", true);
  384. break;
  385. case "AllowOnlyZoneNameServers":
  386. $("#rdZoneTransferAllowOnlyZoneNameServers").prop("checked", true);
  387. break;
  388. case "AllowOnlySpecifiedNameServers":
  389. $("#rdZoneTransferAllowOnlySpecifiedNameServers").prop("checked", true);
  390. $("#txtZoneTransferNameServers").prop("disabled", false);
  391. break;
  392. case "Deny":
  393. default:
  394. $("#rdZoneTransferDeny").prop("checked", true);
  395. break;
  396. }
  397. {
  398. var value = "";
  399. for (var i = 0; i < responseJSON.response.zoneTransferNameServers.length; i++)
  400. value += responseJSON.response.zoneTransferNameServers[i] + "\r\n";
  401. $("#txtZoneTransferNameServers").val(value);
  402. }
  403. switch (responseJSON.response.notify) {
  404. case "ZoneNameServers":
  405. $("#rdZoneNotifyZoneNameServers").prop("checked", true);
  406. break;
  407. case "SpecifiedNameServers":
  408. $("#rdZoneNotifySpecifiedNameServers").prop("checked", true);
  409. $("#txtZoneNotifyNameServers").prop("disabled", false);
  410. break;
  411. case "None":
  412. default:
  413. $("#rdZoneNotifyNone").prop("checked", true);
  414. break;
  415. }
  416. {
  417. var value = "";
  418. for (var i = 0; i < responseJSON.response.notifyNameServers.length; i++)
  419. value += responseJSON.response.notifyNameServers[i] + "\r\n";
  420. $("#txtZoneNotifyNameServers").val(value);
  421. }
  422. {
  423. var value = "";
  424. if (responseJSON.response.zoneTransferTsigKeyNames != null) {
  425. for (var i = 0; i < responseJSON.response.zoneTransferTsigKeyNames.length; i++) {
  426. value += responseJSON.response.zoneTransferTsigKeyNames[i] + "\r\n";
  427. }
  428. }
  429. $("#txtZoneOptionsZoneTransferTsigKeyNames").val(value);
  430. }
  431. {
  432. var options = "<option value=\"blank\" selected></option><option value=\"none\">None</option>";
  433. if (responseJSON.response.availableTsigKeyNames != null) {
  434. for (var i = 0; i < responseJSON.response.availableTsigKeyNames.length; i++) {
  435. options += "<option>" + htmlEncode(responseJSON.response.availableTsigKeyNames[i]) + "</option>";
  436. }
  437. }
  438. $("#optZoneOptionsQuickTsigKeyNames").html(options);
  439. }
  440. divZoneOptionsLoader.hide();
  441. divZoneOptions.show();
  442. },
  443. error: function () {
  444. divZoneOptionsLoader.hide();
  445. },
  446. invalidToken: function () {
  447. $("#modalZoneOptions").modal("hide");
  448. showPageLogin();
  449. },
  450. objAlertPlaceholder: divZoneOptionsAlert,
  451. objLoaderPlaceholder: divZoneOptionsLoader
  452. });
  453. }
  454. function saveZoneOptions() {
  455. var divZoneOptionsAlert = $("#divZoneOptionsAlert");
  456. var divZoneOptionsLoader = $("#divZoneOptionsLoader");
  457. var zone = $("#lblZoneOptionsZoneName").text();
  458. var zoneTransfer = $("input[name=rdZoneTransfer]:checked").val();
  459. var zoneTransferNameServers = cleanTextList($("#txtZoneTransferNameServers").val());
  460. if ((zoneTransferNameServers.length === 0) || (zoneTransferNameServers === ","))
  461. zoneTransferNameServers = false;
  462. else
  463. $("#txtZoneTransferNameServers").val(zoneTransferNameServers.replace(/,/g, "\n"));
  464. var notify = $("input[name=rdZoneNotify]:checked").val();
  465. var notifyNameServers = cleanTextList($("#txtZoneNotifyNameServers").val());
  466. if ((notifyNameServers.length === 0) || (notifyNameServers === ","))
  467. notifyNameServers = false;
  468. else
  469. $("#txtZoneNotifyNameServers").val(notifyNameServers.replace(/,/g, "\n"));
  470. var zoneTransferTsigKeyNames = cleanTextList($("#txtZoneOptionsZoneTransferTsigKeyNames").val());
  471. if ((zoneTransferTsigKeyNames.length === 0) || (zoneTransferTsigKeyNames === ","))
  472. zoneTransferTsigKeyNames = false;
  473. else
  474. $("#txtZoneOptionsZoneTransferTsigKeyNames").val(zoneTransferTsigKeyNames.replace(/,/g, "\n"));
  475. var btn = $("#btnSaveZoneOptions");
  476. btn.button('loading');
  477. HTTPRequest({
  478. url: "/api/zone/options/set?token=" + token + "&zone=" + zone
  479. + "&zoneTransfer=" + zoneTransfer + "&zoneTransferNameServers=" + encodeURIComponent(zoneTransferNameServers)
  480. + "&notify=" + notify + "&notifyNameServers=" + encodeURIComponent(notifyNameServers)
  481. + "&zoneTransferTsigKeyNames=" + encodeURIComponent(zoneTransferTsigKeyNames),
  482. success: function (responseJSON) {
  483. btn.button('reset');
  484. $("#modalZoneOptions").modal("hide");
  485. showAlert("success", "Options Saved!", "Zone options were saved successfully.");
  486. },
  487. error: function () {
  488. btn.button('reset');
  489. divZoneOptionsLoader.hide();
  490. },
  491. invalidToken: function () {
  492. btn.button('reset');
  493. $("#modalZoneOptions").modal("hide");
  494. showPageLogin();
  495. },
  496. objAlertPlaceholder: divZoneOptionsAlert,
  497. objLoaderPlaceholder: divZoneOptionsLoader
  498. });
  499. }
  500. function resyncZone(objBtn, domain) {
  501. if ($("#titleEditZoneType").text() == "Secondary") {
  502. if (!confirm("The resync action will perform a full zone transfer (AXFR). You will need to check the logs to confirm if the resync action was successful.\r\n\r\nAre you sure you want to resync the '" + domain + "' zone?"))
  503. return;
  504. }
  505. else {
  506. if (!confirm("The resync action will perform a full zone refresh. You will need to check the logs to confirm if the resync action was successful.\r\n\r\nAre you sure you want to resync the '" + domain + "' zone?"))
  507. return;
  508. }
  509. var btn = $(objBtn);
  510. btn.button('loading');
  511. HTTPRequest({
  512. url: "/api/zone/resync?token=" + token + "&domain=" + domain,
  513. success: function (responseJSON) {
  514. btn.button('reset');
  515. showAlert("success", "Resync Triggered!", "Zone '" + domain + "' resync was triggered successfully. Please check the Logs for confirmation.");
  516. },
  517. error: function () {
  518. btn.button('reset');
  519. },
  520. invalidToken: function () {
  521. btn.button('reset');
  522. showPageLogin();
  523. }
  524. });
  525. }
  526. function showAddZoneModal() {
  527. $("#divAddZoneAlert").html("");
  528. $("#txtAddZone").val("");
  529. $("#rdAddZoneTypePrimary").prop("checked", true);
  530. $("#txtAddZonePrimaryNameServerAddresses").val("");
  531. $("#rdAddZoneZoneTransferProtocolTcp").prop("checked", true);
  532. $("#optAddZoneTsigKeyName").val("");
  533. $("input[name=rdAddZoneForwarderProtocol]:radio").attr("disabled", false);
  534. $("#rdAddZoneForwarderProtocolUdp").prop("checked", true);
  535. $("#chkAddZoneForwarderThisServer").prop("checked", false);
  536. $("#txtAddZoneForwarder").prop("disabled", false);
  537. $("#txtAddZoneForwarder").attr("placeholder", "8.8.8.8 or [2620:fe::10]")
  538. $("#txtAddZoneForwarder").val("");
  539. $("#chkAddZoneForwarderDnssecValidation").prop("checked", false);
  540. $("#rdAddZoneForwarderProxyTypeNone").prop("checked", true);
  541. $("#txtAddZoneForwarderProxyAddress").prop("disabled", true);
  542. $("#txtAddZoneForwarderProxyPort").prop("disabled", true);
  543. $("#txtAddZoneForwarderProxyUsername").prop("disabled", true);
  544. $("#txtAddZoneForwarderProxyPassword").prop("disabled", true);
  545. $("#txtAddZoneForwarderProxyAddress").val("");
  546. $("#txtAddZoneForwarderProxyPort").val("");
  547. $("#txtAddZoneForwarderProxyUsername").val("");
  548. $("#txtAddZoneForwarderProxyPassword").val("");
  549. $("#divAddZonePrimaryNameServerAddresses").hide();
  550. $("#divAddZoneZoneTransferProtocol").hide();
  551. $("#divAddZoneTsigKeyName").hide();
  552. $("#divAddZoneForwarderProtocol").hide();
  553. $("#divAddZoneForwarder").hide();
  554. $("#divAddZoneForwarderDnssecValidation").hide();
  555. $("#divAddZoneForwarderProxy").hide();
  556. $("#btnAddZone").button('reset');
  557. $("#modalAddZone").modal("show");
  558. setTimeout(function () {
  559. $("#txtAddZone").focus();
  560. }, 1000);
  561. }
  562. function updateAddZoneFormForwarderThisServer() {
  563. var useThisServer = $("#chkAddZoneForwarderThisServer").prop('checked');
  564. if (useThisServer) {
  565. $("input[name=rdAddZoneForwarderProtocol]:radio").attr("disabled", true);
  566. $("#rdAddZoneForwarderProtocolUdp").prop("checked", true);
  567. $("#txtAddZoneForwarder").attr("placeholder", "8.8.8.8 or [2620:fe::10]")
  568. $("#txtAddZoneForwarder").prop("disabled", true);
  569. $("#txtAddZoneForwarder").val("this-server");
  570. $("#divAddZoneForwarderProxy").hide();
  571. }
  572. else {
  573. $("input[name=rdAddZoneForwarderProtocol]:radio").attr("disabled", false);
  574. $("#txtAddZoneForwarder").prop("disabled", false);
  575. $("#txtAddZoneForwarder").val("");
  576. $("#divAddZoneForwarderProxy").show();
  577. }
  578. }
  579. function addZone() {
  580. var divAddZoneAlert = $("#divAddZoneAlert");
  581. var zone = $("#txtAddZone").val();
  582. if ((zone == null) || (zone === "")) {
  583. showAlert("warning", "Missing!", "Please enter a domain name to add zone.", divAddZoneAlert);
  584. $("#txtAddZone").focus();
  585. return;
  586. }
  587. var type = $('input[name=rdAddZoneType]:checked').val();
  588. var parameters;
  589. switch (type) {
  590. case "Secondary":
  591. var tsigKeyName = $("#optAddZoneTsigKeyName").val();
  592. parameters = "&primaryNameServerAddresses=" + encodeURIComponent(cleanTextList($("#txtAddZonePrimaryNameServerAddresses").val()));
  593. parameters += "&zoneTransferProtocol=" + $("input[name=rdAddZoneZoneTransferProtocol]:checked").val();
  594. parameters += "&tsigKeyName=" + encodeURIComponent(tsigKeyName);
  595. break;
  596. case "Stub":
  597. parameters = "&primaryNameServerAddresses=" + encodeURIComponent(cleanTextList($("#txtAddZonePrimaryNameServerAddresses").val()));
  598. break;
  599. case "Forwarder":
  600. var forwarder = $("#txtAddZoneForwarder").val();
  601. if ((forwarder == null) || (forwarder === "")) {
  602. showAlert("warning", "Missing!", "Please enter a forwarder server name to add zone.", divAddZoneAlert);
  603. $("#txtAddZoneForwarder").focus();
  604. return;
  605. }
  606. var dnssecValidation = $("#chkAddZoneForwarderDnssecValidation").prop("checked");
  607. parameters = "&protocol=" + $("input[name=rdAddZoneForwarderProtocol]:checked").val() + "&forwarder=" + encodeURIComponent(forwarder) + "&dnssecValidation=" + dnssecValidation;
  608. if (forwarder !== "this-server") {
  609. var proxyType = $("input[name=rdAddZoneForwarderProxyType]:checked").val();
  610. parameters += "&proxyType=" + proxyType;
  611. if (proxyType != "None") {
  612. var proxyAddress = $("#txtAddZoneForwarderProxyAddress").val();
  613. var proxyPort = $("#txtAddZoneForwarderProxyPort").val();
  614. var proxyUsername = $("#txtAddZoneForwarderProxyUsername").val();
  615. var proxyPassword = $("#txtAddZoneForwarderProxyPassword").val();
  616. if ((proxyAddress == null) || (proxyAddress === "")) {
  617. showAlert("warning", "Missing!", "Please enter a domain name or IP address for Proxy Server Address to add zone.", divAddZoneAlert);
  618. $("#txtAddZoneForwarderProxyAddress").focus();
  619. return;
  620. }
  621. if ((proxyPort == null) || (proxyPort === "")) {
  622. showAlert("warning", "Missing!", "Please enter a port number for Proxy Server Port to add zone.", divAddZoneAlert);
  623. $("#txtAddZoneForwarderProxyPort").focus();
  624. return;
  625. }
  626. parameters += "&proxyAddress=" + encodeURIComponent(proxyAddress) + "&proxyPort=" + proxyPort + "&proxyUsername=" + encodeURIComponent(proxyUsername) + "&proxyPassword=" + encodeURIComponent(proxyPassword);
  627. }
  628. }
  629. break;
  630. default:
  631. parameters = "";
  632. break;
  633. }
  634. var btn = $("#btnAddZone").button('loading');
  635. HTTPRequest({
  636. url: "/api/zone/create?token=" + token + "&zone=" + zone + "&type=" + type + parameters,
  637. success: function (responseJSON) {
  638. $("#modalAddZone").modal("hide");
  639. showEditZone(responseJSON.response.domain);
  640. showAlert("success", "Zone Added!", "Zone was added successfully.");
  641. },
  642. error: function () {
  643. btn.button('reset');
  644. },
  645. invalidToken: function () {
  646. $("#modalAddZone").modal("hide");
  647. showPageLogin();
  648. },
  649. objAlertPlaceholder: divAddZoneAlert
  650. });
  651. }
  652. function showEditZone(domain) {
  653. var divViewZonesLoader = $("#divViewZonesLoader");
  654. var divViewZones = $("#divViewZones");
  655. var divEditZone = $("#divEditZone");
  656. divViewZones.hide();
  657. divEditZone.hide();
  658. divViewZonesLoader.show();
  659. HTTPRequest({
  660. url: "/api/zone/getRecords?token=" + token + "&domain=" + domain,
  661. success: function (responseJSON) {
  662. var type;
  663. if (responseJSON.response.zone.internal)
  664. type = "Internal";
  665. else
  666. type = responseJSON.response.zone.type;
  667. switch (responseJSON.response.zone.dnssecStatus) {
  668. case "SignedWithNSEC":
  669. case "SignedWithNSEC3":
  670. $("#tdDnssecStatusEditZone").show();
  671. break;
  672. default:
  673. $("#tdDnssecStatusEditZone").hide();
  674. break;
  675. }
  676. var status;
  677. if (responseJSON.response.zone.disabled)
  678. status = "Disabled";
  679. else if (responseJSON.response.zone.isExpired)
  680. status = "Expired";
  681. else
  682. status = "Enabled";
  683. var expiry = responseJSON.response.zone.expiry;
  684. if (expiry == null)
  685. expiry = "&nbsp;";
  686. else
  687. expiry = "Expiry: " + moment(expiry).local().format("YYYY-MM-DD HH:mm:ss");
  688. $("#titleEditZoneType").html(type);
  689. $("#tdStatusEditZone").html(status);
  690. $("#titleEditZoneExpiry").html(expiry);
  691. if (responseJSON.response.zone.internal)
  692. $("#titleEditZoneType").attr("class", "label label-default");
  693. else
  694. $("#titleEditZoneType").attr("class", "label label-primary");
  695. switch (status) {
  696. case "Disabled":
  697. $("#tdStatusEditZone").attr("class", "label label-warning");
  698. break;
  699. case "Expired":
  700. $("#tdStatusEditZone").attr("class", "label label-danger");
  701. break;
  702. case "Enabled":
  703. $("#tdStatusEditZone").attr("class", "label label-success");
  704. break;
  705. }
  706. switch (type) {
  707. case "Internal":
  708. case "Secondary":
  709. case "Stub":
  710. $("#btnEditZoneAddRecord").hide();
  711. break;
  712. case "Forwarder":
  713. $("#btnEditZoneAddRecord").show();
  714. $("#optAddEditRecordTypeDs").hide();
  715. $("#optAddEditRecordTypeAName").show();
  716. $("#optAddEditRecordTypeFwd").show();
  717. $("#optAddEditRecordTypeApp").hide();
  718. break;
  719. case "Primary":
  720. $("#btnEditZoneAddRecord").show();
  721. $("#optAddEditRecordTypeFwd").hide();
  722. switch (responseJSON.response.zone.dnssecStatus) {
  723. case "SignedWithNSEC":
  724. case "SignedWithNSEC3":
  725. $("#optAddEditRecordTypeDs").show();
  726. $("#optAddEditRecordTypeAName").hide();
  727. $("#optAddEditRecordTypeApp").hide();
  728. break;
  729. default:
  730. $("#optAddEditRecordTypeDs").hide();
  731. $("#optAddEditRecordTypeAName").show();
  732. $("#optAddEditRecordTypeApp").show();
  733. break;
  734. }
  735. break;
  736. }
  737. if (responseJSON.response.zone.internal) {
  738. $("#btnEnableZoneEditZone").hide();
  739. $("#btnDisableZoneEditZone").hide();
  740. $("#btnEditZoneDeleteZone").hide();
  741. }
  742. else if (responseJSON.response.zone.disabled) {
  743. $("#btnEnableZoneEditZone").show();
  744. $("#btnDisableZoneEditZone").hide();
  745. $("#btnEditZoneDeleteZone").show();
  746. }
  747. else {
  748. $("#btnEnableZoneEditZone").hide();
  749. $("#btnDisableZoneEditZone").show();
  750. $("#btnEditZoneDeleteZone").show();
  751. }
  752. switch (type) {
  753. case "Secondary":
  754. case "Stub":
  755. $("#btnZoneResync").show();
  756. break;
  757. default:
  758. $("#btnZoneResync").hide();
  759. break;
  760. }
  761. switch (type) {
  762. case "Primary":
  763. case "Secondary":
  764. $("#btnZoneOptions").show();
  765. break;
  766. default:
  767. $("#btnZoneOptions").hide();
  768. break;
  769. }
  770. switch (type) {
  771. case "Primary":
  772. $("#divZoneDnssecOptions").show();
  773. switch (responseJSON.response.zone.dnssecStatus) {
  774. case "SignedWithNSEC":
  775. case "SignedWithNSEC3":
  776. $("#lnkZoneDnssecSignZone").hide();
  777. $("#lnkZoneDnssecProperties").show();
  778. $("#lnkZoneDnssecUnsignZone").show();
  779. break;
  780. default:
  781. $("#lnkZoneDnssecSignZone").show();
  782. $("#lnkZoneDnssecProperties").hide();
  783. $("#lnkZoneDnssecUnsignZone").hide();
  784. break;
  785. }
  786. break;
  787. default:
  788. $("#divZoneDnssecOptions").hide();
  789. break;
  790. }
  791. var records = responseJSON.response.records;
  792. var tableHtmlRows = "";
  793. for (var i = 0; i < records.length; i++) {
  794. var id = Math.floor(Math.random() * 10000);
  795. var name = records[i].name.toLowerCase();
  796. if (name === "")
  797. name = ".";
  798. if (name === domain)
  799. name = "@";
  800. else
  801. name = name.replace("." + domain, "");
  802. tableHtmlRows += "<tr id=\"tr" + id + "\"><td>" + htmlEncode(name) + "</td>";
  803. tableHtmlRows += "<td>" + records[i].type + "</td>";
  804. tableHtmlRows += "<td>" + records[i].ttl + "</td>";
  805. var additionalDataAttributes = "";
  806. switch (records[i].type.toUpperCase()) {
  807. case "A":
  808. case "AAAA":
  809. tableHtmlRows += "<td style=\"word-break: break-all;\">" + htmlEncode(records[i].rData.ipAddress);
  810. if ((records[i].comments != null) && (records[i].comments.length > 0))
  811. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  812. tableHtmlRows += "</td>";
  813. additionalDataAttributes = "data-record-ip-address=\"" + htmlEncode(records[i].rData.ipAddress) + "\" ";
  814. break;
  815. case "NS":
  816. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>Name Server:</b> " + htmlEncode(records[i].rData.nameServer);
  817. if (records[i].glueRecords != null) {
  818. tableHtmlRows += "<br /><b>Glue Addresses:</b> " + records[i].glueRecords;
  819. additionalDataAttributes = "data-record-glue=\"" + htmlEncode(records[i].glueRecords) + "\" ";
  820. } else {
  821. additionalDataAttributes = "data-record-glue=\"\" ";
  822. }
  823. if ((records[i].comments != null) && (records[i].comments.length > 0))
  824. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  825. tableHtmlRows += "</td>";
  826. additionalDataAttributes += "data-record-name-server=\"" + htmlEncode(records[i].rData.nameServer) + "\" ";
  827. break;
  828. case "CNAME":
  829. tableHtmlRows += "<td style=\"word-break: break-all;\">" + htmlEncode(records[i].rData.cname);
  830. if ((records[i].comments != null) && (records[i].comments.length > 0))
  831. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  832. tableHtmlRows += "</td>";
  833. additionalDataAttributes = "data-record-cname=\"" + htmlEncode(records[i].rData.cname) + "\" ";
  834. break;
  835. case "SOA":
  836. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>Primary Name Server:</b> " + htmlEncode(records[i].rData.primaryNameServer) +
  837. "<br /><b>Responsible Person:</b> " + htmlEncode(records[i].rData.responsiblePerson) +
  838. "<br /><b>Serial:</b> " + htmlEncode(records[i].rData.serial) +
  839. "<br /><b>Refresh:</b> " + htmlEncode(records[i].rData.refresh) +
  840. "<br /><b>Retry:</b> " + htmlEncode(records[i].rData.retry) +
  841. "<br /><b>Expire:</b> " + htmlEncode(records[i].rData.expire) +
  842. "<br /><b>Minimum:</b> " + htmlEncode(records[i].rData.minimum);
  843. if (records[i].rData.primaryAddresses != null) {
  844. tableHtmlRows += "<br /><b>Primary Name Server Addresses:</b> " + records[i].rData.primaryAddresses;
  845. additionalDataAttributes = "data-record-paddresses=\"" + htmlEncode(records[i].rData.primaryAddresses) + "\" ";
  846. } else {
  847. additionalDataAttributes = "data-record-paddresses=\"\" ";
  848. }
  849. if (records[i].rData.zoneTransferProtocol != null) {
  850. tableHtmlRows += "<br /><b>Zone Transfer Protocol:</b> XFR-over-" + records[i].rData.zoneTransferProtocol.toUpperCase();
  851. additionalDataAttributes += "data-record-zonetransferprotocol=\"" + htmlEncode(records[i].rData.zoneTransferProtocol) + "\" ";
  852. } else {
  853. additionalDataAttributes += "data-record-zonetransferprotocol=\"\" ";
  854. }
  855. if (records[i].rData.tsigKeyName != null) {
  856. tableHtmlRows += "<br /><b>TSIG Key Name:</b> " + records[i].rData.tsigKeyName;
  857. additionalDataAttributes += "data-record-tsigkeyname=\"" + htmlEncode(records[i].rData.tsigKeyName) + "\" ";
  858. } else {
  859. additionalDataAttributes += "data-record-tsigkeyname=\"\" ";
  860. }
  861. if ((records[i].comments != null) && (records[i].comments.length > 0))
  862. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  863. tableHtmlRows += "</td>";
  864. additionalDataAttributes += "data-record-pname=\"" + htmlEncode(records[i].rData.primaryNameServer) + "\" " +
  865. "data-record-rperson=\"" + htmlEncode(records[i].rData.responsiblePerson) + "\" " +
  866. "data-record-serial=\"" + htmlEncode(records[i].rData.serial) + "\" " +
  867. "data-record-refresh=\"" + htmlEncode(records[i].rData.refresh) + "\" " +
  868. "data-record-retry=\"" + htmlEncode(records[i].rData.retry) + "\" " +
  869. "data-record-expire=\"" + htmlEncode(records[i].rData.expire) + "\" " +
  870. "data-record-minimum=\"" + htmlEncode(records[i].rData.minimum) + "\" ";
  871. break;
  872. case "PTR":
  873. tableHtmlRows += "<td style=\"word-break: break-all;\">" + htmlEncode(records[i].rData.ptrName);
  874. if ((records[i].comments != null) && (records[i].comments.length > 0))
  875. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  876. tableHtmlRows += "</td>";
  877. additionalDataAttributes = "data-record-ptr-name=\"" + htmlEncode(records[i].rData.ptrName) + "\" ";
  878. break;
  879. case "MX":
  880. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>Preference: </b> " + htmlEncode(records[i].rData.preference) +
  881. "<br /><b>Exchange:</b> " + htmlEncode(records[i].rData.exchange);
  882. if ((records[i].comments != null) && (records[i].comments.length > 0))
  883. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  884. tableHtmlRows += "</td>";
  885. additionalDataAttributes = "data-record-preference=\"" + htmlEncode(records[i].rData.preference) + "\" " +
  886. "data-record-exchange=\"" + htmlEncode(records[i].rData.exchange) + "\" ";
  887. break;
  888. case "TXT":
  889. tableHtmlRows += "<td style=\"word-break: break-all;\">" + htmlEncode(records[i].rData.text);
  890. if ((records[i].comments != null) && (records[i].comments.length > 0))
  891. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  892. tableHtmlRows += "</td>";
  893. additionalDataAttributes = "data-record-text=\"" + htmlEncode(records[i].rData.text) + "\" ";
  894. break;
  895. case "SRV":
  896. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>Priority: </b> " + htmlEncode(records[i].rData.priority) +
  897. "<br /><b>Weight:</b> " + htmlEncode(records[i].rData.weight) +
  898. "<br /><b>Port:</b> " + htmlEncode(records[i].rData.port) +
  899. "<br /><b>Target:</b> " + htmlEncode(records[i].rData.target);
  900. if ((records[i].comments != null) && (records[i].comments.length > 0))
  901. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  902. tableHtmlRows += "</td>";
  903. additionalDataAttributes = "data-record-priority=\"" + htmlEncode(records[i].rData.priority) + "\" " +
  904. "data-record-weight=\"" + htmlEncode(records[i].rData.weight) + "\" " +
  905. "data-record-port=\"" + htmlEncode(records[i].rData.port) + "\" " +
  906. "data-record-target=\"" + htmlEncode(records[i].rData.target) + "\" ";
  907. break;
  908. case "DNAME":
  909. tableHtmlRows += "<td style=\"word-break: break-all;\">" + htmlEncode(records[i].rData.dname);
  910. if ((records[i].comments != null) && (records[i].comments.length > 0))
  911. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  912. tableHtmlRows += "</td>";
  913. additionalDataAttributes = "data-record-dname=\"" + htmlEncode(records[i].rData.dname) + "\" ";
  914. break;
  915. case "DS":
  916. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>Key Tag: </b> " + htmlEncode(records[i].rData.keyTag) +
  917. "<br /><b>Algorithm:</b> " + htmlEncode(records[i].rData.algorithm) +
  918. "<br /><b>Digest Type:</b> " + htmlEncode(records[i].rData.digestType) +
  919. "<br /><b>Digest:</b> " + htmlEncode(records[i].rData.digest);
  920. if ((records[i].comments != null) && (records[i].comments.length > 0))
  921. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  922. tableHtmlRows += "</td>";
  923. additionalDataAttributes = "data-record-key-tag=\"" + htmlEncode(records[i].rData.keyTag) + "\" " +
  924. "data-record-algorithm=\"" + htmlEncode(records[i].rData.algorithm) + "\" " +
  925. "data-record-digest-type=\"" + htmlEncode(records[i].rData.digestType) + "\" " +
  926. "data-record-digest=\"" + htmlEncode(records[i].rData.digest) + "\" ";
  927. break;
  928. case "RRSIG":
  929. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>Type Covered: </b> " + htmlEncode(records[i].rData.typeCovered) +
  930. "<br /><b>Algorithm:</b> " + htmlEncode(records[i].rData.algorithm) +
  931. "<br /><b>Labels:</b> " + htmlEncode(records[i].rData.labels) +
  932. "<br /><b>Original TTL:</b> " + htmlEncode(records[i].rData.originalTtl) +
  933. "<br /><b>Signature Expiration:</b> " + htmlEncode(records[i].rData.signatureExpiration) +
  934. "<br /><b>Signature Inception:</b> " + htmlEncode(records[i].rData.signatureInception) +
  935. "<br /><b>Key Tag:</b> " + htmlEncode(records[i].rData.keyTag) +
  936. "<br /><b>Signer's Name:</b> " + htmlEncode(records[i].rData.signersName) +
  937. "<br /><b>Signature:</b> " + htmlEncode(records[i].rData.signature);
  938. if ((records[i].comments != null) && (records[i].comments.length > 0))
  939. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  940. tableHtmlRows += "</td>";
  941. additionalDataAttributes = "";
  942. break;
  943. case "NSEC":
  944. var nsecTypes = null;
  945. for (var j = 0; j < records[i].rData.types.length; j++) {
  946. if (nsecTypes == null)
  947. nsecTypes = records[i].rData.types[j];
  948. else
  949. nsecTypes += ", " + records[i].rData.types[j];
  950. }
  951. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>Next Domain Name: </b> " + htmlEncode(records[i].rData.nextDomainName) +
  952. "<br /><b>Types:</b> " + htmlEncode(nsecTypes);
  953. if ((records[i].comments != null) && (records[i].comments.length > 0))
  954. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  955. tableHtmlRows += "</td>";
  956. additionalDataAttributes = "";
  957. break;
  958. case "DNSKEY":
  959. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>Flags: </b> " + htmlEncode(records[i].rData.flags) +
  960. "<br /><b>Protocol:</b> " + htmlEncode(records[i].rData.protocol) +
  961. "<br /><b>Algorithm:</b> " + htmlEncode(records[i].rData.algorithm) +
  962. "<br /><b>Public Key:</b> " + htmlEncode(records[i].rData.publicKey);
  963. tableHtmlRows += "<br /><br /><b>Key State:</b> " + htmlEncode(records[i].rData.dnsKeyState);
  964. tableHtmlRows += "<br /><b>Computed Key Tag:</b> " + htmlEncode(records[i].rData.computedKeyTag);
  965. if (records[i].rData.computedDigests != null) {
  966. tableHtmlRows += "<br /><b>Computed Digests:</b> ";
  967. for (var j = 0; j < records[i].rData.computedDigests.length; j++) {
  968. tableHtmlRows += "<br />" + htmlEncode(records[i].rData.computedDigests[j].digestType) + ": " + htmlEncode(records[i].rData.computedDigests[j].digest)
  969. }
  970. }
  971. if ((records[i].comments != null) && (records[i].comments.length > 0))
  972. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  973. tableHtmlRows += "</td>";
  974. additionalDataAttributes = "";
  975. break;
  976. case "NSEC3":
  977. var nsec3Types = null;
  978. for (var j = 0; j < records[i].rData.types.length; j++) {
  979. if (nsec3Types == null)
  980. nsec3Types = records[i].rData.types[j];
  981. else
  982. nsec3Types += ", " + records[i].rData.types[j];
  983. }
  984. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>Hash Algorithm: </b> " + htmlEncode(records[i].rData.hashAlgorithm) +
  985. "<br /><b>Flags: </b> " + htmlEncode(records[i].rData.flags) +
  986. "<br /><b>Iterations: </b> " + htmlEncode(records[i].rData.iterations) +
  987. "<br /><b>Salt: </b>" + htmlEncode(records[i].rData.salt) +
  988. "<br /><b>Next Hashed Owner Name: </b> " + htmlEncode(records[i].rData.nextHashedOwnerName) +
  989. "<br /><b>Types:</b> " + htmlEncode(nsec3Types);
  990. if ((records[i].comments != null) && (records[i].comments.length > 0))
  991. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  992. tableHtmlRows += "</td>";
  993. additionalDataAttributes = "";
  994. break;
  995. case "NSEC3PARAM":
  996. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>Hash Algorithm: </b> " + htmlEncode(records[i].rData.hashAlgorithm) +
  997. "<br /><b>Flags: </b> " + htmlEncode(records[i].rData.flags) +
  998. "<br /><b>Iterations: </b> " + htmlEncode(records[i].rData.iterations) +
  999. "<br /><b>Salt: </b>" + htmlEncode(records[i].rData.salt);
  1000. if ((records[i].comments != null) && (records[i].comments.length > 0))
  1001. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  1002. tableHtmlRows += "</td>";
  1003. additionalDataAttributes = "";
  1004. break;
  1005. case "CAA":
  1006. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>Flags: </b> " + htmlEncode(records[i].rData.flags) +
  1007. "<br /><b>Tag:</b> " + htmlEncode(records[i].rData.tag) +
  1008. "<br /><b>Authority:</b> " + htmlEncode(records[i].rData.value);
  1009. if ((records[i].comments != null) && (records[i].comments.length > 0))
  1010. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  1011. tableHtmlRows += "</td>";
  1012. additionalDataAttributes = "data-record-flags=\"" + htmlEncode(records[i].rData.flags) + "\" " +
  1013. "data-record-tag=\"" + htmlEncode(records[i].rData.tag) + "\" " +
  1014. "data-record-value=\"" + htmlEncode(records[i].rData.value) + "\" ";
  1015. break;
  1016. case "ANAME":
  1017. tableHtmlRows += "<td style=\"word-break: break-all;\">" + htmlEncode(records[i].rData.aname);
  1018. if ((records[i].comments != null) && (records[i].comments.length > 0))
  1019. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  1020. tableHtmlRows += "</td>";
  1021. additionalDataAttributes = "data-record-aname=\"" + htmlEncode(records[i].rData.aname) + "\" ";
  1022. break;
  1023. case "FWD":
  1024. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>Protocol: </b> " + htmlEncode(records[i].rData.protocol) +
  1025. "<br /><b>Forwarder:</b> " + htmlEncode(records[i].rData.forwarder) +
  1026. "<br /><b>Enable DNSSEC Validation:</b> " + htmlEncode(records[i].rData.dnssecValidation) +
  1027. "<br /><b>Proxy Type:</b> " + htmlEncode(records[i].rData.proxyType);
  1028. if (records[i].rData.proxyType !== "None") {
  1029. tableHtmlRows += "<br /><b>Proxy Address:</b> " + htmlEncode(records[i].rData.proxyAddress) +
  1030. "<br /><b>Proxy Port:</b> " + htmlEncode(records[i].rData.proxyPort) +
  1031. "<br /><b>Proxy Username:</b> " + htmlEncode(records[i].rData.proxyUsername) +
  1032. "<br /><b>Proxy Password:</b> ************";
  1033. }
  1034. if ((records[i].comments != null) && (records[i].comments.length > 0))
  1035. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  1036. tableHtmlRows += "</td>";
  1037. additionalDataAttributes = "data-record-protocol=\"" + htmlEncode(records[i].rData.protocol) + "\" " +
  1038. "data-record-forwarder=\"" + htmlEncode(records[i].rData.forwarder) + "\" " +
  1039. "data-record-dnssec-validation=\"" + htmlEncode(records[i].rData.dnssecValidation) + "\" " +
  1040. "data-record-proxy-type=\"" + htmlEncode(records[i].rData.proxyType) + "\" ";
  1041. if (records[i].rData.proxyType != "None") {
  1042. additionalDataAttributes += "data-record-proxy-address=\"" + htmlEncode(records[i].rData.proxyAddress) + "\" " +
  1043. "data-record-proxy-port=\"" + htmlEncode(records[i].rData.proxyPort) + "\" " +
  1044. "data-record-proxy-username=\"" + htmlEncode(records[i].rData.proxyUsername) + "\" " +
  1045. "data-record-proxy-password=\"" + htmlEncode(records[i].rData.proxyPassword) + "\" ";
  1046. }
  1047. break;
  1048. case "APP":
  1049. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>App Name: </b> " + htmlEncode(records[i].rData.appName) +
  1050. "<br /><b>Class Path:</b> " + htmlEncode(records[i].rData.classPath) +
  1051. "<br /><b>Record Data:</b> " + (records[i].rData.data == "" ? "" : "<pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].rData.data) + "</pre>");
  1052. if ((records[i].comments != null) && (records[i].comments.length > 0))
  1053. tableHtmlRows += "<br /><br /><b>Comments:</b> <pre style=\"white-space: pre-wrap;\">" + htmlEncode(records[i].comments) + "</pre>";
  1054. tableHtmlRows += "</td>";
  1055. additionalDataAttributes = "data-record-app-name=\"" + htmlEncode(records[i].rData.appName) + "\" " +
  1056. "data-record-classpath=\"" + htmlEncode(records[i].rData.classPath) + "\" " +
  1057. "data-record-data=\"" + htmlEncode(records[i].rData.data) + "\"";
  1058. break;
  1059. default:
  1060. tableHtmlRows += "<td style=\"word-break: break-all;\"><b>RDATA:</b> " + htmlEncode(records[i].rData.value) + "</td>";
  1061. break;
  1062. }
  1063. var hideActionButtons = false;
  1064. var disableEnableDisableDeleteButtons = false;
  1065. switch (type) {
  1066. case "Internal":
  1067. hideActionButtons = true;
  1068. break;
  1069. case "Secondary":
  1070. switch (records[i].type) {
  1071. case "SOA":
  1072. disableEnableDisableDeleteButtons = true;
  1073. break;
  1074. default:
  1075. hideActionButtons = true;
  1076. break;
  1077. }
  1078. break;
  1079. case "Stub":
  1080. switch (records[i].type) {
  1081. case "SOA":
  1082. disableEnableDisableDeleteButtons = true;
  1083. break;
  1084. case "NS":
  1085. if (name == "@")
  1086. hideActionButtons = true;
  1087. break;
  1088. }
  1089. break;
  1090. default:
  1091. switch (records[i].type) {
  1092. case "SOA":
  1093. disableEnableDisableDeleteButtons = true;
  1094. break;
  1095. case "DNSKEY":
  1096. case "RRSIG":
  1097. case "NSEC":
  1098. case "NSEC3":
  1099. case "NSEC3PARAM":
  1100. hideActionButtons = true;
  1101. break;
  1102. }
  1103. break;
  1104. }
  1105. if (hideActionButtons) {
  1106. tableHtmlRows += "<td align=\"right\">&nbsp;</td>";
  1107. }
  1108. else {
  1109. tableHtmlRows += "<td align=\"right\" style=\"min-width: 220px;\">";
  1110. tableHtmlRows += "<div id=\"data" + id + "\" data-record-name=\"" + htmlEncode(records[i].name) + "\" data-record-type=\"" + records[i].type + "\" data-record-ttl=\"" + records[i].ttl + "\" " + additionalDataAttributes + " data-record-disabled=\"" + records[i].disabled + "\" data-record-comments=\"" + htmlEncode(records[i].comments) + "\" style=\"display: none;\"></div>";
  1111. tableHtmlRows += "<button type=\"button\" class=\"btn btn-primary\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 0 0;\" data-id=\"" + id + "\" onclick=\"showEditRecordModal(this);\">Edit</button>";
  1112. tableHtmlRows += "<button type=\"button\" class=\"btn btn-default\" id=\"btnEnableRecord" + id + "\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 0 0;" + (records[i].disabled ? "" : " display: none;") + "\" data-id=\"" + id + "\" onclick=\"updateRecordState(this, false);\"" + (disableEnableDisableDeleteButtons ? " disabled" : "") + " data-loading-text=\"Enabling...\">Enable</button>";
  1113. tableHtmlRows += "<button type=\"button\" class=\"btn btn-warning\" id=\"btnDisableRecord" + id + "\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 0 0;" + (!records[i].disabled ? "" : " display: none;") + "\" data-id=\"" + id + "\" onclick=\"updateRecordState(this, true);\"" + (disableEnableDisableDeleteButtons ? " disabled" : "") + " data-loading-text=\"Disabling...\">Disable</button>";
  1114. tableHtmlRows += "<button type=\"button\" class=\"btn btn-danger\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 0 0;\" data-loading-text=\"Deleting...\" data-id=\"" + id + "\" onclick=\"deleteRecord(this);\"" + (disableEnableDisableDeleteButtons ? " disabled" : "") + ">Delete</button></td>";
  1115. }
  1116. tableHtmlRows += "</tr>";
  1117. }
  1118. $("#titleEditZone").text(domain);
  1119. $("#tableEditZoneBody").html(tableHtmlRows);
  1120. if (records.length > 0)
  1121. $("#tableEditZoneFooter").html("<tr><td colspan=\"5\"><b>Total Records: " + records.length + "</b></td></tr>");
  1122. else
  1123. $("#tableEditZoneFooter").html("<tr><td colspan=\"5\" align=\"center\">No Records Found</td></tr>");
  1124. divViewZonesLoader.hide();
  1125. divEditZone.show();
  1126. },
  1127. error: function () {
  1128. divViewZonesLoader.hide();
  1129. divViewZones.show();
  1130. },
  1131. invalidToken: function () {
  1132. showPageLogin();
  1133. },
  1134. objLoaderPlaceholder: divViewZonesLoader
  1135. });
  1136. }
  1137. function clearAddEditForm() {
  1138. $("#divAddEditRecordAlert").html("");
  1139. $("#txtAddEditRecordName").prop("placeholder", "@");
  1140. $("#txtAddEditRecordName").prop("disabled", false);
  1141. $("#optAddEditRecordType").prop("disabled", false);
  1142. $("#txtAddEditRecordTtl").prop("disabled", false);
  1143. $("#divAddEditRecordTtl").show();
  1144. $("#txtAddEditRecordName").val("");
  1145. $("#optAddEditRecordType").val("A");
  1146. $("#txtAddEditRecordTtl").val("");
  1147. $("#divAddEditRecordData").show();
  1148. $("#lblAddEditRecordDataValue").text("IPv4 Address");
  1149. $("#txtAddEditRecordDataValue").val("");
  1150. $("#divAddEditRecordDataPtr").show();
  1151. $("#chkAddEditRecordDataPtr").prop("checked", false);
  1152. $("#chkAddEditRecordDataCreatePtrZone").prop('disabled', true);
  1153. $("#chkAddEditRecordDataCreatePtrZone").prop("checked", false);
  1154. $("#chkAddEditRecordDataPtrLabel").text("Add reverse (PTR) record");
  1155. $("#divAddEditRecordDataNs").hide();
  1156. $("#txtAddEditRecordDataNsNameServer").prop("disabled", false);
  1157. $("#txtAddEditRecordDataNsNameServer").val("");
  1158. $("#txtAddEditRecordDataNsGlue").val("");
  1159. $("#divEditRecordDataSoa").hide();
  1160. $("#txtEditRecordDataSoaPrimaryNameServer").prop("disabled", false);
  1161. $("#txtEditRecordDataSoaResponsiblePerson").prop("disabled", false);
  1162. $("#txtEditRecordDataSoaSerial").prop("disabled", false);
  1163. $("#txtEditRecordDataSoaRefresh").prop("disabled", false);
  1164. $("#txtEditRecordDataSoaRetry").prop("disabled", false);
  1165. $("#txtEditRecordDataSoaExpire").prop("disabled", false);
  1166. $("#txtEditRecordDataSoaMinimum").prop("disabled", false);
  1167. $("#txtEditRecordDataSoaPrimaryNameServer").val("");
  1168. $("#txtEditRecordDataSoaResponsiblePerson").val("");
  1169. $("#txtEditRecordDataSoaSerial").val("");
  1170. $("#txtEditRecordDataSoaRefresh").val("");
  1171. $("#txtEditRecordDataSoaRetry").val("");
  1172. $("#txtEditRecordDataSoaExpire").val("");
  1173. $("#txtEditRecordDataSoaMinimum").val("");
  1174. $("#divAddEditRecordDataMx").hide();
  1175. $("#txtAddEditRecordDataMxPreference").val("");
  1176. $("#txtAddEditRecordDataMxExchange").val("");
  1177. $("#divAddEditRecordDataSrv").hide();
  1178. $("#txtAddEditRecordDataSrvPriority").val("");
  1179. $("#txtAddEditRecordDataSrvWeight").val("");
  1180. $("#txtAddEditRecordDataSrvPort").val("");
  1181. $("#txtAddEditRecordDataSrvTarget").val("");
  1182. $("#divAddEditRecordDataDs").hide();
  1183. $("#txtAddEditRecordDataDsKeyTag").val("");
  1184. $("#optAddEditRecordDataDsAlgorithm").val("");
  1185. $("#optAddEditRecordDataDsDigestType").val("");
  1186. $("#txtAddEditRecordDataDsDigest").val("");
  1187. $("#divAddEditRecordDataCaa").hide();
  1188. $("#txtAddEditRecordDataCaaFlags").val("");
  1189. $("#txtAddEditRecordDataCaaTag").val("");
  1190. $("#txtAddEditRecordDataCaaValue").val("");
  1191. $("#divAddEditRecordDataForwarder").hide();
  1192. $("#rdAddEditRecordDataForwarderProtocolUdp").prop("checked", true);
  1193. $("input[name=rdAddEditRecordDataForwarderProtocol]:radio").attr('disabled', false);
  1194. $("#chkAddEditRecordDataForwarderThisServer").prop("checked", false);
  1195. $('#txtAddEditRecordDataForwarder').prop('disabled', false);
  1196. $("#txtAddEditRecordDataForwarder").attr("placeholder", "8.8.8.8 or [2620:fe::10]")
  1197. $("#txtAddEditRecordDataForwarder").val("");
  1198. $("#chkAddEditRecordDataForwarderDnssecValidation").prop("checked", false);
  1199. $("#rdAddEditRecordDataForwarderProxyTypeNone").prop("checked", true);
  1200. $("#txtAddEditRecordDataForwarderProxyAddress").prop("disabled", true);
  1201. $("#txtAddEditRecordDataForwarderProxyPort").prop("disabled", true);
  1202. $("#txtAddEditRecordDataForwarderProxyUsername").prop("disabled", true);
  1203. $("#txtAddEditRecordDataForwarderProxyPassword").prop("disabled", true);
  1204. $("#txtAddEditRecordDataForwarderProxyAddress").val("");
  1205. $("#txtAddEditRecordDataForwarderProxyPort").val("");
  1206. $("#txtAddEditRecordDataForwarderProxyUsername").val("");
  1207. $("#txtAddEditRecordDataForwarderProxyPassword").val("");
  1208. $("#divAddEditRecordDataApplication").hide();
  1209. $("#optAddEditRecordDataAppName").html("");
  1210. $("#optAddEditRecordDataAppName").attr('disabled', false);
  1211. $("#optAddEditRecordDataClassPath").html("");
  1212. $("#optAddEditRecordDataClassPath").attr('disabled', false);
  1213. $("#txtAddEditRecordDataData").val("");
  1214. $("#divAddEditRecordOverwrite").show();
  1215. $("#chkAddEditRecordOverwrite").prop("checked", false);
  1216. $("#txtAddEditRecordComments").val("");
  1217. $("#btnAddEditRecord").button("reset");
  1218. }
  1219. function showAddRecordModal(objBtn) {
  1220. var zoneType = $("#titleEditZoneType").text();
  1221. if (zoneType === "Primary") {
  1222. var btn = $(objBtn);
  1223. btn.button('loading');
  1224. HTTPRequest({
  1225. url: "/api/apps/list?token=" + token,
  1226. success: function (responseJSON) {
  1227. btn.button('reset');
  1228. showAddRecordModalNow(responseJSON.response.apps);
  1229. },
  1230. error: function () {
  1231. btn.button('reset');
  1232. },
  1233. invalidToken: function () {
  1234. showPageLogin();
  1235. }
  1236. });
  1237. }
  1238. else {
  1239. showAddRecordModalNow(null);
  1240. }
  1241. }
  1242. var appsList;
  1243. function showAddRecordModalNow(apps) {
  1244. var zone = $("#titleEditZone").text();
  1245. clearAddEditForm();
  1246. $("#titleAddEditRecord").text("Add Record");
  1247. $("#lblAddEditRecordZoneName").text(zone === "." ? "" : zone);
  1248. $("#optEditRecordTypeSoa").hide();
  1249. $("#btnAddEditRecord").attr("onclick", "addRecord(); return false;");
  1250. appsList = apps;
  1251. if (apps != null) {
  1252. var optApps = "<option></option>";
  1253. var optClassPaths = "<option></option>";
  1254. for (var i = 0; i < apps.length; i++) {
  1255. for (var j = 0; j < apps[i].dnsApps.length; j++) {
  1256. if (apps[i].dnsApps[j].isAppRecordRequestHandler) {
  1257. optApps += "<option>" + apps[i].name + "</option>";
  1258. break;
  1259. }
  1260. }
  1261. }
  1262. $("#optAddEditRecordDataAppName").html(optApps);
  1263. $("#optAddEditRecordDataClassPath").html(optClassPaths);
  1264. $("#txtAddEditRecordDataData").val("");
  1265. }
  1266. $("#modalAddEditRecord").modal("show");
  1267. setTimeout(function () {
  1268. $("#txtAddEditRecordName").focus();
  1269. }, 1000);
  1270. }
  1271. function modifyAddRecordFormByType() {
  1272. $("#divAddEditRecordAlert").html("");
  1273. $("#txtAddEditRecordName").prop("placeholder", "@");
  1274. $("#divAddEditRecordTtl").show();
  1275. var type = $("#optAddEditRecordType").val();
  1276. $("#divAddEditRecordData").hide();
  1277. $("#divAddEditRecordDataPtr").hide();
  1278. $("#divAddEditRecordDataNs").hide();
  1279. $("#divEditRecordDataSoa").hide();
  1280. $("#divAddEditRecordDataMx").hide();
  1281. $("#divAddEditRecordDataSrv").hide();
  1282. $("#divAddEditRecordDataDs").hide();
  1283. $("#divAddEditRecordDataCaa").hide();
  1284. $("#divAddEditRecordDataForwarder").hide();
  1285. $("#divAddEditRecordDataApplication").hide();
  1286. switch (type) {
  1287. case "A":
  1288. $("#lblAddEditRecordDataValue").text("IPv4 Address");
  1289. $("#txtAddEditRecordDataValue").val("");
  1290. $("#chkAddEditRecordDataPtr").prop("checked", false);
  1291. $("#chkAddEditRecordDataCreatePtrZone").prop('disabled', true);
  1292. $("#chkAddEditRecordDataCreatePtrZone").prop("checked", false);
  1293. $("#chkAddEditRecordDataPtrLabel").text("Add reverse (PTR) record");
  1294. $("#divAddEditRecordData").show();
  1295. $("#divAddEditRecordDataPtr").show();
  1296. break;
  1297. case "AAAA":
  1298. $("#lblAddEditRecordDataValue").text("IPv6 Address");
  1299. $("#txtAddEditRecordDataValue").val("");
  1300. $("#chkAddEditRecordDataPtr").prop("checked", false);
  1301. $("#chkAddEditRecordDataCreatePtrZone").prop('disabled', true);
  1302. $("#chkAddEditRecordDataCreatePtrZone").prop("checked", false);
  1303. $("#chkAddEditRecordDataPtrLabel").text("Add reverse (PTR) record");
  1304. $("#divAddEditRecordData").show();
  1305. $("#divAddEditRecordDataPtr").show();
  1306. break;
  1307. case "NS":
  1308. $("#txtAddEditRecordDataNsNameServer").val("");
  1309. $("#txtAddEditRecordDataNsGlue").val("");
  1310. $("#divAddEditRecordDataNs").show();
  1311. break;
  1312. case "SOA":
  1313. $("#txtEditRecordDataSoaPrimaryNameServer").val("");
  1314. $("#txtEditRecordDataSoaResponsiblePerson").val("");
  1315. $("#txtEditRecordDataSoaSerial").val("");
  1316. $("#txtEditRecordDataSoaRefresh").val("");
  1317. $("#txtEditRecordDataSoaRetry").val("");
  1318. $("#txtEditRecordDataSoaExpire").val("");
  1319. $("#txtEditRecordDataSoaMinimum").val("");
  1320. $("#txtEditRecordDataSoaPrimaryAddresses").val("");
  1321. $("#rdEditRecordDataSoaZoneTransferProtocolTcp").prop("checked", true);
  1322. $("#optEditRecordDataSoaTsigKeyName").val("");
  1323. $("#divEditRecordDataSoa").show();
  1324. break;
  1325. case "PTR":
  1326. case "CNAME":
  1327. case "DNAME":
  1328. case "ANAME":
  1329. $("#lblAddEditRecordDataValue").text("Domain Name");
  1330. $("#txtAddEditRecordDataValue").val("");
  1331. $("#divAddEditRecordData").show();
  1332. break;
  1333. case "MX":
  1334. $("#txtAddEditRecordDataMxPreference").val("");
  1335. $("#txtAddEditRecordDataMxExchange").val("");
  1336. $("#divAddEditRecordDataMx").show();
  1337. break;
  1338. case "TXT":
  1339. $("#lblAddEditRecordDataValue").text("Text Data");
  1340. $("#txtAddEditRecordDataValue").val("");
  1341. $("#divAddEditRecordData").show();
  1342. break;
  1343. case "SRV":
  1344. $("#txtAddEditRecordName").prop("placeholder", "_service._protocol.name");
  1345. $("#txtAddEditRecordDataSrvPriority").val("");
  1346. $("#txtAddEditRecordDataSrvWeight").val("");
  1347. $("#txtAddEditRecordDataSrvPort").val("");
  1348. $("#txtAddEditRecordDataSrvTarget").val("");
  1349. $("#divAddEditRecordDataSrv").show();
  1350. break;
  1351. case "DS":
  1352. $("#txtAddEditRecordDataDsKeyTag").val("");
  1353. $("#optAddEditRecordDataDsAlgorithm").val("");
  1354. $("#optAddEditRecordDataDsDigestType").val("");
  1355. $("#txtAddEditRecordDataDsDigest").val("");
  1356. $("#divAddEditRecordDataDs").show();
  1357. break;
  1358. case "CAA":
  1359. $("#txtAddEditRecordDataCaaFlags").val("");
  1360. $("#txtAddEditRecordDataCaaTag").val("");
  1361. $("#txtAddEditRecordDataCaaValue").val("");
  1362. $("#divAddEditRecordDataCaa").show();
  1363. break;
  1364. case "FWD":
  1365. $("#divAddEditRecordTtl").hide();
  1366. $("input[name=rdAddEditRecordDataForwarderProtocol]:radio").attr("disabled", false);
  1367. $("#rdAddEditRecordDataForwarderProtocolUdp").prop("checked", true);
  1368. $("#chkAddEditRecordDataForwarderThisServer").prop("checked", false);
  1369. $('#txtAddEditRecordDataForwarder').prop('disabled', false);
  1370. $("#txtAddEditRecordDataForwarder").val("");
  1371. $("#chkAddEditRecordDataForwarderDnssecValidation").prop("checked", false);
  1372. $("#rdAddEditRecordDataForwarderProxyTypeNone").prop("checked", true);
  1373. $("#txtAddEditRecordDataForwarderProxyAddress").prop("disabled", true);
  1374. $("#txtAddEditRecordDataForwarderProxyPort").prop("disabled", true);
  1375. $("#txtAddEditRecordDataForwarderProxyUsername").prop("disabled", true);
  1376. $("#txtAddEditRecordDataForwarderProxyPassword").prop("disabled", true);
  1377. $("#txtAddEditRecordDataForwarderProxyAddress").val("");
  1378. $("#txtAddEditRecordDataForwarderProxyPort").val("");
  1379. $("#txtAddEditRecordDataForwarderProxyUsername").val("");
  1380. $("#txtAddEditRecordDataForwarderProxyPassword").val("");
  1381. $("#divAddEditRecordDataForwarder").show();
  1382. $("#divAddEditRecordDataForwarderProxy").show();
  1383. break;
  1384. case "APP":
  1385. $("#optAddEditRecordDataAppName").val("");
  1386. $("#optAddEditRecordDataClassPath").val("");
  1387. $("#txtAddEditRecordDataData").val("");
  1388. $("#divAddEditRecordDataApplication").show();
  1389. break;
  1390. }
  1391. }
  1392. function addRecord() {
  1393. var btn = $("#btnAddEditRecord");
  1394. var divAddEditRecordAlert = $("#divAddEditRecordAlert");
  1395. var zone = $("#titleEditZone").text();
  1396. var domain;
  1397. {
  1398. var subDomain = $("#txtAddEditRecordName").val();
  1399. if (subDomain === "")
  1400. subDomain = "@";
  1401. if (subDomain === "@")
  1402. domain = zone;
  1403. else if (zone === ".")
  1404. domain = subDomain + ".";
  1405. else
  1406. domain = subDomain + "." + zone;
  1407. }
  1408. var type = $("#optAddEditRecordType").val();
  1409. var ttl = $("#txtAddEditRecordTtl").val();
  1410. var overwrite = $("#chkAddEditRecordOverwrite").prop("checked");
  1411. var comments = $("#txtAddEditRecordComments").val();
  1412. var apiUrl = "/api/zone/addRecord?token=" + token + "&zone=" + encodeURIComponent(zone) + "&domain=" + encodeURIComponent(domain) + "&type=" + type + "&ttl=" + ttl + "&overwrite=" + overwrite + "&comments=" + encodeURIComponent(comments);
  1413. switch (type) {
  1414. case "A":
  1415. case "AAAA":
  1416. var ipAddress = $("#txtAddEditRecordDataValue").val();
  1417. if (ipAddress === "") {
  1418. showAlert("warning", "Missing!", "Please enter an IP address to add the record.", divAddEditRecordAlert);
  1419. $("#txtAddEditRecordDataValue").focus();
  1420. return;
  1421. }
  1422. apiUrl += "&ipAddress=" + encodeURIComponent(ipAddress) + "&ptr=" + $("#chkAddEditRecordDataPtr").prop('checked') + "&createPtrZone=" + $("#chkAddEditRecordDataCreatePtrZone").prop('checked');
  1423. break;
  1424. case "NS":
  1425. var nameServer = $("#txtAddEditRecordDataNsNameServer").val();
  1426. if (nameServer === "") {
  1427. showAlert("warning", "Missing!", "Please enter a name server to add the record.", divAddEditRecordAlert);
  1428. $("#txtAddEditRecordDataNsNameServer").focus();
  1429. return;
  1430. }
  1431. var glue = cleanTextList($("#txtAddEditRecordDataNsGlue").val());
  1432. apiUrl += "&nameServer=" + encodeURIComponent(nameServer) + "&glue=" + encodeURIComponent(glue);
  1433. break;
  1434. case "CNAME":
  1435. var subDomainName = $("#txtAddEditRecordName").val();
  1436. if ((subDomainName === "") || (subDomainName === "@")) {
  1437. showAlert("warning", "Missing!", "Please enter a name for the CNAME record.", divAddEditRecordAlert);
  1438. $("#txtAddEditRecordName").focus();
  1439. return;
  1440. }
  1441. var cname = $("#txtAddEditRecordDataValue").val();
  1442. if (cname === "") {
  1443. showAlert("warning", "Missing!", "Please enter a domain name to add the record.", divAddEditRecordAlert);
  1444. $("#txtAddEditRecordDataValue").focus();
  1445. return;
  1446. }
  1447. apiUrl += "&cname=" + encodeURIComponent(cname);
  1448. break;
  1449. case "PTR":
  1450. var ptrName = $("#txtAddEditRecordDataValue").val();
  1451. if (ptrName === "") {
  1452. showAlert("warning", "Missing!", "Please enter a suitable value to add the record.", divAddEditRecordAlert);
  1453. $("#txtAddEditRecordDataValue").focus();
  1454. return;
  1455. }
  1456. apiUrl += "&ptrName=" + encodeURIComponent(ptrName);
  1457. break;
  1458. case "MX":
  1459. var preference = $("#txtAddEditRecordDataMxPreference").val();
  1460. if (preference === "")
  1461. preference = 1;
  1462. var exchange = $("#txtAddEditRecordDataMxExchange").val();
  1463. if (exchange === "") {
  1464. showAlert("warning", "Missing!", "Please enter a mail exchange domain name to add the record.", divAddEditRecordAlert);
  1465. $("#txtAddEditRecordDataMxExchange").focus();
  1466. return;
  1467. }
  1468. apiUrl += "&preference=" + preference + "&exchange=" + encodeURIComponent(exchange);
  1469. break;
  1470. case "TXT":
  1471. var text = $("#txtAddEditRecordDataValue").val();
  1472. if (text === "") {
  1473. showAlert("warning", "Missing!", "Please enter a suitable value to add the record.", divAddEditRecordAlert);
  1474. $("#txtAddEditRecordDataValue").focus();
  1475. return;
  1476. }
  1477. apiUrl += "&text=" + encodeURIComponent(text);
  1478. break;
  1479. case "SRV":
  1480. if ($("#txtAddEditRecordName").val() === "") {
  1481. showAlert("warning", "Missing!", "Please enter a name that includes service and protocol labels.", divAddEditRecordAlert);
  1482. $("#txtAddEditRecordName").focus();
  1483. return;
  1484. }
  1485. var priority = $("#txtAddEditRecordDataSrvPriority").val();
  1486. if (priority === "") {
  1487. showAlert("warning", "Missing!", "Please enter a suitable priority.", divAddEditRecordAlert);
  1488. $("#txtAddEditRecordDataSrvPriority").focus();
  1489. return;
  1490. }
  1491. var weight = $("#txtAddEditRecordDataSrvWeight").val();
  1492. if (weight === "") {
  1493. showAlert("warning", "Missing!", "Please enter a suitable weight.", divAddEditRecordAlert);
  1494. $("#txtAddEditRecordDataSrvWeight").focus();
  1495. return;
  1496. }
  1497. var port = $("#txtAddEditRecordDataSrvPort").val();
  1498. if (port === "") {
  1499. showAlert("warning", "Missing!", "Please enter a suitable port number.", divAddEditRecordAlert);
  1500. $("#txtAddEditRecordDataSrvPort").focus();
  1501. return;
  1502. }
  1503. var target = $("#txtAddEditRecordDataSrvTarget").val();
  1504. if (target === "") {
  1505. showAlert("warning", "Missing!", "Please enter a suitable value into the target field.", divAddEditRecordAlert);
  1506. $("#txtAddEditRecordDataSrvTarget").focus();
  1507. return;
  1508. }
  1509. apiUrl += "&priority=" + priority + "&weight=" + weight + "&port=" + port + "&target=" + encodeURIComponent(target);
  1510. break;
  1511. case "DNAME":
  1512. var dname = $("#txtAddEditRecordDataValue").val();
  1513. if (dname === "") {
  1514. showAlert("warning", "Missing!", "Please enter a domain name to add the record.", divAddEditRecordAlert);
  1515. $("#txtAddEditRecordDataValue").focus();
  1516. return;
  1517. }
  1518. apiUrl += "&dname=" + encodeURIComponent(dname);
  1519. break;
  1520. case "DS":
  1521. var subDomainName = $("#txtAddEditRecordName").val();
  1522. if ((subDomainName === "") || (subDomainName === "@")) {
  1523. showAlert("warning", "Missing!", "Please enter a name for the DS record.", divAddEditRecordAlert);
  1524. $("#txtAddEditRecordName").focus();
  1525. return;
  1526. }
  1527. var keyTag = $("#txtAddEditRecordDataDsKeyTag").val();
  1528. if (keyTag === "") {
  1529. showAlert("warning", "Missing!", "Please enter the Key Tag value to add the record.", divAddEditRecordAlert);
  1530. $("#txtAddEditRecordDataDsKeyTag").focus();
  1531. return;
  1532. }
  1533. var algorithm = $("#optAddEditRecordDataDsAlgorithm").val();
  1534. if ((algorithm === null) || (algorithm === "")) {
  1535. showAlert("warning", "Missing!", "Please select an DNSSEC algorithm to add the record.", divAddEditRecordAlert);
  1536. $("#optAddEditRecordDataDsAlgorithm").focus();
  1537. return;
  1538. }
  1539. var digestType = $("#optAddEditRecordDataDsDigestType").val();
  1540. if ((digestType === null) || (digestType === "")) {
  1541. showAlert("warning", "Missing!", "Please select a Digest Type to add the record.", divAddEditRecordAlert);
  1542. $("#optAddEditRecordDataDsDigestType").focus();
  1543. return;
  1544. }
  1545. var digest = $("#txtAddEditRecordDataDsDigest").val();
  1546. if (digest === "") {
  1547. showAlert("warning", "Missing!", "Please enter the Digest hash in hex string format to add the record.", divAddEditRecordAlert);
  1548. $("#txtAddEditRecordDataDsDigest").focus();
  1549. return;
  1550. }
  1551. apiUrl += "&keyTag=" + keyTag + "&algorithm=" + algorithm + "&digestType=" + digestType + "&digest=" + encodeURIComponent(digest);
  1552. break;
  1553. case "CAA":
  1554. var flags = $("#txtAddEditRecordDataCaaFlags").val();
  1555. if (flags === "")
  1556. flags = 0;
  1557. var tag = $("#txtAddEditRecordDataCaaTag").val();
  1558. if (tag === "")
  1559. tag = "issue";
  1560. var value = $("#txtAddEditRecordDataCaaValue").val();
  1561. if (value === "") {
  1562. showAlert("warning", "Missing!", "Please enter a suitable value into the authority field.", divAddEditRecordAlert);
  1563. $("#txtAddEditRecordDataCaaValue").focus();
  1564. return;
  1565. }
  1566. apiUrl += "&flags=" + flags + "&tag=" + encodeURIComponent(tag) + "&value=" + encodeURIComponent(value);
  1567. break;
  1568. case "ANAME":
  1569. var aname = $("#txtAddEditRecordDataValue").val();
  1570. if (aname === "") {
  1571. showAlert("warning", "Missing!", "Please enter a suitable value to add the record.", divAddEditRecordAlert);
  1572. $("#txtAddEditRecordDataValue").focus();
  1573. return;
  1574. }
  1575. apiUrl += "&aname=" + encodeURIComponent(aname);
  1576. break;
  1577. case "FWD":
  1578. var forwarder = $("#txtAddEditRecordDataForwarder").val();
  1579. if (forwarder === "") {
  1580. showAlert("warning", "Missing!", "Please enter a domain name or IP address or URL as a forwarder to add the record.", divAddEditRecordAlert);
  1581. $("#txtAddEditRecordDataForwarder").focus();
  1582. return;
  1583. }
  1584. var dnssecValidation = $("#chkAddEditRecordDataForwarderDnssecValidation").prop("checked");
  1585. var proxyType = $("input[name=rdAddEditRecordDataForwarderProxyType]:checked").val();
  1586. apiUrl += "&protocol=" + $('input[name=rdAddEditRecordDataForwarderProtocol]:checked').val() + "&forwarder=" + encodeURIComponent(forwarder);
  1587. apiUrl += "&dnssecValidation=" + dnssecValidation + "&proxyType=" + proxyType;
  1588. if (proxyType != "None") {
  1589. var proxyAddress = $("#txtAddEditRecordDataForwarderProxyAddress").val();
  1590. var proxyPort = $("#txtAddEditRecordDataForwarderProxyPort").val();
  1591. var proxyUsername = $("#txtAddEditRecordDataForwarderProxyUsername").val();
  1592. var proxyPassword = $("#txtAddEditRecordDataForwarderProxyPassword").val();
  1593. if ((proxyAddress == null) || (proxyAddress === "")) {
  1594. showAlert("warning", "Missing!", "Please enter a domain name or IP address for Proxy Server Address to add the record.", divAddEditRecordAlert);
  1595. $("#txtAddEditRecordDataForwarderProxyAddress").focus();
  1596. return;
  1597. }
  1598. if ((proxyPort == null) || (proxyPort === "")) {
  1599. showAlert("warning", "Missing!", "Please enter a port number for Proxy Server Port to add the record.", divAddEditRecordAlert);
  1600. $("#txtAddEditRecordDataForwarderProxyPort").focus();
  1601. return;
  1602. }
  1603. apiUrl += "&proxyAddress=" + encodeURIComponent(proxyAddress) + "&proxyPort=" + proxyPort + "&proxyUsername=" + encodeURIComponent(proxyUsername) + "&proxyPassword=" + encodeURIComponent(proxyPassword);
  1604. }
  1605. break;
  1606. case "APP":
  1607. var appName = $("#optAddEditRecordDataAppName").val();
  1608. if ((appName === null) || (appName === "")) {
  1609. showAlert("warning", "Missing!", "Please select an application name to add record.", divAddEditRecordAlert);
  1610. $("#optAddEditRecordDataAppName").focus();
  1611. return;
  1612. }
  1613. var classPath = $("#optAddEditRecordDataClassPath").val();
  1614. if ((classPath === null) || (classPath === "")) {
  1615. showAlert("warning", "Missing!", "Please select a class path to add record.", divAddEditRecordAlert);
  1616. $("#optAddEditRecordDataClassPath").focus();
  1617. return;
  1618. }
  1619. var recordData = $("#txtAddEditRecordDataData").val();
  1620. apiUrl += "&appName=" + encodeURIComponent(appName) + "&classPath=" + encodeURIComponent(classPath) + "&recordData=" + encodeURIComponent(recordData);
  1621. break;
  1622. }
  1623. btn.button("loading");
  1624. HTTPRequest({
  1625. url: apiUrl,
  1626. success: function (responseJSON) {
  1627. $("#modalAddEditRecord").modal("hide");
  1628. showEditZone(zone);
  1629. showAlert("success", "Record Added!", "Resource record was added successfully.");
  1630. },
  1631. error: function () {
  1632. btn.button('reset');
  1633. },
  1634. invalidToken: function () {
  1635. $("#modalAddEditRecord").modal("hide");
  1636. showPageLogin();
  1637. },
  1638. objAlertPlaceholder: divAddEditRecordAlert
  1639. });
  1640. }
  1641. function updateAddEditFormForwarderPlaceholder() {
  1642. var protocol = $('input[name=rdAddEditRecordDataForwarderProtocol]:checked').val();
  1643. switch (protocol) {
  1644. case "Udp":
  1645. case "Tcp":
  1646. $("#txtAddEditRecordDataForwarder").attr("placeholder", "8.8.8.8 or [2620:fe::10]")
  1647. break;
  1648. case "Tls":
  1649. $("#txtAddEditRecordDataForwarder").attr("placeholder", "dns.quad9.net (9.9.9.9:853)")
  1650. break;
  1651. case "Https":
  1652. case "HttpsJson":
  1653. $("#txtAddEditRecordDataForwarder").attr("placeholder", "https://cloudflare-dns.com/dns-query (1.1.1.1)")
  1654. break;
  1655. }
  1656. }
  1657. function updateAddEditFormForwarderProxyType() {
  1658. var proxyType = $('input[name=rdAddEditRecordDataForwarderProxyType]:checked').val();
  1659. $("#txtAddEditRecordDataForwarderProxyAddress").prop("disabled", (proxyType === "None"));
  1660. $("#txtAddEditRecordDataForwarderProxyPort").prop("disabled", (proxyType === "None"));
  1661. $("#txtAddEditRecordDataForwarderProxyUsername").prop("disabled", (proxyType === "None"));
  1662. $("#txtAddEditRecordDataForwarderProxyPassword").prop("disabled", (proxyType === "None"));
  1663. }
  1664. function updateAddEditFormForwarderThisServer() {
  1665. var useThisServer = $("#chkAddEditRecordDataForwarderThisServer").prop('checked');
  1666. if (useThisServer) {
  1667. $("input[name=rdAddEditRecordDataForwarderProtocol]:radio").attr("disabled", true);
  1668. $("#rdAddEditRecordDataForwarderProtocolUdp").prop("checked", true);
  1669. $("#txtAddEditRecordDataForwarder").attr("placeholder", "8.8.8.8 or [2620:fe::10]")
  1670. $("#txtAddEditRecordDataForwarder").prop("disabled", true);
  1671. $("#txtAddEditRecordDataForwarder").val("this-server");
  1672. $("#divAddEditRecordDataForwarderProxy").hide();
  1673. }
  1674. else {
  1675. $("input[name=rdAddEditRecordDataForwarderProtocol]:radio").attr("disabled", false);
  1676. $("#txtAddEditRecordDataForwarder").prop("disabled", false);
  1677. $("#txtAddEditRecordDataForwarder").val("");
  1678. $("#divAddEditRecordDataForwarderProxy").show();
  1679. }
  1680. }
  1681. function showEditRecordModal(objBtn) {
  1682. var btn = $(objBtn);
  1683. var id = btn.attr("data-id");
  1684. var divData = $("#data" + id);
  1685. var zone = $("#titleEditZone").text();
  1686. var name = divData.attr("data-record-name");
  1687. var type = divData.attr("data-record-type");
  1688. var ttl = divData.attr("data-record-ttl");
  1689. var comments = divData.attr("data-record-comments");
  1690. if (name === zone)
  1691. name = "@";
  1692. else
  1693. name = name.replace("." + zone, "");
  1694. clearAddEditForm();
  1695. $("#titleAddEditRecord").text("Edit Record");
  1696. $("#lblAddEditRecordZoneName").text(zone === "." ? "" : zone);
  1697. $("#optEditRecordTypeSoa").show();
  1698. $("#optAddEditRecordType").val(type);
  1699. $("#divAddEditRecordOverwrite").hide();
  1700. modifyAddRecordFormByType();
  1701. $("#txtAddEditRecordName").val(name);
  1702. $("#txtAddEditRecordTtl").val(ttl)
  1703. $("#txtAddEditRecordComments").val(comments);
  1704. var disableSoaRecordModalFields = false;
  1705. var hideSoaRecordPrimaryAddressesField = false;
  1706. var hideSoaRecordXfrAndTsigFields = false;
  1707. var zoneType = $("#titleEditZoneType").text();
  1708. switch (zoneType) {
  1709. case "Primary":
  1710. switch (type) {
  1711. case "SOA":
  1712. hideSoaRecordPrimaryAddressesField = true;
  1713. hideSoaRecordXfrAndTsigFields = true;
  1714. break;
  1715. }
  1716. break;
  1717. case "Secondary":
  1718. switch (type) {
  1719. case "SOA":
  1720. disableSoaRecordModalFields = true;
  1721. break;
  1722. }
  1723. break;
  1724. case "Stub":
  1725. switch (type) {
  1726. case "SOA":
  1727. disableSoaRecordModalFields = true;
  1728. hideSoaRecordXfrAndTsigFields = true;
  1729. break;
  1730. }
  1731. break;
  1732. }
  1733. switch (type) {
  1734. case "A":
  1735. case "AAAA":
  1736. $("#txtAddEditRecordDataValue").val(divData.attr("data-record-ip-address"));
  1737. $("#chkAddEditRecordDataPtr").prop("checked", false);
  1738. $("#chkAddEditRecordDataCreatePtrZone").prop('disabled', true);
  1739. $("#chkAddEditRecordDataCreatePtrZone").prop("checked", false);
  1740. $("#chkAddEditRecordDataPtrLabel").text("Update reverse (PTR) record");
  1741. break;
  1742. case "NS":
  1743. $("#txtAddEditRecordDataNsNameServer").val(divData.attr("data-record-name-server"));
  1744. $("#txtAddEditRecordDataNsGlue").val(divData.attr("data-record-glue").replace(/, /g, "\n"));
  1745. break;
  1746. case "CNAME":
  1747. $("#txtAddEditRecordDataValue").val(divData.attr("data-record-cname"));
  1748. break;
  1749. case "SOA":
  1750. $("#txtEditRecordDataSoaPrimaryNameServer").val(divData.attr("data-record-pname"));
  1751. $("#txtEditRecordDataSoaResponsiblePerson").val(divData.attr("data-record-rperson"));
  1752. $("#txtEditRecordDataSoaSerial").val(divData.attr("data-record-serial"));
  1753. $("#txtEditRecordDataSoaRefresh").val(divData.attr("data-record-refresh"));
  1754. $("#txtEditRecordDataSoaRetry").val(divData.attr("data-record-retry"));
  1755. $("#txtEditRecordDataSoaExpire").val(divData.attr("data-record-expire"));
  1756. $("#txtEditRecordDataSoaMinimum").val(divData.attr("data-record-minimum"));
  1757. $("#txtEditRecordDataSoaPrimaryAddresses").val(divData.attr("data-record-paddresses").replace(/, /g, "\n"));
  1758. switch (divData.attr("data-record-zonetransferprotocol").toLowerCase()) {
  1759. case "tls":
  1760. $("#rdEditRecordDataSoaZoneTransferProtocolTls").prop("checked", true);
  1761. break;
  1762. case "tcp":
  1763. default:
  1764. $("#rdEditRecordDataSoaZoneTransferProtocolTcp").prop("checked", true);
  1765. break;
  1766. }
  1767. $("#optEditRecordDataSoaTsigKeyName").val(divData.attr("data-record-tsigkeyname"));
  1768. $("#txtAddEditRecordName").prop("disabled", true);
  1769. if (disableSoaRecordModalFields) {
  1770. $("#txtAddEditRecordTtl").prop("disabled", true);
  1771. $("#txtEditRecordDataSoaPrimaryNameServer").prop("disabled", true);
  1772. $("#txtEditRecordDataSoaResponsiblePerson").prop("disabled", true);
  1773. $("#txtEditRecordDataSoaSerial").prop("disabled", true);
  1774. $("#txtEditRecordDataSoaRefresh").prop("disabled", true);
  1775. $("#txtEditRecordDataSoaRetry").prop("disabled", true);
  1776. $("#txtEditRecordDataSoaExpire").prop("disabled", true);
  1777. $("#txtEditRecordDataSoaMinimum").prop("disabled", true);
  1778. }
  1779. if (hideSoaRecordPrimaryAddressesField) {
  1780. $("#divEditRecordDataSoaPrimaryAddresses").hide();
  1781. } else {
  1782. $("#divEditRecordDataSoaPrimaryAddresses").show();
  1783. }
  1784. if (hideSoaRecordXfrAndTsigFields) {
  1785. $("#divEditRecordDataSoaZoneTransferProtocol").hide();
  1786. $("#divEditRecordDataSoaTsigKeyName").hide();
  1787. } else {
  1788. $("#divEditRecordDataSoaZoneTransferProtocol").show();
  1789. $("#divEditRecordDataSoaTsigKeyName").show();
  1790. }
  1791. break;
  1792. case "PTR":
  1793. $("#txtAddEditRecordDataValue").val(divData.attr("data-record-ptr-name"));
  1794. break;
  1795. case "MX":
  1796. $("#txtAddEditRecordDataMxPreference").val(divData.attr("data-record-preference"));
  1797. $("#txtAddEditRecordDataMxExchange").val(divData.attr("data-record-exchange"));
  1798. break;
  1799. case "TXT":
  1800. $("#txtAddEditRecordDataValue").val(divData.attr("data-record-text"));
  1801. break;
  1802. case "SRV":
  1803. $("#txtAddEditRecordDataSrvPriority").val(divData.attr("data-record-priority"));
  1804. $("#txtAddEditRecordDataSrvWeight").val(divData.attr("data-record-weight"));
  1805. $("#txtAddEditRecordDataSrvPort").val(divData.attr("data-record-port"));
  1806. $("#txtAddEditRecordDataSrvTarget").val(divData.attr("data-record-target"));
  1807. break;
  1808. case "DNAME":
  1809. $("#txtAddEditRecordDataValue").val(divData.attr("data-record-dname"));
  1810. break;
  1811. case "DS":
  1812. $("#txtAddEditRecordDataDsKeyTag").val(divData.attr("data-record-key-tag"));
  1813. $("#optAddEditRecordDataDsAlgorithm").val(divData.attr("data-record-algorithm"));
  1814. $("#optAddEditRecordDataDsDigestType").val(divData.attr("data-record-digest-type"));
  1815. $("#txtAddEditRecordDataDsDigest").val(divData.attr("data-record-digest"));
  1816. break;
  1817. case "CAA":
  1818. $("#txtAddEditRecordDataCaaFlags").val(divData.attr("data-record-flags"));
  1819. $("#txtAddEditRecordDataCaaTag").val(divData.attr("data-record-tag"));
  1820. $("#txtAddEditRecordDataCaaValue").val(divData.attr("data-record-value"));
  1821. break;
  1822. case "ANAME":
  1823. $("#txtAddEditRecordDataValue").val(divData.attr("data-record-aname"));
  1824. break;
  1825. case "FWD":
  1826. $("#divAddEditRecordTtl").hide();
  1827. $("#rdAddEditRecordDataForwarderProtocol" + divData.attr("data-record-protocol")).prop("checked", true);
  1828. var forwarder = divData.attr("data-record-forwarder");
  1829. $("#chkAddEditRecordDataForwarderThisServer").prop("checked", (forwarder == "this-server"));
  1830. $("#txtAddEditRecordDataForwarder").prop("disabled", (forwarder == "this-server"));
  1831. $("#txtAddEditRecordDataForwarder").val(forwarder);
  1832. if (forwarder === "this-server") {
  1833. $("input[name=rdAddEditRecordDataForwarderProtocol]:radio").attr("disabled", true);
  1834. $("#divAddEditRecordDataForwarderProxy").hide();
  1835. }
  1836. else {
  1837. $("input[name=rdAddEditRecordDataForwarderProtocol]:radio").attr("disabled", false);
  1838. $("#divAddEditRecordDataForwarderProxy").show();
  1839. }
  1840. $("#chkAddEditRecordDataForwarderDnssecValidation").prop("checked", divData.attr("data-record-dnssec-validation") === "true");
  1841. var proxyType = divData.attr("data-record-proxy-type");
  1842. $("#rdAddEditRecordDataForwarderProxyType" + proxyType).prop("checked", true);
  1843. if (proxyType !== "None") {
  1844. $("#txtAddEditRecordDataForwarderProxyAddress").val(divData.attr("data-record-proxy-address"));
  1845. $("#txtAddEditRecordDataForwarderProxyPort").val(divData.attr("data-record-proxy-port"));
  1846. $("#txtAddEditRecordDataForwarderProxyUsername").val(divData.attr("data-record-proxy-username"));
  1847. $("#txtAddEditRecordDataForwarderProxyPassword").val(divData.attr("data-record-proxy-password"));
  1848. }
  1849. updateAddEditFormForwarderPlaceholder();
  1850. updateAddEditFormForwarderProxyType();
  1851. break;
  1852. case "APP":
  1853. $("#optAddEditRecordDataAppName").attr("disabled", true);
  1854. $("#optAddEditRecordDataClassPath").attr("disabled", true);
  1855. $("#optAddEditRecordDataAppName").html("<option>" + divData.attr("data-record-app-name") + "</option>")
  1856. $("#optAddEditRecordDataAppName").val(divData.attr("data-record-app-name"))
  1857. $("#optAddEditRecordDataClassPath").html("<option>" + divData.attr("data-record-classpath") + "</option>")
  1858. $("#optAddEditRecordDataClassPath").val(divData.attr("data-record-classpath"))
  1859. $("#txtAddEditRecordDataData").val(divData.attr("data-record-data"))
  1860. break;
  1861. default:
  1862. showAlert("warning", "Not Supported!", "Record type not supported for edit.");
  1863. return;
  1864. }
  1865. $("#optAddEditRecordType").prop("disabled", true);
  1866. $("#btnAddEditRecord").attr("data-id", id);
  1867. $("#btnAddEditRecord").attr("onclick", "updateRecord(); return false;");
  1868. $("#modalAddEditRecord").modal("show");
  1869. setTimeout(function () {
  1870. $("#txtAddEditRecordName").focus();
  1871. }, 1000);
  1872. }
  1873. function updateRecord() {
  1874. var btn = $("#btnAddEditRecord");
  1875. var divAddEditRecordAlert = $("#divAddEditRecordAlert");
  1876. var id = btn.attr("data-id");
  1877. var divData = $("#data" + id);
  1878. var zone = $("#titleEditZone").text();
  1879. var type = divData.attr("data-record-type");
  1880. var domain = divData.attr("data-record-name");
  1881. if (domain === "")
  1882. domain = ".";
  1883. var newDomain;
  1884. {
  1885. var newSubDomain = $("#txtAddEditRecordName").val();
  1886. if (newSubDomain === "")
  1887. newSubDomain = "@";
  1888. if (newSubDomain === "@")
  1889. newDomain = zone;
  1890. else if (zone === ".")
  1891. newDomain = newSubDomain + ".";
  1892. else
  1893. newDomain = newSubDomain + "." + zone;
  1894. }
  1895. var ttl = $("#txtAddEditRecordTtl").val();
  1896. var disable = (divData.attr("data-record-disabled") === "true");
  1897. var comments = $("#txtAddEditRecordComments").val();
  1898. var apiUrl = "/api/zone/updateRecord?token=" + token + "&zone=" + encodeURIComponent(zone) + "&type=" + type + "&domain=" + encodeURIComponent(domain) + "&newDomain=" + encodeURIComponent(newDomain) + "&ttl=" + ttl + "&disable=" + disable + "&comments=" + encodeURIComponent(comments);
  1899. switch (type) {
  1900. case "A":
  1901. case "AAAA":
  1902. var ipAddress = divData.attr("data-record-ip-address");
  1903. var newIpAddress = $("#txtAddEditRecordDataValue").val();
  1904. if (newIpAddress === "") {
  1905. showAlert("warning", "Missing!", "Please enter an IP address to update the record.", divAddEditRecordAlert);
  1906. $("#txtAddEditRecordDataValue").focus();
  1907. return;
  1908. }
  1909. apiUrl += "&ipAddress=" + encodeURIComponent(ipAddress) + "&newIpAddress=" + encodeURIComponent(newIpAddress) + "&ptr=" + $("#chkAddEditRecordDataPtr").prop('checked') + "&createPtrZone=" + $("#chkAddEditRecordDataCreatePtrZone").prop('checked');
  1910. break;
  1911. case "NS":
  1912. var nameServer = divData.attr("data-record-name-server");
  1913. var newNameServer = $("#txtAddEditRecordDataNsNameServer").val();
  1914. if (newNameServer === "") {
  1915. showAlert("warning", "Missing!", "Please enter a name server to update the record.", divAddEditRecordAlert);
  1916. $("#txtAddEditRecordDataNsNameServer").focus();
  1917. return;
  1918. }
  1919. var glue = cleanTextList($("#txtAddEditRecordDataNsGlue").val());
  1920. apiUrl += "&nameServer=" + encodeURIComponent(nameServer) + "&newNameServer=" + encodeURIComponent(newNameServer) + "&glue=" + encodeURIComponent(glue);
  1921. break;
  1922. case "CNAME":
  1923. var subDomainName = $("#txtAddEditRecordName").val();
  1924. if ((subDomainName === "") || (subDomainName === "@")) {
  1925. showAlert("warning", "Missing!", "Please enter a name for the CNAME record.", divAddEditRecordAlert);
  1926. $("#txtAddEditRecordName").focus();
  1927. return;
  1928. }
  1929. var cname = $("#txtAddEditRecordDataValue").val();
  1930. if (cname === "") {
  1931. showAlert("warning", "Missing!", "Please enter a domain name to update the record.", divAddEditRecordAlert);
  1932. $("#txtAddEditRecordDataValue").focus();
  1933. return;
  1934. }
  1935. apiUrl += "&cname=" + encodeURIComponent(cname);
  1936. break;
  1937. case "SOA":
  1938. var primaryNameServer = $("#txtEditRecordDataSoaPrimaryNameServer").val();
  1939. if (primaryNameServer === "") {
  1940. showAlert("warning", "Missing!", "Please enter a value for primary name server.", divAddEditRecordAlert);
  1941. $("#txtEditRecordDataSoaPrimaryNameServer").focus();
  1942. return;
  1943. }
  1944. var responsiblePerson = $("#txtEditRecordDataSoaResponsiblePerson").val();
  1945. if (responsiblePerson === "") {
  1946. showAlert("warning", "Missing!", "Please enter a value for responsible person.", divAddEditRecordAlert);
  1947. $("#txtEditRecordDataSoaResponsiblePerson").focus();
  1948. return;
  1949. }
  1950. var serial = $("#txtEditRecordDataSoaSerial").val();
  1951. if (serial === "") {
  1952. showAlert("warning", "Missing!", "Please enter a value for serial.", divAddEditRecordAlert);
  1953. $("#txtEditRecordDataSoaSerial").focus();
  1954. return;
  1955. }
  1956. var refresh = $("#txtEditRecordDataSoaRefresh").val();
  1957. if (refresh === "") {
  1958. showAlert("warning", "Missing!", "Please enter a value for refresh.", divAddEditRecordAlert);
  1959. $("#txtEditRecordDataSoaRefresh").focus();
  1960. return;
  1961. }
  1962. var retry = $("#txtEditRecordDataSoaRetry").val();
  1963. if (retry === "") {
  1964. showAlert("warning", "Missing!", "Please enter a value for retry.", divAddEditRecordAlert);
  1965. $("#txtEditRecordDataSoaRetry").focus();
  1966. return;
  1967. }
  1968. var expire = $("#txtEditRecordDataSoaExpire").val();
  1969. if (expire === "") {
  1970. showAlert("warning", "Missing!", "Please enter a value for expire.", divAddEditRecordAlert);
  1971. $("#txtEditRecordDataSoaExpire").focus();
  1972. return;
  1973. }
  1974. var minimum = $("#txtEditRecordDataSoaMinimum").val();
  1975. if (minimum === "") {
  1976. showAlert("warning", "Missing!", "Please enter a value for minimum.", divAddEditRecordAlert);
  1977. $("#txtEditRecordDataSoaMinimum").focus();
  1978. return;
  1979. }
  1980. var primaryAddresses = cleanTextList($("#txtEditRecordDataSoaPrimaryAddresses").val());
  1981. var zoneTransferProtocol = $('input[name=rdEditRecordDataSoaZoneTransferProtocol]:checked').val();
  1982. var tsigKeyName = $("#optEditRecordDataSoaTsigKeyName").val();
  1983. apiUrl += "&primaryNameServer=" + encodeURIComponent(primaryNameServer) +
  1984. "&responsiblePerson=" + encodeURIComponent(responsiblePerson) +
  1985. "&serial=" + encodeURIComponent(serial) +
  1986. "&refresh=" + encodeURIComponent(refresh) +
  1987. "&retry=" + encodeURIComponent(retry) +
  1988. "&expire=" + encodeURIComponent(expire) +
  1989. "&minimum=" + encodeURIComponent(minimum) +
  1990. "&primaryAddresses=" + encodeURIComponent(primaryAddresses) +
  1991. "&zoneTransferProtocol=" + encodeURIComponent(zoneTransferProtocol) +
  1992. "&tsigKeyName=" + encodeURIComponent(tsigKeyName);
  1993. break;
  1994. case "PTR":
  1995. var ptrName = divData.attr("data-record-ptr-name");
  1996. var newPtrName = $("#txtAddEditRecordDataValue").val();
  1997. if (newPtrName === "") {
  1998. showAlert("warning", "Missing!", "Please enter a suitable value to update the record.", divAddEditRecordAlert);
  1999. $("#txtAddEditRecordDataValue").focus();
  2000. return;
  2001. }
  2002. apiUrl += "&ptrName=" + encodeURIComponent(ptrName) + "&newPtrName=" + encodeURIComponent(newPtrName);
  2003. break;
  2004. case "MX":
  2005. var preference = $("#txtAddEditRecordDataMxPreference").val();
  2006. if (preference === "")
  2007. preference = 1;
  2008. var exchange = divData.attr("data-record-exchange");
  2009. var newExchange = $("#txtAddEditRecordDataMxExchange").val();
  2010. if (newExchange === "") {
  2011. showAlert("warning", "Missing!", "Please enter a mail exchange domain name to update the record.", divAddEditRecordAlert);
  2012. $("#txtAddEditRecordDataMxExchange").focus();
  2013. return;
  2014. }
  2015. apiUrl += "&preference=" + preference + "&exchange=" + encodeURIComponent(exchange) + "&newExchange=" + encodeURIComponent(newExchange);
  2016. break;
  2017. case "TXT":
  2018. var text = divData.attr("data-record-text");
  2019. var newText = $("#txtAddEditRecordDataValue").val();
  2020. if (newText === "") {
  2021. showAlert("warning", "Missing!", "Please enter a suitable value to update the record.", divAddEditRecordAlert);
  2022. $("#txtAddEditRecordDataValue").focus();
  2023. return;
  2024. }
  2025. apiUrl += "&text=" + encodeURIComponent(text) + "&newText=" + encodeURIComponent(newText);
  2026. break;
  2027. case "SRV":
  2028. if ($("#txtAddEditRecordName").val() === "") {
  2029. showAlert("warning", "Missing!", "Please enter a name that includes service and protocol labels.", divAddEditRecordAlert);
  2030. $("#txtAddEditRecordName").focus();
  2031. return;
  2032. }
  2033. var port = divData.attr("data-record-port");
  2034. var priority = $("#txtAddEditRecordDataSrvPriority").val();
  2035. if (priority === "") {
  2036. showAlert("warning", "Missing!", "Please enter a suitable priority.", divAddEditRecordAlert);
  2037. $("#txtAddEditRecordDataSrvPriority").focus();
  2038. return;
  2039. }
  2040. var weight = $("#txtAddEditRecordDataSrvWeight").val();
  2041. if (weight === "") {
  2042. showAlert("warning", "Missing!", "Please enter a suitable weight.", divAddEditRecordAlert);
  2043. $("#txtAddEditRecordDataSrvWeight").focus();
  2044. return;
  2045. }
  2046. var newPort = $("#txtAddEditRecordDataSrvPort").val();
  2047. if (newPort === "") {
  2048. showAlert("warning", "Missing!", "Please enter a suitable port number.", divAddEditRecordAlert);
  2049. $("#txtAddEditRecordDataSrvPort").focus();
  2050. return;
  2051. }
  2052. var target = divData.attr("data-record-target");
  2053. var newTarget = $("#txtAddEditRecordDataSrvTarget").val();
  2054. if (newTarget === "") {
  2055. showAlert("warning", "Missing!", "Please enter a suitable value into the target field.", divAddEditRecordAlert);
  2056. $("#txtAddEditRecordDataSrvTarget").focus();
  2057. return;
  2058. }
  2059. apiUrl += "&priority=" + priority + "&weight=" + weight + "&port=" + port + "&newPort=" + newPort + "&target=" + encodeURIComponent(target) + "&newTarget=" + encodeURIComponent(newTarget);
  2060. break;
  2061. case "DNAME":
  2062. var dname = $("#txtAddEditRecordDataValue").val();
  2063. if (dname === "") {
  2064. showAlert("warning", "Missing!", "Please enter a domain name to update the record.", divAddEditRecordAlert);
  2065. $("#txtAddEditRecordDataValue").focus();
  2066. return;
  2067. }
  2068. apiUrl += "&dname=" + encodeURIComponent(dname);
  2069. break;
  2070. case "DS":
  2071. var subDomainName = $("#txtAddEditRecordName").val();
  2072. if ((subDomainName === "") || (subDomainName === "@")) {
  2073. showAlert("warning", "Missing!", "Please enter a name for the DS record.", divAddEditRecordAlert);
  2074. $("#txtAddEditRecordName").focus();
  2075. return;
  2076. }
  2077. var keyTag = divData.attr("data-record-key-tag");
  2078. var algorithm = divData.attr("data-record-algorithm");
  2079. var digestType = divData.attr("data-record-digest-type");
  2080. var newKeyTag = $("#txtAddEditRecordDataDsKeyTag").val();
  2081. if (newKeyTag === "") {
  2082. showAlert("warning", "Missing!", "Please enter the Key Tag value to update the record.", divAddEditRecordAlert);
  2083. $("#txtAddEditRecordDataDsKeyTag").focus();
  2084. return;
  2085. }
  2086. var newAlgorithm = $("#optAddEditRecordDataDsAlgorithm").val();
  2087. if ((newAlgorithm === null) || (newAlgorithm === "")) {
  2088. showAlert("warning", "Missing!", "Please select an DNSSEC algorithm to update the record.", divAddEditRecordAlert);
  2089. $("#optAddEditRecordDataDsAlgorithm").focus();
  2090. return;
  2091. }
  2092. var newDigestType = $("#optAddEditRecordDataDsDigestType").val();
  2093. if ((newDigestType === null) || (newDigestType === "")) {
  2094. showAlert("warning", "Missing!", "Please select a Digest Type to update the record.", divAddEditRecordAlert);
  2095. $("#optAddEditRecordDataDsDigestType").focus();
  2096. return;
  2097. }
  2098. var digest = divData.attr("data-record-digest");
  2099. var newDigest = $("#txtAddEditRecordDataDsDigest").val();
  2100. if (newDigest === "") {
  2101. showAlert("warning", "Missing!", "Please enter the Digest hash in hex string format to update the record.", divAddEditRecordAlert);
  2102. $("#txtAddEditRecordDataDsDigest").focus();
  2103. return;
  2104. }
  2105. apiUrl += "&keyTag=" + keyTag + "&algorithm=" + algorithm + "&digestType=" + digestType + "&newKeyTag=" + newKeyTag + "&newAlgorithm=" + newAlgorithm + "&newDigestType=" + newDigestType + "&digest=" + encodeURIComponent(digest) + "&newDigest=" + encodeURIComponent(newDigest);
  2106. break;
  2107. case "CAA":
  2108. var flags = divData.attr("data-record-flags");
  2109. var tag = divData.attr("data-record-tag");
  2110. var newFlags = $("#txtAddEditRecordDataCaaFlags").val();
  2111. if (newFlags === "")
  2112. newFlags = 0;
  2113. var newTag = $("#txtAddEditRecordDataCaaTag").val();
  2114. if (newTag === "")
  2115. newTag = "issue";
  2116. var value = divData.attr("data-record-value");
  2117. var newValue = $("#txtAddEditRecordDataCaaValue").val();
  2118. if (newValue === "") {
  2119. showAlert("warning", "Missing!", "Please enter a suitable value into the authority field.", divAddEditRecordAlert);
  2120. $("#txtAddEditRecordDataCaaValue").focus();
  2121. return;
  2122. }
  2123. apiUrl += "&flags=" + flags + "&tag=" + encodeURIComponent(tag) + "&newFlags=" + newFlags + "&newTag=" + encodeURIComponent(newTag) + "&value=" + encodeURIComponent(value) + "&newValue=" + encodeURIComponent(newValue);
  2124. break;
  2125. case "ANAME":
  2126. var aname = divData.attr("data-record-aname");
  2127. var newAName = $("#txtAddEditRecordDataValue").val();
  2128. if (newAName === "") {
  2129. showAlert("warning", "Missing!", "Please enter a suitable value to update the record.", divAddEditRecordAlert);
  2130. $("#txtAddEditRecordDataValue").focus();
  2131. return;
  2132. }
  2133. apiUrl += "&aname=" + encodeURIComponent(aname) + "&newAName=" + encodeURIComponent(newAName);
  2134. break;
  2135. case "FWD":
  2136. var protocol = divData.attr("data-record-protocol");
  2137. var newProtocol = $("input[name=rdAddEditRecordDataForwarderProtocol]:checked").val();
  2138. var forwarder = divData.attr("data-record-forwarder");
  2139. var newForwarder = $("#txtAddEditRecordDataForwarder").val();
  2140. if (newForwarder === "") {
  2141. showAlert("warning", "Missing!", "Please enter a domain name or IP address or URL as a forwarder to update the record.", divAddEditRecordAlert);
  2142. $("#txtAddEditRecordDataForwarder").focus();
  2143. return;
  2144. }
  2145. var dnssecValidation = $("#chkAddEditRecordDataForwarderDnssecValidation").prop("checked");
  2146. apiUrl += "&protocol=" + protocol + "&newProtocol=" + newProtocol + "&forwarder=" + encodeURIComponent(forwarder) + "&newForwarder=" + encodeURIComponent(newForwarder) + "&dnssecValidation=" + dnssecValidation;
  2147. if (newForwarder !== "this-server") {
  2148. var proxyType = $("input[name=rdAddEditRecordDataForwarderProxyType]:checked").val();
  2149. apiUrl += "&proxyType=" + proxyType;
  2150. if (proxyType != "None") {
  2151. var proxyAddress = $("#txtAddEditRecordDataForwarderProxyAddress").val();
  2152. var proxyPort = $("#txtAddEditRecordDataForwarderProxyPort").val();
  2153. var proxyUsername = $("#txtAddEditRecordDataForwarderProxyUsername").val();
  2154. var proxyPassword = $("#txtAddEditRecordDataForwarderProxyPassword").val();
  2155. if ((proxyAddress == null) || (proxyAddress === "")) {
  2156. showAlert("warning", "Missing!", "Please enter a domain name or IP address for Proxy Server Address to update the record.", divAddEditRecordAlert);
  2157. $("#txtAddEditRecordDataForwarderProxyAddress").focus();
  2158. return;
  2159. }
  2160. if ((proxyPort == null) || (proxyPort === "")) {
  2161. showAlert("warning", "Missing!", "Please enter a port number for Proxy Server Port to update the record.", divAddEditRecordAlert);
  2162. $("#txtAddEditRecordDataForwarderProxyPort").focus();
  2163. return;
  2164. }
  2165. apiUrl += "&proxyAddress=" + encodeURIComponent(proxyAddress) + "&proxyPort=" + proxyPort + "&proxyUsername=" + encodeURIComponent(proxyUsername) + "&proxyPassword=" + encodeURIComponent(proxyPassword);
  2166. }
  2167. }
  2168. break;
  2169. case "APP":
  2170. apiUrl += "&appName=" + encodeURIComponent(divData.attr("data-record-app-name")) + "&classPath=" + encodeURIComponent(divData.attr("data-record-classpath")) + "&recordData=" + encodeURIComponent($("#txtAddEditRecordDataData").val());
  2171. break;
  2172. }
  2173. btn.button('loading');
  2174. HTTPRequest({
  2175. url: apiUrl,
  2176. success: function (responseJSON) {
  2177. $("#modalAddEditRecord").modal("hide");
  2178. showEditZone(zone);
  2179. showAlert("success", "Record Updated!", "Resource record was updated successfully.");
  2180. },
  2181. error: function () {
  2182. btn.button('reset');
  2183. },
  2184. invalidToken: function () {
  2185. $("#modalAddEditRecord").modal("hide");
  2186. showPageLogin();
  2187. },
  2188. objAlertPlaceholder: divAddEditRecordAlert
  2189. });
  2190. }
  2191. function updateRecordState(objBtn, disable) {
  2192. var btn = $(objBtn);
  2193. var id = btn.attr("data-id");
  2194. var divData = $("#data" + id);
  2195. var type = divData.attr("data-record-type");
  2196. var domain = divData.attr("data-record-name");
  2197. var ttl = divData.attr("data-record-ttl");
  2198. var comments = divData.attr("data-record-comments");
  2199. if (domain === "")
  2200. domain = ".";
  2201. if (disable && !confirm("Are you sure to disable the " + type + " record '" + domain + "'?"))
  2202. return;
  2203. var apiUrl = "/api/zone/updateRecord?token=" + token + "&type=" + type + "&domain=" + encodeURIComponent(domain) + "&ttl=" + ttl + "&disable=" + disable + "&comments=" + encodeURIComponent(comments);
  2204. switch (type) {
  2205. case "A":
  2206. case "AAAA":
  2207. apiUrl += "&ipAddress=" + encodeURIComponent(divData.attr("data-record-ip-address"));
  2208. break;
  2209. case "NS":
  2210. apiUrl += "&nameServer=" + encodeURIComponent(divData.attr("data-record-name-server")) + "&glue=" + encodeURIComponent(divData.attr("data-record-glue"));
  2211. break;
  2212. case "CNAME":
  2213. apiUrl += "&cname=" + encodeURIComponent(divData.attr("data-record-cname"));
  2214. break;
  2215. case "PTR":
  2216. apiUrl += "&ptrName=" + encodeURIComponent(divData.attr("data-record-ptr-name"));
  2217. break;
  2218. case "MX":
  2219. apiUrl += "&preference=" + divData.attr("data-record-preference") + "&exchange=" + encodeURIComponent(divData.attr("data-record-exchange"));
  2220. break;
  2221. case "TXT":
  2222. apiUrl += "&text=" + encodeURIComponent(divData.attr("data-record-text"));
  2223. break;
  2224. case "SRV":
  2225. apiUrl += "&port=" + divData.attr("data-record-port") + "&priority=" + divData.attr("data-record-priority") + "&weight=" + divData.attr("data-record-weight") + "&target=" + encodeURIComponent(divData.attr("data-record-target"));
  2226. break;
  2227. case "DNAME":
  2228. apiUrl += "&dname=" + encodeURIComponent(divData.attr("data-record-dname"));
  2229. break;
  2230. case "DS":
  2231. apiUrl += "&keyTag=" + divData.attr("data-record-key-tag") + "&algorithm=" + divData.attr("data-record-algorithm") + "&digestType=" + divData.attr("data-record-digest-type") + "&digest=" + encodeURIComponent(divData.attr("data-record-digest"));
  2232. break;
  2233. case "CAA":
  2234. apiUrl += "&flags=" + divData.attr("data-record-flags") + "&tag=" + encodeURIComponent(divData.attr("data-record-tag")) + "&value=" + encodeURIComponent(divData.attr("data-record-value"));
  2235. break;
  2236. case "ANAME":
  2237. apiUrl += "&aname=" + encodeURIComponent(divData.attr("data-record-aname"));
  2238. break;
  2239. case "FWD":
  2240. apiUrl += "&protocol=" + divData.attr("data-record-protocol") + "&forwarder=" + encodeURIComponent(divData.attr("data-record-forwarder"));
  2241. var proxyType = divData.attr("data-record-proxy-type");
  2242. apiUrl += "&dnssecValidation=" + divData.attr("data-record-dnssec-validation") + "&proxyType=" + proxyType;
  2243. if (proxyType != "None") {
  2244. apiUrl += "&proxyAddress=" + encodeURIComponent(divData.attr("data-record-proxy-address")) + "&proxyPort=" + divData.attr("data-record-proxy-port") + "&proxyUsername=" + encodeURIComponent(divData.attr("data-record-proxy-username")) + "&proxyPassword=" + encodeURIComponent(divData.attr("data-record-proxy-password"));
  2245. }
  2246. break;
  2247. case "APP":
  2248. apiUrl += "&appName=" + encodeURIComponent(divData.attr("data-record-app-name")) + "&classPath=" + encodeURIComponent(divData.attr("data-record-classpath")) + "&recordData=" + encodeURIComponent(divData.attr("data-record-data"));
  2249. break;
  2250. }
  2251. btn.button('loading');
  2252. HTTPRequest({
  2253. url: apiUrl,
  2254. success: function (responseJSON) {
  2255. btn.button('reset');
  2256. //set new state
  2257. divData.attr("data-record-disabled", disable);
  2258. if (disable) {
  2259. $("#btnEnableRecord" + id).show();
  2260. $("#btnDisableRecord" + id).hide();
  2261. showAlert("success", "Record Disabled!", "Resource record was disabled successfully.");
  2262. }
  2263. else {
  2264. $("#btnEnableRecord" + id).hide();
  2265. $("#btnDisableRecord" + id).show();
  2266. showAlert("success", "Record Enabled!", "Resource record was enabled successfully.");
  2267. }
  2268. },
  2269. error: function () {
  2270. btn.button('reset');
  2271. },
  2272. invalidToken: function () {
  2273. showPageLogin();
  2274. }
  2275. });
  2276. }
  2277. function deleteRecord(objBtn) {
  2278. var btn = $(objBtn);
  2279. var id = btn.attr("data-id");
  2280. var divData = $("#data" + id);
  2281. var zone = $("#titleEditZone").text();
  2282. var domain = divData.attr("data-record-name");
  2283. var type = divData.attr("data-record-type");
  2284. if (domain === "")
  2285. domain = ".";
  2286. if (!confirm("Are you sure to permanently delete the " + type + " record '" + domain + "'?"))
  2287. return;
  2288. var apiUrl = "/api/zone/deleteRecord?token=" + token + "&zone=" + encodeURIComponent(zone) + "&domain=" + domain + "&type=" + type;
  2289. switch (type) {
  2290. case "A":
  2291. case "AAAA":
  2292. apiUrl += "&ipAddress=" + encodeURIComponent(divData.attr("data-record-ip-address"));
  2293. break;
  2294. case "NS":
  2295. apiUrl += "&nameServer=" + encodeURIComponent(divData.attr("data-record-name-server"));
  2296. break;
  2297. case "PTR":
  2298. apiUrl += "&ptrName=" + encodeURIComponent(divData.attr("data-record-ptr-name"));
  2299. break;
  2300. case "MX":
  2301. apiUrl += "&exchange=" + encodeURIComponent(divData.attr("data-record-exchange"));
  2302. break;
  2303. case "TXT":
  2304. apiUrl += "&text=" + encodeURIComponent(divData.attr("data-record-text"));
  2305. break;
  2306. case "SRV":
  2307. apiUrl += "&port=" + divData.attr("data-record-port") + "&target=" + encodeURIComponent(divData.attr("data-record-target"));
  2308. break;
  2309. case "DS":
  2310. apiUrl += "&keyTag=" + divData.attr("data-record-key-tag") + "&algorithm=" + divData.attr("data-record-algorithm") + "&digestType=" + divData.attr("data-record-digest-type") + "&digest=" + encodeURIComponent(divData.attr("data-record-digest"));
  2311. break;
  2312. case "CAA":
  2313. apiUrl += "&flags=" + divData.attr("data-record-flags") + "&tag=" + encodeURIComponent(divData.attr("data-record-tag")) + "&value=" + encodeURIComponent(divData.attr("data-record-value"));
  2314. break;
  2315. case "ANAME":
  2316. apiUrl += "&aname=" + encodeURIComponent(divData.attr("data-record-aname"));
  2317. break;
  2318. case "FWD":
  2319. apiUrl += "&protocol=" + divData.attr("data-record-protocol") + "&forwarder=" + encodeURIComponent(divData.attr("data-record-forwarder"));
  2320. break;
  2321. }
  2322. btn.button('loading');
  2323. HTTPRequest({
  2324. url: apiUrl,
  2325. success: function (responseJSON) {
  2326. $("#tr" + id).remove();
  2327. $("#tableEditZoneFooter").html("<tr><td colspan=\"5\"><b>Total Records: " + $('#tableEditZone >tbody >tr').length + "</b></td></tr>");
  2328. showAlert("success", "Record Deleted!", "Resource record was deleted successfully.");
  2329. },
  2330. error: function () {
  2331. btn.button('reset');
  2332. },
  2333. invalidToken: function () {
  2334. showPageLogin();
  2335. }
  2336. });
  2337. }
  2338. function showSignZoneModal(zoneName) {
  2339. $("#divDnssecSignZoneAlert").html("");
  2340. $("#lblDnssecSignZoneZoneName").text(zoneName);
  2341. $("#rdDnssecSignZoneAlgorithmEcdsa").prop("checked", true);
  2342. $("#divDnssecSignZoneRsaParameters").hide();
  2343. $("#optDnssecSignZoneRsaHashAlgorithm").val("SHA256");
  2344. $("#optDnssecSignZoneRsaKSKKeySize").val("2048");
  2345. $("#optDnssecSignZoneRsaZSKKeySize").val("1024");
  2346. $("#divDnssecSignZoneEcdsaParameters").show();
  2347. $("#optDnssecSignZoneEcdsaCurve").val("P256");
  2348. $("#rdDnssecSignZoneNxProofNSEC").prop("checked", true);
  2349. $("#divDnssecSignZoneNSEC3Parameters").hide();
  2350. $("#txtDnssecSignZoneNSEC3Iterations").val("0");
  2351. $("#txtDnssecSignZoneNSEC3SaltLength").val("0");
  2352. $("#txtDnssecSignZoneDnsKeyTtl").val("86400");
  2353. $("#txtDnssecSignZoneZskAutoRollover").val("90");
  2354. $("#modalDnssecSignZone").modal("show");
  2355. }
  2356. function signPrimaryZone() {
  2357. var divDnssecSignZoneAlert = $("#divDnssecSignZoneAlert");
  2358. var zone = $("#lblDnssecSignZoneZoneName").text();
  2359. var algorithm = $("input[name=rdDnssecSignZoneAlgorithm]:checked").val();
  2360. var dnsKeyTtl = $("#txtDnssecSignZoneDnsKeyTtl").val();
  2361. var zskRolloverDays = $("#txtDnssecSignZoneZskAutoRollover").val();
  2362. var nxProof = $("input[name=rdDnssecSignZoneNxProof]:checked").val();
  2363. var additionalParameters = "";
  2364. if (nxProof === "NSEC3") {
  2365. var iterations = $("#txtDnssecSignZoneNSEC3Iterations").val();
  2366. var saltLength = $("#txtDnssecSignZoneNSEC3SaltLength").val();
  2367. additionalParameters += "&iterations=" + iterations + "&saltLength=" + saltLength;
  2368. }
  2369. switch (algorithm) {
  2370. case "RSA":
  2371. var hashAlgorithm = $("#optDnssecSignZoneRsaHashAlgorithm").val();
  2372. var kskKeySize = $("#optDnssecSignZoneRsaKSKKeySize").val();
  2373. var zskKeySize = $("#optDnssecSignZoneRsaZSKKeySize").val();
  2374. additionalParameters += "&hashAlgorithm=" + hashAlgorithm + "&kskKeySize=" + kskKeySize + "&zskKeySize=" + zskKeySize;
  2375. break;
  2376. case "ECDSA":
  2377. var curve = $("#optDnssecSignZoneEcdsaCurve").val();
  2378. additionalParameters += "&curve=" + curve;
  2379. break;
  2380. }
  2381. var btn = $("#btnDnssecSignZone");
  2382. btn.button("loading");
  2383. HTTPRequest({
  2384. url: "/api/zone/dnssec/sign?token=" + token + "&zone=" + encodeURIComponent(zone) + "&algorithm=" + algorithm + "&dnsKeyTtl=" + dnsKeyTtl + "&zskRolloverDays=" + zskRolloverDays + "&nxProof=" + nxProof + additionalParameters,
  2385. success: function (responseJSON) {
  2386. btn.button('reset');
  2387. $("#modalDnssecSignZone").modal("hide");
  2388. showEditZone(zone);
  2389. showAlert("success", "Zone Signed!", "The primary zone was signed successfully.");
  2390. },
  2391. error: function () {
  2392. btn.button("reset");
  2393. },
  2394. invalidToken: function () {
  2395. btn.button("reset");
  2396. $("#modalDnssecSignZone").modal("hide");
  2397. showPageLogin();
  2398. },
  2399. objAlertPlaceholder: divDnssecSignZoneAlert
  2400. });
  2401. }
  2402. function showUnsignZoneModal(zoneName) {
  2403. $("#divDnssecUnsignZoneAlert").html("");
  2404. $("#lblDnssecUnsignZoneZoneName").text(zoneName);
  2405. $("#modalDnssecUnsignZone").modal("show");
  2406. }
  2407. function unsignPrimaryZone() {
  2408. var divDnssecUnsignZoneAlert = $("#divDnssecUnsignZoneAlert");
  2409. var zone = $("#lblDnssecUnsignZoneZoneName").text();
  2410. var btn = $("#btnDnssecUnsignZone");
  2411. btn.button("loading");
  2412. HTTPRequest({
  2413. url: "/api/zone/dnssec/unsign?token=" + token + "&zone=" + encodeURIComponent(zone),
  2414. success: function (responseJSON) {
  2415. btn.button('reset');
  2416. $("#modalDnssecUnsignZone").modal("hide");
  2417. showEditZone(zone);
  2418. showAlert("success", "Zone Unsigned!", "The primary zone was unsigned successfully.");
  2419. },
  2420. error: function () {
  2421. btn.button("reset");
  2422. },
  2423. invalidToken: function () {
  2424. btn.button("reset");
  2425. $("#modalDnssecUnsignZone").modal("hide");
  2426. showPageLogin();
  2427. },
  2428. objAlertPlaceholder: divDnssecUnsignZoneAlert
  2429. });
  2430. }
  2431. function showDnssecPropertiesModal(zoneName) {
  2432. var divDnssecPropertiesLoader = $("#divDnssecPropertiesLoader");
  2433. var divDnssecProperties = $("#divDnssecProperties");
  2434. $("#divDnssecPropertiesAlert").html("");
  2435. $("#lblDnssecPropertiesZoneName").text(zoneName);
  2436. $("#divDnssecPropertiesGenerateKey").collapse("hide");
  2437. $("#optDnssecPropertiesGenerateKeyKeyType").val("KeySigningKey");
  2438. $("#divDnssecPropertiesGenerateKeyAutomaticRollover").hide();
  2439. $("#txtDnssecPropertiesGenerateKeyAutomaticRollover").val(0);
  2440. $("#divDnssecPropertiesGenerateKeyRsaParameters").hide();
  2441. $("#optDnssecPropertiesGenerateKeyRsaHashAlgorithm").val("SHA256");
  2442. $("#optDnssecPropertiesGenerateKeyRsaKeySize").val("1024");
  2443. $("#divDnssecPropertiesGenerateKeyEcdsaParameters").show();
  2444. $("#optDnssecPropertiesGenerateKeyAlgorithm").val("ECDSA");
  2445. divDnssecPropertiesLoader.show();
  2446. divDnssecProperties.hide();
  2447. $("#modalDnssecProperties").modal("show");
  2448. refreshDnssecProperties(divDnssecPropertiesLoader);
  2449. }
  2450. function refreshDnssecProperties(divDnssecPropertiesLoader) {
  2451. var divDnssecPropertiesAlert = $("#divDnssecPropertiesAlert");
  2452. var zone = $("#lblDnssecPropertiesZoneName").text();
  2453. HTTPRequest({
  2454. url: "/api/zone/dnssec/getProperties?token=" + token + "&zone=" + zone,
  2455. success: function (responseJSON) {
  2456. var tableHtmlRows = "";
  2457. for (var i = 0; i < responseJSON.response.dnssecPrivateKeys.length; i++) {
  2458. var id = Math.floor(Math.random() * 10000);
  2459. tableHtmlRows += "<tr id=\"trDnssecPropertiesPrivateKey" + id + "\">"
  2460. + "<td>" + responseJSON.response.dnssecPrivateKeys[i].keyTag + "</td>"
  2461. + "<td>" + responseJSON.response.dnssecPrivateKeys[i].keyType + "</td>"
  2462. + "<td>" + responseJSON.response.dnssecPrivateKeys[i].algorithm + "</td>"
  2463. + "<td>" + responseJSON.response.dnssecPrivateKeys[i].state + "</td>"
  2464. + "<td>" + moment(responseJSON.response.dnssecPrivateKeys[i].stateChangedOn).local().format("YYYY-MM-DD HH:mm") + "</td>"
  2465. + "<td>" + (responseJSON.response.dnssecPrivateKeys[i].keyType === "ZoneSigningKey" ?
  2466. "<input id=\"txtDnssecPropertiesPrivateKeyAutomaticRollover" + id + "\" type=\"text\" placeholder=\"days\" style=\"width: 40px;\" value=\"" + responseJSON.response.dnssecPrivateKeys[i].rolloverDays + "\" />" +
  2467. "<button type=\"button\" class=\"btn btn-default\" style=\"padding: 2px 6px; margin-top: -2px; margin-left: 4px; font-size: 12px; height: 26px; width: 46px;\" data-id=\"" + id + "\" data-loading-text=\"Save\" onclick=\"updateDnssecPrivateKey(" + responseJSON.response.dnssecPrivateKeys[i].keyTag + ", this);\">Save</button>"
  2468. : "-") + "</td>"
  2469. + "<td align=\"right\">";
  2470. switch (responseJSON.response.dnssecPrivateKeys[i].state) {
  2471. case "Generated":
  2472. tableHtmlRows += "<button type=\"button\" class=\"btn btn-danger\" style=\"font-size: 12px; padding: 2px 0px; width: 60px;\" data-id=\"" + id + "\" data-loading-text=\"Deleting...\" onclick=\"deleteDnssecPrivateKey(" + responseJSON.response.dnssecPrivateKeys[i].keyTag + ", this);\">Delete</button>";
  2473. break;
  2474. case "Ready":
  2475. case "Active":
  2476. if (!responseJSON.response.dnssecPrivateKeys[i].isRetiring) {
  2477. tableHtmlRows += "<button type=\"button\" class=\"btn btn-warning\" style=\"font-size: 12px; padding: 2px 0px; width: 60px; margin: 0 6px 0 0;\" data-loading-text=\"Rolling...\" onclick=\"rolloverDnssecDnsKey(" + responseJSON.response.dnssecPrivateKeys[i].keyTag + ", this);\">Rollover</button>";
  2478. tableHtmlRows += "<button type=\"button\" class=\"btn btn-warning\" style=\"font-size: 12px; padding: 2px 0px; width: 60px;\" data-loading-text=\"Retiring...\" onclick=\"retireDnssecDnsKey(" + responseJSON.response.dnssecPrivateKeys[i].keyTag + ", this);\">Retire</button>";
  2479. }
  2480. break;
  2481. }
  2482. tableHtmlRows += "</td></tr>";
  2483. }
  2484. $("#tableDnssecPropertiesPrivateKeysBody").html(tableHtmlRows);
  2485. switch (responseJSON.response.dnssecStatus) {
  2486. case "SignedWithNSEC":
  2487. $("#rdDnssecPropertiesNxProofNSEC").prop("checked", true);
  2488. $("#divDnssecPropertiesNSEC3Parameters").hide();
  2489. $("#txtDnssecPropertiesNSEC3Iterations").val(0);
  2490. $("#txtDnssecPropertiesNSEC3SaltLength").val(0);
  2491. $("#btnDnssecPropertiesChangeNxProof").attr("data-nx-proof", "NSEC");
  2492. break;
  2493. case "SignedWithNSEC3":
  2494. $("#rdDnssecPropertiesNxProofNSEC3").prop("checked", true);
  2495. $("#divDnssecPropertiesNSEC3Parameters").show();
  2496. $("#txtDnssecPropertiesNSEC3Iterations").val(responseJSON.response.nsec3Iterations);
  2497. $("#txtDnssecPropertiesNSEC3SaltLength").val(responseJSON.response.nsec3SaltLength);
  2498. $("#btnDnssecPropertiesChangeNxProof").attr("data-nx-proof", "NSEC3");
  2499. $("#btnDnssecPropertiesChangeNxProof").attr("data-nsec3-iterations", responseJSON.response.nsec3Iterations);
  2500. $("#btnDnssecPropertiesChangeNxProof").attr("data-nsec3-salt-length", responseJSON.response.nsec3SaltLength);
  2501. break;
  2502. }
  2503. $("#txtDnssecPropertiesDnsKeyTtl").val(responseJSON.response.dnsKeyTtl);
  2504. if (divDnssecPropertiesLoader != null)
  2505. divDnssecPropertiesLoader.hide();
  2506. $("#divDnssecProperties").show();
  2507. },
  2508. error: function () {
  2509. if (divDnssecPropertiesLoader != null)
  2510. divDnssecPropertiesLoader.hide();
  2511. },
  2512. invalidToken: function () {
  2513. $("#modalDnssecProperties").modal("hide");
  2514. showPageLogin();
  2515. },
  2516. objAlertPlaceholder: divDnssecPropertiesAlert,
  2517. objLoaderPlaceholder: divDnssecPropertiesLoader
  2518. });
  2519. }
  2520. function updateDnssecPrivateKey(keyTag, objBtn) {
  2521. var btn = $(objBtn);
  2522. var id = btn.attr("data-id");
  2523. var divDnssecPropertiesAlert = $("#divDnssecPropertiesAlert");
  2524. var zone = $("#lblDnssecPropertiesZoneName").text();
  2525. var rolloverDays = $("#txtDnssecPropertiesPrivateKeyAutomaticRollover" + id).val();
  2526. btn.button('loading');
  2527. HTTPRequest({
  2528. url: "/api/zone/dnssec/updatePrivateKey?token=" + token + "&zone=" + zone + "&keyTag=" + keyTag + "&rolloverDays=" + rolloverDays,
  2529. success: function (responseJSON) {
  2530. btn.button('reset');
  2531. showAlert("success", "Updated!", "The DNSKEY automatic rollover config was updated successfully.", divDnssecPropertiesAlert);
  2532. },
  2533. error: function () {
  2534. btn.button('reset');
  2535. },
  2536. invalidToken: function () {
  2537. btn.button('reset');
  2538. $("#modalDnssecProperties").modal("hide");
  2539. showPageLogin();
  2540. },
  2541. objAlertPlaceholder: divDnssecPropertiesAlert
  2542. });
  2543. }
  2544. function deleteDnssecPrivateKey(keyTag, objBtn) {
  2545. if (!confirm("Are you sure to permanently delete the private key?"))
  2546. return;
  2547. var btn = $(objBtn);
  2548. var id = btn.attr("data-id");
  2549. var divDnssecPropertiesAlert = $("#divDnssecPropertiesAlert");
  2550. var zone = $("#lblDnssecPropertiesZoneName").text();
  2551. btn.button('loading');
  2552. HTTPRequest({
  2553. url: "/api/zone/dnssec/deletePrivateKey?token=" + token + "&zone=" + zone + "&keyTag=" + keyTag,
  2554. success: function (responseJSON) {
  2555. $("#trDnssecPropertiesPrivateKey" + id).remove();
  2556. showAlert("success", "Private Key Deleted!", "The DNSSEC private key was deleted successfully.", divDnssecPropertiesAlert);
  2557. },
  2558. error: function () {
  2559. btn.button('reset');
  2560. },
  2561. invalidToken: function () {
  2562. $("#modalDnssecProperties").modal("hide");
  2563. showPageLogin();
  2564. },
  2565. objAlertPlaceholder: divDnssecPropertiesAlert
  2566. });
  2567. }
  2568. function rolloverDnssecDnsKey(keyTag, objBtn) {
  2569. if (!confirm("Are you sure you want to rollover the DNS Key?"))
  2570. return;
  2571. var btn = $(objBtn);
  2572. var divDnssecPropertiesAlert = $("#divDnssecPropertiesAlert");
  2573. var zone = $("#lblDnssecPropertiesZoneName").text();
  2574. btn.button('loading');
  2575. HTTPRequest({
  2576. url: "/api/zone/dnssec/rolloverDnsKey?token=" + token + "&zone=" + zone + "&keyTag=" + keyTag,
  2577. success: function (responseJSON) {
  2578. refreshDnssecProperties();
  2579. showAlert("success", "Rollover Done!", "The DNS Key was rolled over successfully.", divDnssecPropertiesAlert);
  2580. },
  2581. error: function () {
  2582. btn.button('reset');
  2583. },
  2584. invalidToken: function () {
  2585. $("#modalDnssecProperties").modal("hide");
  2586. showPageLogin();
  2587. },
  2588. objAlertPlaceholder: divDnssecPropertiesAlert
  2589. });
  2590. }
  2591. function retireDnssecDnsKey(keyTag, objBtn) {
  2592. if (!confirm("Are you sure you want to retire the DNS Key?"))
  2593. return;
  2594. var btn = $(objBtn);
  2595. var divDnssecPropertiesAlert = $("#divDnssecPropertiesAlert");
  2596. var zone = $("#lblDnssecPropertiesZoneName").text();
  2597. btn.button('loading');
  2598. HTTPRequest({
  2599. url: "/api/zone/dnssec/retireDnsKey?token=" + token + "&zone=" + zone + "&keyTag=" + keyTag,
  2600. success: function (responseJSON) {
  2601. refreshDnssecProperties();
  2602. showAlert("success", "DNS Key Retired!", "The DNS Key was retired successfully.", divDnssecPropertiesAlert);
  2603. },
  2604. error: function () {
  2605. btn.button('reset');
  2606. },
  2607. invalidToken: function () {
  2608. $("#modalDnssecProperties").modal("hide");
  2609. showPageLogin();
  2610. },
  2611. objAlertPlaceholder: divDnssecPropertiesAlert
  2612. });
  2613. }
  2614. function publishAllDnssecPrivateKeys(objBtn) {
  2615. if (!confirm("Are you sure you want to publish all generated DNSSEC private keys?"))
  2616. return;
  2617. var btn = $(objBtn);
  2618. var divDnssecPropertiesAlert = $("#divDnssecPropertiesAlert");
  2619. var zone = $("#lblDnssecPropertiesZoneName").text();
  2620. btn.button('loading');
  2621. HTTPRequest({
  2622. url: "/api/zone/dnssec/publishAllPrivateKeys?token=" + token + "&zone=" + zone,
  2623. success: function (responseJSON) {
  2624. refreshDnssecProperties();
  2625. btn.button('reset');
  2626. showAlert("success", "Keys Published!", "All the generated DNSSEC private keys were published successfully.", divDnssecPropertiesAlert);
  2627. },
  2628. error: function () {
  2629. btn.button('reset');
  2630. },
  2631. invalidToken: function () {
  2632. btn.button('reset');
  2633. $("#modalDnssecProperties").modal("hide");
  2634. showPageLogin();
  2635. },
  2636. objAlertPlaceholder: divDnssecPropertiesAlert
  2637. });
  2638. }
  2639. function generateAndAddDnssecPrivateKey(objBtn) {
  2640. var btn = $(objBtn);
  2641. var divDnssecPropertiesAlert = $("#divDnssecPropertiesAlert");
  2642. var zone = $("#lblDnssecPropertiesZoneName").text();
  2643. var keyType = $("#optDnssecPropertiesGenerateKeyKeyType").val();
  2644. var algorithm = $("#optDnssecPropertiesGenerateKeyAlgorithm").val();
  2645. var rolloverDays = $("#txtDnssecPropertiesGenerateKeyAutomaticRollover").val();
  2646. var additionalParameters = "";
  2647. switch (algorithm) {
  2648. case "RSA":
  2649. var hashAlgorithm = $("#optDnssecPropertiesGenerateKeyRsaHashAlgorithm").val();
  2650. var keySize = $("#optDnssecPropertiesGenerateKeyRsaKeySize").val();
  2651. additionalParameters = "&hashAlgorithm=" + hashAlgorithm + "&keySize=" + keySize;
  2652. break;
  2653. case "ECDSA":
  2654. var curve = $("#optDnssecPropertiesGenerateKeyEcdsaCurve").val();
  2655. additionalParameters = "&curve=" + curve;
  2656. break;
  2657. }
  2658. btn.button('loading');
  2659. HTTPRequest({
  2660. url: "/api/zone/dnssec/generatePrivateKey?token=" + token + "&zone=" + zone + "&keyType=" + keyType + "&rolloverDays=" + rolloverDays + "&algorithm=" + algorithm + additionalParameters,
  2661. success: function (responseJSON) {
  2662. $("#divDnssecPropertiesGenerateKey").collapse("hide");
  2663. refreshDnssecProperties();
  2664. btn.button('reset');
  2665. showAlert("success", "Key Generated!", "The DNSSEC private key was generated successfully.", divDnssecPropertiesAlert);
  2666. },
  2667. error: function () {
  2668. btn.button('reset');
  2669. },
  2670. invalidToken: function () {
  2671. btn.button('reset');
  2672. $("#modalDnssecProperties").modal("hide");
  2673. showPageLogin();
  2674. },
  2675. objAlertPlaceholder: divDnssecPropertiesAlert
  2676. });
  2677. }
  2678. function changeDnssecNxProof(objBtn) {
  2679. var btn = $(objBtn);
  2680. var currentNxProof = btn.attr("data-nx-proof");
  2681. var currentIterations = btn.attr("data-nsec3-iterations");
  2682. var currentSaltLength = btn.attr("data-nsec3-salt-length");
  2683. var nxProof = $("input[name=rdDnssecPropertiesNxProof]:checked").val();
  2684. var iterations;
  2685. var saltLength;
  2686. var divDnssecPropertiesAlert = $("#divDnssecPropertiesAlert");
  2687. var zone = $("#lblDnssecPropertiesZoneName").text();
  2688. var apiUrl;
  2689. switch (currentNxProof) {
  2690. case "NSEC":
  2691. if (nxProof === "NSEC") {
  2692. showAlert("success", "Proof Changed!", "The proof of non-existence was changed successfully.", divDnssecPropertiesAlert)
  2693. return;
  2694. }
  2695. else {
  2696. var iterations = $("#txtDnssecPropertiesNSEC3Iterations").val();
  2697. var saltLength = $("#txtDnssecPropertiesNSEC3SaltLength").val();
  2698. apiUrl = "/api/zone/dnssec/convertToNSEC3?token=" + token + "&zone=" + zone + "&iterations=" + iterations + "&saltLength=" + saltLength;
  2699. }
  2700. break;
  2701. case "NSEC3":
  2702. if (nxProof === "NSEC3") {
  2703. iterations = $("#txtDnssecPropertiesNSEC3Iterations").val();
  2704. saltLength = $("#txtDnssecPropertiesNSEC3SaltLength").val();
  2705. if ((currentIterations == iterations) && (currentSaltLength == saltLength)) {
  2706. showAlert("success", "Proof Changed!", "The proof of non-existence was changed successfully.", divDnssecPropertiesAlert)
  2707. return;
  2708. }
  2709. else {
  2710. apiUrl = "/api/zone/dnssec/updateNSEC3Params?token=" + token + "&zone=" + zone + "&iterations=" + iterations + "&saltLength=" + saltLength;
  2711. }
  2712. } else {
  2713. apiUrl = "/api/zone/dnssec/convertToNSEC?token=" + token + "&zone=" + zone;
  2714. }
  2715. break;
  2716. default:
  2717. return;
  2718. }
  2719. if (!confirm("Are you sure you want to change the proof of non-existence options for the zone?"))
  2720. return;
  2721. btn.button('loading');
  2722. HTTPRequest({
  2723. url: apiUrl,
  2724. success: function (responseJSON) {
  2725. btn.attr("data-nx-proof", nxProof);
  2726. if (iterations != null)
  2727. btn.attr("data-nsec3-iterations", iterations);
  2728. if (saltLength != null)
  2729. btn.attr("data-nsec3-salt-length", saltLength);
  2730. btn.button('reset');
  2731. showEditZone(zone);
  2732. showAlert("success", "Proof Changed!", "The proof of non-existence was changed successfully.", divDnssecPropertiesAlert);
  2733. },
  2734. error: function () {
  2735. btn.button('reset');
  2736. },
  2737. invalidToken: function () {
  2738. btn.button('reset');
  2739. $("#modalDnssecProperties").modal("hide");
  2740. showPageLogin();
  2741. },
  2742. objAlertPlaceholder: divDnssecPropertiesAlert
  2743. });
  2744. }
  2745. function updateDnssecDnsKeyTtl(objBtn) {
  2746. var btn = $(objBtn);
  2747. var divDnssecPropertiesAlert = $("#divDnssecPropertiesAlert");
  2748. var zone = $("#lblDnssecPropertiesZoneName").text();
  2749. var ttl = $("#txtDnssecPropertiesDnsKeyTtl").val();
  2750. btn.button('loading');
  2751. HTTPRequest({
  2752. url: "/api/zone/dnssec/updateDnsKeyTtl?token=" + token + "&zone=" + zone + "&ttl=" + ttl,
  2753. success: function (responseJSON) {
  2754. btn.button('reset');
  2755. showAlert("success", "TTL Updated!", "The DNSKEY TTL was updated successfully.", divDnssecPropertiesAlert);
  2756. },
  2757. error: function () {
  2758. btn.button('reset');
  2759. },
  2760. invalidToken: function () {
  2761. btn.button('reset');
  2762. $("#modalDnssecProperties").modal("hide");
  2763. showPageLogin();
  2764. },
  2765. objAlertPlaceholder: divDnssecPropertiesAlert
  2766. });
  2767. }