mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 00:07:26 +00:00
dnsmasq: Implement a light validation for option6 values (#8520)
* dnsmasq: Implement a light validation for option6 values as they require to be wrapped inside square brackets if they contain an IPv6 address * dnsmasq: Improve the IPv6 bracket check, also handle multiple ipv6 addresses that are comma separated, use isIpv6Address() * dnsmasq: Put IPv6 value check inline since dhcp-match and dhcp-option have been unified in master. * Update src/opnsense/mvc/app/models/OPNsense/Dnsmasq/Dnsmasq.php Co-authored-by: Ad Schellevis <AdSchellevis@users.noreply.github.com> * Update src/opnsense/mvc/app/models/OPNsense/Dnsmasq/Dnsmasq.php Co-authored-by: Ad Schellevis <AdSchellevis@users.noreply.github.com> * dnsmasq: trim value directly --------- Co-authored-by: Ad Schellevis <AdSchellevis@users.noreply.github.com>
This commit is contained in:
parent
905b990dea
commit
7210f016eb
@ -31,6 +31,7 @@ namespace OPNsense\Dnsmasq;
|
||||
use OPNsense\Base\BaseModel;
|
||||
use OPNsense\Base\Messages\Message;
|
||||
use OPNsense\Core\Backend;
|
||||
use OPNsense\Firewall\Util;
|
||||
|
||||
/**
|
||||
* Class Dnsmasq
|
||||
@ -259,6 +260,26 @@ class Dnsmasq extends BaseModel
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!$option->value->isEmpty() &&
|
||||
!$option->option6->isEmpty()
|
||||
) {
|
||||
$values = array_map('trim', explode(',', (string)$option->value));
|
||||
foreach ($values as $value) {
|
||||
if (
|
||||
Util::isIpv6Address(trim($value, '[]')) &&
|
||||
!(str_starts_with($value, '[') && str_ends_with($value, ']'))
|
||||
) {
|
||||
$messages->appendMessage(
|
||||
new Message(
|
||||
gettext("Each IPv6 address must be wrapped inside square brackets '[fe80::]'."),
|
||||
$key . ".value"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user