vpn_ipsec_settings.php 10.9 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1 2
<?php
/*
3
	Copyright (C) 2014-2015 Deciso B.V.
Ad Schellevis's avatar
Ad Schellevis committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
	Copyright (C) 2014 Electric Sheep Fencing, LLC
	All rights reserved.

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions are met:

	1. Redistributions of source code must retain the above copyright notice,
	   this list of conditions and the following disclaimer.

	2. Redistributions in binary form must reproduce the above copyright
	   notice, this list of conditions and the following disclaimer in the
	   documentation and/or other materials provided with the distribution.

	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
*/

29 30
require_once("functions.inc");
require_once("guiconfig.inc");
Ad Schellevis's avatar
Ad Schellevis committed
31 32 33 34 35
require_once("filter.inc");
require_once("shaper.inc");
require_once("ipsec.inc");
require_once("vpn.inc");

36 37 38
if (!is_array($config['ipsec'])) {
        $config['ipsec'] = array();
}
39

Ad Schellevis's avatar
Ad Schellevis committed
40 41 42
$pconfig['noinstalllanspd'] = $config['system']['noinstalllanspd'];
$pconfig['preferoldsa_enable'] = isset($config['ipsec']['preferoldsa']);
foreach ($ipsec_loglevels as $lkey => $ldescr) {
43 44 45
    if (!empty($config['ipsec']["ipsec_{$lkey}"])) {
        $pconfig["ipsec_{$lkey}"] = $config['ipsec']["ipsec_{$lkey}"];
    }
Ad Schellevis's avatar
Ad Schellevis committed
46 47 48 49 50 51
}
$pconfig['failoverforcereload'] = isset($config['ipsec']['failoverforcereload']);
$pconfig['maxmss_enable'] = isset($config['system']['maxmss_enable']);
$pconfig['maxmss'] = $config['system']['maxmss'];

if ($_POST) {
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
    unset($input_errors);
    $pconfig = $_POST;

    if (!$input_errors) {
        if ($_POST['noinstalllanspd'] == "yes") {
            $config['system']['noinstalllanspd'] = true;
        } else {
            if (isset($config['system']['noinstalllanspd'])) {
                unset($config['system']['noinstalllanspd']);
            }
        }

        if ($_POST['preferoldsa_enable'] == "yes") {
            $config['ipsec']['preferoldsa'] = true;
        } elseif (isset($config['ipsec']['preferoldsa']))
            unset($config['ipsec']['preferoldsa']);

        if (is_array($config['ipsec'])) {
            foreach ($ipsec_loglevels as $lkey => $ldescr) {
                if (empty($_POST["ipsec_{$lkey}"])) {
                    if (isset($config['ipsec']["ipsec_{$lkey}"])) {
                        unset($config['ipsec']["ipsec_{$lkey}"]);
                    }
                } else {
                    $config['ipsec']["ipsec_{$lkey}"] = $_POST["ipsec_{$lkey}"];
                }
            }
        }

        if ($_POST['failoverforcereload'] == "yes") {
            $config['ipsec']['failoverforcereload'] = true;
        } elseif (isset($config['ipsec']['failoverforcereload']))
            unset($config['ipsec']['failoverforcereload']);

        if ($_POST['maxmss_enable'] == "yes") {
            $config['system']['maxmss_enable'] = true;
            $config['system']['maxmss'] = $_POST['maxmss'];
        } else {
            unset($config['system']['maxmss_enable']);
            unset($config['system']['maxmss']);
        }

        write_config();

        $retval = 0;
        $retval = filter_configure();
        if (stristr($retval, "error") <> true) {
            $savemsg = get_std_save_message(gettext($retval));
        } else {
            $savemsg = gettext($retval);
        }

        vpn_ipsec_configure_preferoldsa();
        vpn_ipsec_configure();
        vpn_ipsec_configure_loglevels();
Ad Schellevis's avatar
Ad Schellevis committed
107 108 109

//		header("Location: vpn_ipsec_settings.php");
//		return;
110
    }
Ad Schellevis's avatar
Ad Schellevis committed
111 112 113 114 115 116 117 118
}

$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Settings"));
$shortcut_section = "ipsec";

include("head.inc");
?>

119
<body>
Ad Schellevis's avatar
Ad Schellevis committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
<?php include("fbegin.inc"); ?>

<script type="text/javascript">
//<![CDATA[

function maxmss_checked(obj) {
	if (obj.checked)
		jQuery('#maxmss').attr('disabled',false);
	else
		jQuery('#maxmss').attr('disabled','true');
}

//]]>
</script>

135
	<section class="page-content-main">
136
		<div class="container-fluid">
137
			<div class="row">
138 139


140
				<?php
141 142 143 144 145 146 147
                if ($savemsg) {
                    print_info_box($savemsg);
                }
                if ($input_errors) {
                    print_input_errors($input_errors);
                }
                ?>
148

149

150
			    <section class="col-xs-12">
151

152 153
				<? $active_tab = "/vpn_ipsec_settings.php";
                include('vpn_ipsec_tabs.inc'); ?>
154 155 156

					<div class="tab-content content-box col-xs-12">

157 158 159
							<form action="vpn_ipsec_settings.php" method="post" name="iform" id="iform">

								<div class="table-responsive">
160 161
									<table class="table table-striped table-sort">

Ad Schellevis's avatar
Ad Schellevis committed
162 163
										<thead>
		                                    <tr>
164
							<th colspan="2" class="listtopic"><?=gettext("IPSec Advanced Settings"); ?></th>
Ad Schellevis's avatar
Ad Schellevis committed
165 166
		                                    </tr>
		                                </thead>
167 168 169

									<tbody>

170 171 172
										<tr>
											<td width="22%" valign="top" class="vncell"><?=gettext("LAN security associsations"); ?></td>
											<td width="78%" class="vtable">
173 174 175
												<input name="noinstalllanspd" type="checkbox" id="noinstalllanspd" value="yes" <?php if ($pconfig['noinstalllanspd']) {
                                                    echo "checked=\"checked\"";
} ?> />
176 177 178
												<strong><?=gettext("Do not install LAN SPD"); ?></strong>
												<br />
												<?=gettext("By default, if IPSec is enabled negating SPD are inserted to provide protection. " .
179
                                                "This behaviour can be changed by enabling this setting which will prevent installing these SPDs."); ?>
180 181 182 183 184
											</td>
										</tr>
										<tr>
											<td width="22%" valign="top" class="vncell"><?=gettext("Security Associations"); ?></td>
											<td width="78%" class="vtable">
185 186 187
												<input name="preferoldsa_enable" type="checkbox" id="preferoldsa_enable" value="yes" <?php if ($pconfig['preferoldsa_enable']) {
                                                    echo "checked=\"checked\"";
} ?> />
188 189 190
												<strong><?=gettext("Prefer older IPsec SAs"); ?></strong>
												<br />
												<?=gettext("By default, if several SAs match, the newest one is " .
191 192
                                                "preferred if it's at least 30 seconds old. Select this " .
                                                "option to always prefer old SAs over new ones."); ?>
193 194 195 196 197 198 199 200
											</td>
										</tr>
										<tr>
											<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Debug"); ?></td>
											<td width="78%" class="vtable">
												<strong><?=gettext("Start IPSec in debug mode based on sections selected"); ?></strong>
												<br />
												<table summary="ipsec debug">
201 202
											<?php foreach ($ipsec_loglevels as $lkey => $ldescr) :
?>
203 204 205 206
												<tr>
													<td width="22%" valign="top" class="vncell"><?=$ldescr;?></td>
													<td width="78%" valign="top" class="vncell">
													<?php	echo "<select name=\"ipsec_{$lkey}\" id=\"ipsec_{$lkey}\">\n";
207 208 209 210 211 212 213 214
                                                    foreach (array("Silent", "Audit", "Control", "Diag", "Raw", "Highest") as $lidx => $lvalue) {
                                                        echo "<option value=\"{$lidx}\" ";
                                                        if ($pconfig["ipsec_{$lkey}"] == $lidx) {
                                                            echo "selected=\"selected\"";
                                                        }
                                                        echo ">{$lvalue}</option>\n";
                                                    }
                                                    ?>
215 216 217
														</select>
													</td>
												</tr>
218 219
											<?php
endforeach; ?>
220 221 222
												<tr style="display:none;"><td></td></tr>
												</table>
												<br /><?=gettext("Launches IPSec in debug mode so that more verbose logs " .
223
                                                "will be generated to aid in troubleshooting."); ?>
224 225 226 227 228
											</td>
										</tr>
										<tr>
											<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Reload on Failover"); ?></td>
											<td width="78%" class="vtable">
229 230 231
												<input name="failoverforcereload" type="checkbox" id="failoverforcereload" value="yes" <?php if ($pconfig['failoverforcereload']) {
                                                    echo "checked=\"checked\"";
} ?> />
232 233 234
												<strong><?=gettext("Force IPsec Reload on Failover"); ?></strong>
												<br />
												<?=gettext("In some circumstances using a gateway group as the interface for " .
235 236 237
                                                "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" .
                                                " is disabled by default. Check this box to force IPsec to fully reload on failover."); ?>
238 239 240 241 242
											</td>
										</tr>
										<tr>
											<td width="22%" valign="top" class="vncell"><?=gettext("Maximum MSS"); ?></td>
											<td width="78%" class="vtable">
243 244 245
												<input name="maxmss_enable" type="checkbox" id="maxmss_enable" value="yes" <?php if ($pconfig['maxmss_enable'] == true) {
                                                    echo "checked=\"checked\"";
} ?> onclick="maxmss_checked(this)" />
246 247
												<strong><?=gettext("Enable MSS clamping on VPN traffic"); ?></strong>
												<br />
248 249 250 251 252 253 254 255
												<input name="maxmss" id="maxmss" value="<?php if ($pconfig['maxmss'] <> "") {
                                                    echo $pconfig['maxmss'];

} else {
    "1400";
} ?>" class="formfld unknown" <?php if ($pconfig['maxmss_enable'] == false) {
    echo "disabled=\"disabled\"";
} ?> />
256 257
												<br />
												<?=gettext("Enable MSS clamping on TCP flows over VPN. " .
258
                                                "This helps overcome problems with PMTUD on IPsec VPN links. If left blank, the default value is 1400 bytes. "); ?>
259 260 261 262 263 264 265 266 267 268 269
											</td>
										</tr>
										<tr>
											<td width="22%" valign="top">&nbsp;</td>
											<td width="78%">
												<input name="submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
											</td>
										</tr>
									</table>
								</div>
							</form>
270

271 272
					</div>
				</section>
Ad Schellevis's avatar
Ad Schellevis committed
273
			</div>
274 275
		</div>
	</section>
276
<?php include("foot.inc");