mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 00:24:40 +00:00
interfaces: fix loopholes in the VipNetworkField #6775
This commit is contained in:
parent
bcd8cec574
commit
e239ac2ab2
@ -43,12 +43,12 @@ class VipSettingsController extends ApiMutableModelControllerBase
|
||||
*/
|
||||
private function getVipOverlay()
|
||||
{
|
||||
$overlay = ['network' => ''];
|
||||
$overlay = ['network' => '', 'subnet' => '', 'subnet_bits' => ''];
|
||||
$tmp = $this->request->getPost('vip');
|
||||
if (!empty($tmp['network'])) {
|
||||
$parts = explode('/', $tmp['network'], 2);
|
||||
$overlay['subnet'] = $parts[0];
|
||||
if (count($parts) < 2) {
|
||||
if (count($parts) == 1 || $parts[1] == '') {
|
||||
$overlay['subnet_bits'] = strpos($parts[0], ':') !== false ? 128 : 32;
|
||||
} else {
|
||||
$overlay['subnet_bits'] = $parts[1];
|
||||
|
||||
@ -45,15 +45,12 @@ class VipNetworkField extends TextField
|
||||
}
|
||||
$validators[] = new CallbackValidator(["callback" => function ($data) {
|
||||
$parent = $this->getParentNode();
|
||||
$subnet_bits = (string)$parent->subnet_bits;
|
||||
$subnet = (string)$parent->subnet;
|
||||
$messages = [];
|
||||
if (!Util::isSubnet($subnet . "/" . $subnet_bits)) {
|
||||
$messages[] = sprintf(
|
||||
gettext('Entry "%s/%s" is not a valid network address.'),
|
||||
$subnet,
|
||||
$subnet_bits
|
||||
);
|
||||
$network = implode('/', [(string)$parent->subnet, (string)$parent->subnet_bits]);
|
||||
if (empty((string)$parent->subnet)) {
|
||||
$messages[] = gettext('A network address is required.');
|
||||
} elseif (!Util::isIpAddress((string)$parent->subnet) || !Util::isSubnet($network)) {
|
||||
$messages[] = sprintf(gettext('Entry "%s" is not a valid network address.'), $network);
|
||||
}
|
||||
return $messages;
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ class Vip extends BaseModel
|
||||
$vips = [];
|
||||
$carp_vhids = [];
|
||||
|
||||
// collect chaned VIP entries
|
||||
// collect changed VIP entries
|
||||
$vip_fields = ['mode', 'subnet', 'subnet_bits', 'password', 'vhid', 'interface'];
|
||||
foreach ($this->getFlatNodes() as $key => $node) {
|
||||
$tagName = $node->getInternalXMLTagName();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user