From 16eace63e7cb2cc5ef21e0e6e956d4871ac4ff51 Mon Sep 17 00:00:00 2001 From: billz Date: Sun, 21 Feb 2021 23:51:20 +0000 Subject: [PATCH 1/5] Add dhcp-ignore handling --- includes/dhcp.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/dhcp.php b/includes/dhcp.php index 0ebf641b..14c0cf34 100755 --- a/includes/dhcp.php +++ b/includes/dhcp.php @@ -45,12 +45,15 @@ function DisplayDHCPConfig() } } getWifiInterface(); + $ap_iface = $_SESSION['ap_interface']; $serviceStatus = $dnsmasq_state ? "up" : "down"; exec('cat '. RASPI_DNSMASQ_PREFIX.'raspap.conf', $return); $conf = ParseConfig($return); + exec('cat '. RASPI_DNSMASQ_PREFIX.$ap_iface.'.conf', $return); + $conf = array_merge(ParseConfig($return)); + $hosts = (array)$conf['dhcp-host']; exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces); exec('cat ' . RASPI_DNSMASQ_LEASES, $leases); - $ap_iface = $_SESSION['ap_interface']; echo renderTemplate( "dhcp", compact( @@ -59,7 +62,7 @@ function DisplayDHCPConfig() "dnsmasq_state", "ap_iface", "conf", - "dhcpHost", + "hosts", "interfaces", "leases" ) @@ -188,6 +191,9 @@ function updateDnsmasqConfig($iface,$status) } $config .= PHP_EOL; } + if ($_POST['dhcp-ignore'] == "1") { + $config .= 'dhcp-ignore=tag:!known'.PHP_EOL; + } file_put_contents("/tmp/dnsmasqdata", $config); $msg = file_exists(RASPI_DNSMASQ_PREFIX.$iface.'.conf') ? 'updated' : 'added'; system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_PREFIX.$iface.'.conf', $result); From 9466e4fa70bbba629fd20679f0d1d04fac3c8e9d Mon Sep 17 00:00:00 2001 From: billz Date: Sun, 21 Feb 2021 23:53:14 +0000 Subject: [PATCH 2/5] Rework static leases tab --- templates/dhcp/static_leases.php | 34 ++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/templates/dhcp/static_leases.php b/templates/dhcp/static_leases.php index 3b804270..bec40ca0 100644 --- a/templates/dhcp/static_leases.php +++ b/templates/dhcp/static_leases.php @@ -3,7 +3,7 @@

- +
@@ -13,13 +13,21 @@ " class="form-control">
- +
+
+
+

+ + dhcp-host entries to the dnsmasq configuration.") ?> +

+
+
" class="form-control" autofocus="autofocus"> @@ -28,10 +36,27 @@ " class="form-control">
- +
+
+
+
+
+ +
+ aria-describedby="dhcp-ignore-description"> + +
+

+ ignore any clients which are not specified in the static leases list.") ?> + dhcp-ignore to the dnsmasq configuration.") ?> +

+
+
+
+ + From a33512953dc691e10aec58aa27242fbb191ca951 Mon Sep 17 00:00:00 2001 From: billz Date: Sun, 21 Feb 2021 23:53:58 +0000 Subject: [PATCH 3/5] Update en_US dhcp msgs --- locale/en_US/LC_MESSAGES/messages.po | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/locale/en_US/LC_MESSAGES/messages.po b/locale/en_US/LC_MESSAGES/messages.po index dcd715ae..26677ce7 100644 --- a/locale/en_US/LC_MESSAGES/messages.po +++ b/locale/en_US/LC_MESSAGES/messages.po @@ -362,6 +362,24 @@ msgstr "Log DHCP requests" msgid "Log DNS queries" msgstr "Log DNS queries" +msgid "Restrict access" +msgstr "Restrict access" + +msgid "Limit network access to static clients" +msgstr "Limit network access to static clients" + +msgid "Enable this option if you want RaspAP to ignore any clients which are not specified in the static leases list." +msgstr "Enable this option if you want RaspAP to ignore any clients which are not specified in the static leases list." + +msgid "This option adds dhcp-ignore to the dnsmasq configuration." +msgstr "This option adds dhcp-ignore to the dnsmasq configuration." + +msgid "Clients with a particular hardware MAC address can always be allocated the same IP address." +msgstr "Clients with a particular hardware MAC address can always be allocated the same IP address." + +msgid "This option adds dhcp-host entries to the dnsmasq configuration." +msgstr "This option adds dhcp-host entries to the dnsmasq configuration." + #: includes/hostapd.php msgid "Basic" msgstr "Basic" From f156fbceae9b5117de45f0fa8505a548225a0db0 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 22 Feb 2021 08:00:50 +0000 Subject: [PATCH 4/5] Add tag set:known to dhcp-host --- includes/dhcp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/dhcp.php b/includes/dhcp.php index 14c0cf34..d4f981ed 100755 --- a/includes/dhcp.php +++ b/includes/dhcp.php @@ -175,7 +175,7 @@ function updateDnsmasqConfig($iface,$status) $mac = trim($_POST["static_leases"]["mac"][$i]); $ip = trim($_POST["static_leases"]["ip"][$i]); if ($mac != "" && $ip != "") { - $config .= "dhcp-host=$mac,$ip".PHP_EOL; + $config .= "dhcp-host=$mac,$ip".",set:known".PHP_EOL; } } if ($_POST['no-resolv'] == "1") { From f7a441566e3ca8f586a283fec320f8593ac3f52d Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 22 Feb 2021 08:01:41 +0000 Subject: [PATCH 5/5] Optimize template layout --- templates/dhcp/static_leases.php | 97 +++++++++++++++----------------- 1 file changed, 46 insertions(+), 51 deletions(-) diff --git a/templates/dhcp/static_leases.php b/templates/dhcp/static_leases.php index bec40ca0..aaa8cb12 100644 --- a/templates/dhcp/static_leases.php +++ b/templates/dhcp/static_leases.php @@ -1,50 +1,44 @@
-

- -
- - -
-
- " class="form-control"> -
-
- " class="form-control"> -
-
- -
-
- -
- -
-
-
+
+
+

dhcp-host entries to the dnsmasq configuration.") ?>

-
-
-
-
- " class="form-control" autofocus="autofocus"> -
-
- " class="form-control"> -
-
- -
-
+
+ + +
+
+ " class="form-control"> +
+
+ " class="form-control"> +
+
+ +
+
+ +
-
-
-
+
+
+ " class="form-control" autofocus="autofocus"> +
+
+ " class="form-control"> +
+
+ +
+
+ +
- +
aria-describedby="dhcp-ignore-description"> @@ -57,18 +51,19 @@
- +