mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-20 03:16:12 +00:00
Services: Kea DHCP: Kea DHCPv4 / Reservations - add address constraint (address should lie inside requested netblock)
This commit is contained in:
parent
27e27f25c5
commit
e210c854c3
@ -28,6 +28,7 @@
|
||||
|
||||
namespace OPNsense\Kea;
|
||||
|
||||
use Phalcon\Messages\Message;
|
||||
use OPNsense\Base\BaseModel;
|
||||
use OPNsense\Core\Config;
|
||||
use OPNsense\Core\Backend;
|
||||
@ -66,6 +67,31 @@ class KeaDhcpv4 extends BaseModel
|
||||
return parent::setNodes($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function performValidation($validateFullModel = false)
|
||||
{
|
||||
$messages = parent::performValidation($validateFullModel);
|
||||
// validate changed reservations
|
||||
foreach ($this->reservations->reservation->iterateItems() as $reservation) {
|
||||
if (!$validateFullModel && !$reservation->isFieldChanged()) {
|
||||
continue;
|
||||
}
|
||||
$key = $reservation->__reference;
|
||||
$subnet = "";
|
||||
$subnet_node = $this->getNodeByReference("subnets.subnet4.{$reservation->subnet}");
|
||||
if ($subnet_node) {
|
||||
$subnet = (string)$subnet_node->subnet;
|
||||
}
|
||||
if (!Util::isIPInCIDR((string)$reservation->ip_address, $subnet)) {
|
||||
$messages->appendMessage(new Message(gettext("Address not in specified subnet"), $key . ".ip_address"));
|
||||
}
|
||||
}
|
||||
return $messages;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* should filter rules be enabled
|
||||
* @return bool
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user