From c7ba2e1ec5b37c089c8260eb367ea65f249951bf Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 17 Jan 2023 18:10:13 +0100 Subject: [PATCH 1/2] Fix handling of infinite lease time. --- includes/dhcp.php | 6 +++--- templates/dhcp/general.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/dhcp.php b/includes/dhcp.php index 62371722..22ee2c72 100755 --- a/includes/dhcp.php +++ b/includes/dhcp.php @@ -143,10 +143,10 @@ function validateDHCPInput() if (!filter_var($_POST['RangeEnd'], FILTER_VALIDATE_IP) && !empty($_POST['RangeEnd'])) { $errors .= _('Invalid DHCP range end.').'
'.PHP_EOL; } - if (!ctype_digit($_POST['RangeLeaseTime']) && $_POST['RangeLeaseTimeUnits'] !== 'infinite') { + if (!ctype_digit($_POST['RangeLeaseTime']) && $_POST['RangeLeaseTimeUnits'] !== 'i') { $errors .= _('Invalid DHCP lease time, not a number.').'
'.PHP_EOL; } - if (!in_array($_POST['RangeLeaseTimeUnits'], array('m', 'h', 'd', 'infinite'))) { + if (!in_array($_POST['RangeLeaseTimeUnits'], array('m', 'h', 'd', 'i'))) { $errors .= _('Unknown DHCP lease time unit.').'
'.PHP_EOL; } if ($_POST['Metric'] !== '' && !ctype_digit($_POST['Metric'])) { @@ -181,7 +181,7 @@ function updateDnsmasqConfig($iface,$status) { $config = '# RaspAP '.$iface.' configuration'.PHP_EOL; $config .= 'interface='.$iface.PHP_EOL.'dhcp-range='.$_POST['RangeStart'].','.$_POST['RangeEnd'].','.$_POST['SubnetMask'].','; - if ($_POST['RangeLeaseTimeUnits'] !== 'infinite') { + if ($_POST['RangeLeaseTimeUnits'] !== 'i') { $config .= $_POST['RangeLeaseTime']; } $config .= $_POST['RangeLeaseTimeUnits'].PHP_EOL; diff --git a/templates/dhcp/general.php b/templates/dhcp/general.php index 83bc3504..47c802f5 100644 --- a/templates/dhcp/general.php +++ b/templates/dhcp/general.php @@ -107,7 +107,7 @@ - + From 56b15a8eb8cd8d3044afc502125a6a8ad7de226d Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 17 Jan 2023 18:23:50 +0100 Subject: [PATCH 2/2] Handle infinite value when constructing cfg --- includes/dhcp.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/dhcp.php b/includes/dhcp.php index 22ee2c72..35080fe9 100755 --- a/includes/dhcp.php +++ b/includes/dhcp.php @@ -183,8 +183,10 @@ function updateDnsmasqConfig($iface,$status) $config .= 'interface='.$iface.PHP_EOL.'dhcp-range='.$_POST['RangeStart'].','.$_POST['RangeEnd'].','.$_POST['SubnetMask'].','; if ($_POST['RangeLeaseTimeUnits'] !== 'i') { $config .= $_POST['RangeLeaseTime']; + $config .= $_POST['RangeLeaseTimeUnits'].PHP_EOL; + } else { + $config .= 'infinite'.PHP_EOL; } - $config .= $_POST['RangeLeaseTimeUnits'].PHP_EOL; // Static leases $staticLeases = array(); for ($i=0; $i < count($_POST["static_leases"]["mac"]); $i++) {