interfaces: allow multiple IP addresses in dhcp reject from; closes #6683

This commit is contained in:
Csaba Kos 2023-07-22 00:33:14 -05:00 committed by Franco Fichtner
parent b7c4631179
commit 1f3311f5dd
2 changed files with 11 additions and 5 deletions

View File

@ -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'])) {

View File

@ -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");
<td>
<input name="dhcprejectfrom" type="text" id="dhcprejectfrom" value="<?=htmlspecialchars($pconfig['dhcprejectfrom']);?>" />
<div class="hidden" data-for="help_for_dhcprejectfrom">
<?=gettext("If there is a certain upstream DHCP server that should be ignored, place the IP address or subnet of the DHCP server to be ignored here."); ?>
<?=gettext("If there are certain upstream DHCP servers that should be ignored, place the comma separated list of IP addresses of the DHCP servers to be ignored here."); ?>
<?=gettext("This is useful for rejecting leases from cable modems that offer private IPs when they lose upstream sync."); ?>
</div>
</td>