Commit 5b379a6f authored by Ad Schellevis's avatar Ad Schellevis

(legacy) refactor vpn_ipsec_settings.php

parent 392df2f1
...@@ -33,39 +33,38 @@ require_once("services.inc"); ...@@ -33,39 +33,38 @@ require_once("services.inc");
require_once("pfsense-utils.inc"); require_once("pfsense-utils.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
if (!is_array($config['ipsec'])) { if (!isset($config['ipsec'])) {
$config['ipsec'] = array(); $config['ipsec'] = array();
} }
$pconfig['noinstalllanspd'] = $config['system']['noinstalllanspd']; if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['preferoldsa_enable'] = isset($config['ipsec']['preferoldsa']); // fetch form data
foreach ($ipsec_loglevels as $lkey => $ldescr) { $pconfig = array();
$pconfig['noinstalllanspd'] = isset($config['system']['noinstalllanspd']);
$pconfig['preferoldsa_enable'] = isset($config['ipsec']['preferoldsa']);
foreach ($ipsec_loglevels as $lkey => $ldescr) {
if (!empty($config['ipsec']["ipsec_{$lkey}"])) { if (!empty($config['ipsec']["ipsec_{$lkey}"])) {
$pconfig["ipsec_{$lkey}"] = $config['ipsec']["ipsec_{$lkey}"]; $pconfig["ipsec_{$lkey}"] = $config['ipsec']["ipsec_{$lkey}"];
} else {
$pconfig["ipsec_{$lkey}"] = null;
} }
} }
$pconfig['failoverforcereload'] = isset($config['ipsec']['failoverforcereload']); $pconfig['failoverforcereload'] = isset($config['ipsec']['failoverforcereload']);
$pconfig['maxmss_enable'] = isset($config['system']['maxmss_enable']); $pconfig['maxmss_enable'] = isset($config['system']['maxmss_enable']);
$pconfig['maxmss'] = $config['system']['maxmss']; $pconfig['maxmss'] = isset($config['system']['maxmss']) ? $config['system']['maxmss'] : null;
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($_POST) { // save form data
unset($input_errors);
$pconfig = $_POST; $pconfig = $_POST;
if (isset($pconfig['noinstalllanspd']) && $pconfig['noinstalllanspd'] == "yes") {
if (!$input_errors) {
if ($_POST['noinstalllanspd'] == "yes") {
$config['system']['noinstalllanspd'] = true; $config['system']['noinstalllanspd'] = true;
} else { } elseif (isset($config['system']['noinstalllanspd'])) {
if (isset($config['system']['noinstalllanspd'])) {
unset($config['system']['noinstalllanspd']); unset($config['system']['noinstalllanspd']);
} }
} if (isset($pconfig['preferoldsa_enable']) && $pconfig['preferoldsa_enable'] == "yes") {
if ($_POST['preferoldsa_enable'] == "yes") {
$config['ipsec']['preferoldsa'] = true; $config['ipsec']['preferoldsa'] = true;
} elseif (isset($config['ipsec']['preferoldsa'])) } elseif (isset($config['ipsec']['preferoldsa'])) {
unset($config['ipsec']['preferoldsa']); unset($config['ipsec']['preferoldsa']);
}
if (is_array($config['ipsec'])) { if (is_array($config['ipsec'])) {
foreach ($ipsec_loglevels as $lkey => $ldescr) { foreach ($ipsec_loglevels as $lkey => $ldescr) {
if (empty($_POST["ipsec_{$lkey}"])) { if (empty($_POST["ipsec_{$lkey}"])) {
...@@ -78,22 +77,26 @@ if ($_POST) { ...@@ -78,22 +77,26 @@ if ($_POST) {
} }
} }
if ($_POST['failoverforcereload'] == "yes") { if (isset($pconfig['failoverforcereload']) && $pconfig['failoverforcereload'] == "yes") {
$config['ipsec']['failoverforcereload'] = true; $config['ipsec']['failoverforcereload'] = true;
} elseif (isset($config['ipsec']['failoverforcereload'])) } elseif (isset($config['ipsec']['failoverforcereload']))
unset($config['ipsec']['failoverforcereload']); unset($config['ipsec']['failoverforcereload']);
if ($_POST['maxmss_enable'] == "yes") { if (isset($pconfig['maxmss_enable']) && $pconfig['maxmss_enable'] == "yes") {
$config['system']['maxmss_enable'] = true; $config['system']['maxmss_enable'] = true;
$config['system']['maxmss'] = $_POST['maxmss']; if (!empty($pconfig['maxmss']) && is_numericint($pconfig['maxmss'])) {
$config['system']['maxmss'] = $pconfig['maxmss'];
}
} else { } else {
if (isset($config['system']['maxmss_enable'])) {
unset($config['system']['maxmss_enable']); unset($config['system']['maxmss_enable']);
}
if (isset($config['system']['maxmss'])) {
unset($config['system']['maxmss']); unset($config['system']['maxmss']);
} }
}
write_config(); write_config();
$retval = 0;
$retval = filter_configure(); $retval = filter_configure();
if (stristr($retval, "error") <> true) { if (stristr($retval, "error") <> true) {
$savemsg = get_std_save_message(gettext($retval)); $savemsg = get_std_save_message(gettext($retval));
...@@ -104,10 +107,6 @@ if ($_POST) { ...@@ -104,10 +107,6 @@ if ($_POST) {
vpn_ipsec_configure_preferoldsa(); vpn_ipsec_configure_preferoldsa();
vpn_ipsec_configure(); vpn_ipsec_configure();
vpn_ipsec_configure_loglevels(); vpn_ipsec_configure_loglevels();
// header("Location: vpn_ipsec_settings.php");
// return;
}
} }
$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Settings")); $pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Settings"));
...@@ -121,153 +120,134 @@ include("head.inc"); ...@@ -121,153 +120,134 @@ include("head.inc");
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
$( document ).ready(function() {
maxmss_checked()
});
function maxmss_checked(obj) { function maxmss_checked(obj) {
if (obj.checked) if ($('#maxmss_enable').is(":checked")) {
jQuery('#maxmss').attr('disabled',false); $('#maxmss').attr('disabled',false);
else $("#maxmss").addClass('show');
jQuery('#maxmss').attr('disabled','true'); $("#maxmss").removeClass('hidden');
} else {
$('#maxmss').attr('disabled',true);
$("#maxmss").addClass('hidden');
$("#maxmss").removeClass('show');
}
} }
//]]> //]]>
</script> </script>
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php
<?php
if (isset($savemsg)) { if (isset($savemsg)) {
print_info_box($savemsg); print_info_box($savemsg);
} }
if (isset($input_errors) && count($input_errors) > 0) { if (isset($input_errors) && count($input_errors) > 0) {
print_input_errors($input_errors); print_input_errors($input_errors);
} }
?> ?>
<section class="col-xs-12"> <section class="col-xs-12">
<? $active_tab = "/vpn_ipsec_settings.php"; <? $active_tab = "/vpn_ipsec_settings.php";
include('vpn_ipsec_tabs.inc'); ?> include('vpn_ipsec_tabs.inc'); ?>
<div class="tab-content content-box col-xs-12"> <div class="tab-content content-box col-xs-12">
<form action="vpn_ipsec_settings.php" method="post" name="iform" id="iform"> <form action="vpn_ipsec_settings.php" method="post" name="iform" id="iform">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-sort"> <table class="table table-striped">
<thead>
<tr> <tr>
<th colspan="2" class="listtopic"><?=gettext("IPSec Advanced Settings"); ?></th> <td ><strong><?=gettext("IPSec Advanced Settings"); ?></strong></td>
<td align="right">
<small><?=gettext("full help"); ?> </small>
<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_opnvpn_server" type="button"></i></a>
</td>
</tr> </tr>
</thead>
<tbody>
<tr> <tr>
<td width="22%" valign="top" class="vncell"><?=gettext("LAN security associsations"); ?></td> <td><a id="help_for_noinstalllanspd" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("LAN security associsations"); ?></td>
<td width="78%" class="vtable"> <td>
<input name="noinstalllanspd" type="checkbox" id="noinstalllanspd" value="yes" <?php if ($pconfig['noinstalllanspd']) { <input name="noinstalllanspd" type="checkbox" id="noinstalllanspd" value="yes" <?=!empty($pconfig['noinstalllanspd']) ? "checked=\"checked\"" : "";?> />
echo "checked=\"checked\"";
} ?> />
<strong><?=gettext("Do not install LAN SPD"); ?></strong> <strong><?=gettext("Do not install LAN SPD"); ?></strong>
<br /> <div class="hidden" for="help_for_noinstalllanspd">
<?=gettext("By default, if IPSec is enabled negating SPD are inserted to provide protection. " . <?=gettext("By default, if IPSec is enabled negating SPD are inserted to provide protection. " .
"This behaviour can be changed by enabling this setting which will prevent installing these SPDs."); ?> "This behaviour can be changed by enabling this setting which will prevent installing these SPDs."); ?>
</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Security Associations"); ?></td> <td><a id="help_for_preferoldsa_enable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Security Associations"); ?></td>
<td width="78%" class="vtable"> <td width="78%" class="vtable">
<input name="preferoldsa_enable" type="checkbox" id="preferoldsa_enable" value="yes" <?php if ($pconfig['preferoldsa_enable']) { <input name="preferoldsa_enable" type="checkbox" id="preferoldsa_enable" value="yes" <?= !empty($pconfig['preferoldsa_enable']) ? "checked=\"checked\"" : "";?> />
echo "checked=\"checked\"";
} ?> />
<strong><?=gettext("Prefer older IPsec SAs"); ?></strong> <strong><?=gettext("Prefer older IPsec SAs"); ?></strong>
<br /> <div class="hidden" for="help_for_preferoldsa_enable">
<?=gettext("By default, if several SAs match, the newest one is " . <?=gettext("By default, if several SAs match, the newest one is " .
"preferred if it's at least 30 seconds old. Select this " . "preferred if it's at least 30 seconds old. Select this " .
"option to always prefer old SAs over new ones."); ?> "option to always prefer old SAs over new ones."); ?>
</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Debug"); ?></td> <td><a id="help_for_ipsec_debug" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IPsec Debug"); ?></td>
<td width="78%" class="vtable"> <td>
<strong><?=gettext("Start IPSec in debug mode based on sections selected"); ?></strong> <div class="hidden" for="help_for_ipsec_debug">
<br /> <strong><?=gettext("Start IPSec in debug mode based on sections selected"); ?></strong> <br/>
<table summary="ipsec debug"> </div>
<?php foreach ($ipsec_loglevels as $lkey => $ldescr) : <?php foreach ($ipsec_loglevels as $lkey => $ldescr) :
?> ?>
<tr> <?=$ldescr?>
<td width="22%" valign="top" class="vncell"><?=$ldescr;?></td> <select name="ipsec_<?=$lkey?>" id="ipsec_<?=$lkey?>">
<td width="78%" valign="top" class="vncell"> <?php foreach (array("Silent", "Audit", "Control", "Diag", "Raw", "Highest") as $lidx => $lvalue):
<?php echo "<select name=\"ipsec_{$lkey}\" id=\"ipsec_{$lkey}\">\n"; ?>
foreach (array("Silent", "Audit", "Control", "Diag", "Raw", "Highest") as $lidx => $lvalue) { <option value="<?=$lidx?>" <?= isset($pconfig["ipsec_{$lkey}"]) && $pconfig["ipsec_{$lkey}"] == $lidx ? "selected=\"selected\"" : "";?> ?>
echo "<option value=\"{$lidx}\" "; <?=$lvalue?>
if ($pconfig["ipsec_{$lkey}"] == $lidx) { </option>
echo "selected=\"selected\""; <?php
} endforeach; ?>
echo ">{$lvalue}</option>\n";
}
?>
</select> </select>
</td> <?php
</tr> endforeach; ?>
<?php <div class="hidden" for="help_for_ipsec_debug">
endforeach; ?> <?=gettext("Launches IPSec in debug mode so that more verbose logs " .
<tr style="display:none;"><td></td></tr>
</table>
<br /><?=gettext("Launches IPSec in debug mode so that more verbose logs " .
"will be generated to aid in troubleshooting."); ?> "will be generated to aid in troubleshooting."); ?>
</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Reload on Failover"); ?></td> <td><a id="help_for_failoverforcereloadg" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IPsec Reload on Failover"); ?></td>
<td width="78%" class="vtable"> <td>
<input name="failoverforcereload" type="checkbox" id="failoverforcereload" value="yes" <?php if ($pconfig['failoverforcereload']) { <input name="failoverforcereload" type="checkbox" id="failoverforcereload" value="yes" <?= !empty($pconfig['failoverforcereload']) ? "checked=\"checked\"" : "";?> />
echo "checked=\"checked\"";
} ?> />
<strong><?=gettext("Force IPsec Reload on Failover"); ?></strong> <strong><?=gettext("Force IPsec Reload on Failover"); ?></strong>
<br /> <div class="hidden" for="help_for_failoverforcereloadg">
<?=gettext("In some circumstances using a gateway group as the interface for " . <?=gettext("In some circumstances using a gateway group as the interface for " .
"an IPsec tunnel does not function properly, and IPsec must be forcefully reloaded " . "an IPsec tunnel does not function properly, and IPsec must be forcefully reloaded " .
"when a failover occurs. Because this will disrupt all IPsec tunnels, this behavior" . "when a failover occurs. Because this will disrupt all IPsec tunnels, this behavior" .
" is disabled by default. Check this box to force IPsec to fully reload on failover."); ?> " is disabled by default. Check this box to force IPsec to fully reload on failover."); ?>
</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Maximum MSS"); ?></td> <td><a id="help_for_maxmss_enable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Maximum MSS"); ?></td>
<td width="78%" class="vtable"> <td>
<input name="maxmss_enable" type="checkbox" id="maxmss_enable" value="yes" <?php if ($pconfig['maxmss_enable'] == true) { <input name="maxmss_enable" type="checkbox" id="maxmss_enable" value="yes" <?= !empty($pconfig['maxmss_enable']) ? "checked=\"checked\"" : "" ;?> onclick="maxmss_checked()" />
echo "checked=\"checked\"";
} ?> onclick="maxmss_checked(this)" />
<strong><?=gettext("Enable MSS clamping on VPN traffic"); ?></strong> <strong><?=gettext("Enable MSS clamping on VPN traffic"); ?></strong>
<br /> <input name="maxmss" id="maxmss" type="text" value="<?= !empty($pconfig['maxmss']) ? $pconfig['maxmss'] : "1400";?>" <?= !empty($pconfig['maxmss_enable']) ? "disabled=\"disabled\"" : "" ;?> />
<input name="maxmss" id="maxmss" value="<?php if ($pconfig['maxmss'] <> "") { <div class="hidden" for="help_for_maxmss_enable">
echo $pconfig['maxmss'];
} else {
"1400";
} ?>" class="formfld unknown" <?php if ($pconfig['maxmss_enable'] == false) {
echo "disabled=\"disabled\"";
} ?> />
<br />
<?=gettext("Enable MSS clamping on TCP flows over VPN. " . <?=gettext("Enable MSS clamping on TCP flows over VPN. " .
"This helps overcome problems with PMTUD on IPsec VPN links. If left blank, the default value is 1400 bytes. "); ?> "This helps overcome problems with PMTUD on IPsec VPN links. If left blank, the default value is 1400 bytes. "); ?>
</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top">&nbsp;</td> <td>&nbsp;</td>
<td width="78%"> <td>
<input name="submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" /> <input name="submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>
</form> </form>
</div> </div>
</section> </section>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment