From 1f3311f5dd45784fe6802a2d150776dc75a6c591 Mon Sep 17 00:00:00 2001 From: Csaba Kos Date: Sat, 22 Jul 2023 00:33:14 -0500 Subject: [PATCH] interfaces: allow multiple IP addresses in dhcp reject from; closes #6683 --- src/etc/inc/interfaces.inc | 4 ++-- src/www/interfaces.php | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 9fc6fc297..1d865733f 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -3112,7 +3112,7 @@ EOD; $dhclientconf .= " supersede interface-mtu 0;\n"; } - if (is_ipaddrv4($wancfg['dhcprejectfrom'])) { + if (!empty($wancfg['dhcprejectfrom'])) { $dhclientconf .= " reject {$wancfg['dhcprejectfrom']};\n"; } @@ -3223,7 +3223,7 @@ function DHCP_Config_File_Advanced($interface, $wancfg, $wanif) if (empty($wancfg['dhcphonourmtu'])) { $dhclientconf .= "\tsupersede interface-mtu 0;\n"; } - if (is_ipaddrv4($wancfg['dhcprejectfrom'])) { + if (!empty($wancfg['dhcprejectfrom'])) { $dhclientconf .= "\treject {$wancfg['dhcprejectfrom']};\n"; } if (isset($wancfg['dhcpvlanprio'])) { diff --git a/src/www/interfaces.php b/src/www/interfaces.php index 3288373c6..d7e865d4e 100644 --- a/src/www/interfaces.php +++ b/src/www/interfaces.php @@ -845,8 +845,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { if (!empty($pconfig['alias-subnet']) && !is_numeric($pconfig['alias-subnet'])) { $input_errors[] = gettext("A valid alias subnet bit count must be specified."); } - if (!empty($pconfig['dhcprejectfrom']) && !is_ipaddrv4($pconfig['dhcprejectfrom'])) { - $input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from."); + + if (!empty($pconfig['dhcprejectfrom'])) { + foreach (explode(',', $pconfig['dhcprejectfrom']) as $addr) { + if (!is_ipaddrv4($addr)) { + $input_errors[] = gettext('A valid alias IP address list must be specified to reject DHCP leases from.'); + break; + } + } } if ($pconfig['gateway'] != "none" || $pconfig['gatewayv6'] != "none") { @@ -2289,7 +2295,7 @@ include("head.inc");