From a3c8def1200d58d8ff16c8815e0c6d727e523404 Mon Sep 17 00:00:00 2001 From: glaszig Date: Fri, 28 Feb 2020 23:37:52 +0100 Subject: [PATCH] added ui to manage upstream dns servers --- app/js/custom.js | 22 ++++++++++++++++++++++ includes/dhcp.php | 6 ++++++ templates/dhcp.php | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/app/js/custom.js b/app/js/custom.js index 1923b38d..3638ed4d 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -143,6 +143,28 @@ $(document).on("submit", ".js-dhcp-settings-form", function(e) { $(".js-add-dhcp-static-lease").trigger("click"); }); +$(document).on("click", ".js-add-dhcp-upstream-server", function(e) { + e.preventDefault(); + + var field = $("#add-dhcp-upstream-server-field") + var row = $("#dhcp-upstream-server").html().replace("{{ server }}", field.val()) + + if (field.val().trim() == "") { return } + + $(".js-dhcp-upstream-servers").append(row) + + field.val("") +}); + +$(document).on("click", ".js-remove-dhcp-upstream-server", function(e) { + e.preventDefault(); + $(this).parents(".js-dhcp-upstream-server").remove(); +}); + +$(document).on("submit", ".js-dhcp-settings-form", function(e) { + $(".js-add-dhcp-upstream-server").trigger("click"); +}); + $(document).on("click", "#gen_wpa_passphrase", function(e) { $('#txtwpapassphrase').val(genPassword(63)); }); diff --git a/includes/dhcp.php b/includes/dhcp.php index 82d084d7..63b56831 100755 --- a/includes/dhcp.php +++ b/includes/dhcp.php @@ -59,6 +59,10 @@ function DisplayDHCPConfig() } } + foreach ($_POST['server'] as $server) { + $config .= "server=$server".PHP_EOL; + } + if ($_POST['DNS1']) { $config .= "dhcp-option=6," . $_POST['DNS1']; if ($_POST['DNS2']) { @@ -126,6 +130,7 @@ function DisplayDHCPConfig() $dhcpHost = $conf["dhcp-host"]; $dhcpHost = empty($dhcpHost) ? [] : $dhcpHost; $dhcpHost = is_array($dhcpHost) ? $dhcpHost : [ $dhcpHost ]; + $upstreamServers = is_array($conf['server']) ? $conf['server'] : [ $conf['server'] ]; $DNS1 = ''; $DNS2 = ''; @@ -173,6 +178,7 @@ function DisplayDHCPConfig() "RangeEnd", "DNS1", "DNS2", + "upstreamServers", "arrRangeLeaseTime", "mselected", "hselected", diff --git a/templates/dhcp.php b/templates/dhcp.php index 3b06e531..133e76dd 100755 --- a/templates/dhcp.php +++ b/templates/dhcp.php @@ -84,6 +84,45 @@ +
+
+ + +
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ + ]/[domain/]][[#][@|[#]]"); ?> + +
+
+
+ + + + " name="savedhcpdsettings" />