From 28caaf7342f0f54406f9659a30a30a933de36dcd Mon Sep 17 00:00:00 2001 From: vnxme <46669194+vnxme@users.noreply.github.com> Date: Sat, 28 Nov 2020 11:44:00 +0300 Subject: [PATCH] DHCP: Add min-secs option for each subnet (#4486) --- src/etc/inc/plugins.inc.d/dhcpd.inc | 11 +++++++++++ src/www/services_dhcp.php | 17 ++++++++++++++++- src/www/services_dhcpv6.php | 17 +++++++++++++++-- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/etc/inc/plugins.inc.d/dhcpd.inc b/src/etc/inc/plugins.inc.d/dhcpd.inc index 37abb50f9..63eb4d636 100644 --- a/src/etc/inc/plugins.inc.d/dhcpd.inc +++ b/src/etc/inc/plugins.inc.d/dhcpd.inc @@ -990,6 +990,12 @@ EOD; if (!empty($dhcpifconf['maxleasetime'])) { $dhcpdconf .= " max-lease-time {$dhcpifconf['maxleasetime']};\n"; } + + // min-secs + if (!empty($dhcpifconf['minsecs'])) { + $dhcpdconf .= " min-secs {$dhcpifconf['minsecs']};\n"; + } + // interface MTU if (!empty($dhcpifconf['interface_mtu'])) { $dhcpdconf .= " option interface-mtu {$dhcpifconf['interface_mtu']};\n"; @@ -1501,6 +1507,11 @@ EOD; $dhcpdv6conf .= " max-lease-time {$dhcpv6ifconf['maxleasetime']};\n"; } + // min-secs + if (!empty($dhcpv6ifconf['minsecs'])) { + $dhcpdv6conf .= " min-secs {$dhcpv6ifconf['minsecs']};\n"; + } + // ntp-servers if (isset($dhcpv6ifconf['ntpserver'][0])) { $ntpservers = array(); diff --git a/src/www/services_dhcp.php b/src/www/services_dhcp.php index b53f4306e..621a62df9 100644 --- a/src/www/services_dhcp.php +++ b/src/www/services_dhcp.php @@ -97,7 +97,7 @@ $config_copy_fieldsnames = array('enable', 'staticarp', 'failover_peerip', 'fail 'defaultleasetime', 'maxleasetime', 'gateway', 'domain', 'domainsearchlist', 'denyunknown', 'ddnsdomain', 'ddnsdomainprimary', 'ddnsdomainkeyname', 'ddnsdomainkey', 'ddnsdomainalgorithm', 'ddnsupdate', 'mac_allow', 'mac_deny', 'tftp', 'bootfilename', 'ldap', 'netboot', 'nextserver', 'filename', 'filename32', 'filename64', - 'rootpath', 'netmask', 'numberoptions', 'interface_mtu', 'wpad', 'omapi', 'omapiport', 'omapialgorithm', 'omapikey'); + 'rootpath', 'netmask', 'numberoptions', 'interface_mtu', 'wpad', 'omapi', 'omapiport', 'omapialgorithm', 'omapikey', 'minsecs'); if ($_SERVER['REQUEST_METHOD'] === 'GET') { // handle identifiers and action @@ -226,6 +226,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { if (!empty($pconfig['maxleasetime']) && (!is_numeric($pconfig['maxleasetime']) || ($pconfig['maxleasetime'] < 60) || ($pconfig['maxleasetime'] <= $pconfig['defaultleasetime']))) { $input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time."); } + + if (!empty($pconfig['minsecs']) && (!is_numeric($pconfig['minsecs']) || ($pconfig['minsecs'] < 0) || ($pconfig['minsecs'] > 255))) { + $input_errors[] = gettext("The response delay must be higher than 0 and no more than 255 seconds."); + } + if ((!empty($pconfig['ddnsdomain']) && !is_domain($pconfig['ddnsdomain']))) { $input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration."); } @@ -842,6 +847,16 @@ include("head.inc"); +