mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 16:14:40 +00:00
openvpn: tunnel network tweaks, only one needed #2266
This commit is contained in:
parent
01b0534cc6
commit
c51a6916c3
@ -161,7 +161,16 @@ function do_input_validation($postdata, $reqdfields, $reqdfieldsn, &$input_error
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($reqdfields); $i++) {
|
||||
if (empty($postdata[$reqdfields[$i]])) {
|
||||
$fields = explode(',', $reqdfields[$i]);
|
||||
$found = false;
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if (!empty($postdata[$field])) {
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$input_errors[] = sprintf(gettext("The field %s is required."), $reqdfieldsn[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,15 +251,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($pconfig['tunnel_network'])) {
|
||||
if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4")) {
|
||||
$input_errors[] = $result;
|
||||
}
|
||||
if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4")) {
|
||||
$input_errors[] = $result;
|
||||
}
|
||||
if (!empty($pconfig['tunnel_networkv6'])) {
|
||||
if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6")) {
|
||||
$input_errors[] = $result;
|
||||
}
|
||||
if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6")) {
|
||||
$input_errors[] = $result;
|
||||
}
|
||||
if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4")) {
|
||||
$input_errors[] = $result;
|
||||
|
||||
@ -295,10 +295,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
}
|
||||
|
||||
if ($pconfig['dev_mode'] != "tap") {
|
||||
$reqdfields[] = 'tunnel_network';
|
||||
$reqdfieldsn[] = gettext('Tunnel network');
|
||||
$reqdfields[] = 'tunnel_network,tunnel_networkv6';
|
||||
$reqdfieldsn[] = gettext('Tunnel Network');
|
||||
} else {
|
||||
if ($pconfig['serverbridge_dhcp'] && $pconfig['tunnel_network']) {
|
||||
if ($pconfig['serverbridge_dhcp'] && ($pconfig['tunnel_network'] || $pconfig['tunnel_networkv6'])) {
|
||||
$input_errors[] = gettext("Using a tunnel network and server bridge settings together is not allowed.");
|
||||
}
|
||||
if (($pconfig['serverbridge_dhcp_start'] && !$pconfig['serverbridge_dhcp_end'])
|
||||
@ -318,6 +318,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
if (isset($pconfig['reneg-sec']) && $pconfig['reneg-sec'] != "" && (string)((int)$pconfig['reneg-sec']) != $pconfig['reneg-sec']) {
|
||||
$input_errors[] = gettext("Renegotiate time should contain a valid number of seconds.");
|
||||
}
|
||||
|
||||
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
|
||||
|
||||
if (count($input_errors) == 0) {
|
||||
@ -1622,8 +1623,9 @@ endif; ?>
|
||||
<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
|
||||
</td>
|
||||
<td>
|
||||
<?=htmlspecialchars($server['tunnel_network']);?> <?=!empty($server['tunnel_networkv6']) ? "," :""?>
|
||||
<?=htmlspecialchars($server['tunnel_networkv6']);?>
|
||||
<?= htmlspecialchars($server['tunnel_network']) ?>
|
||||
<?= !empty($server['tunnel_networkv6']) && !empty($server['tunnel_network']) ? ',' : '' ?>
|
||||
<?= htmlspecialchars($server['tunnel_networkv6']) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?=htmlspecialchars($server['description']);?>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user