Project

General

Profile

Download (12.8 KB) Statistics
| Branch: | Tag: | Revision:
1 71172088 jim-p
<?php
2
/*
3
	vpn_ipsec_settings.php
4
5
	Copyright (C) 2014 Electric Sheep Fencing, LLC
6
	All rights reserved.
7
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29
30
##|+PRIV
31
##|*IDENT=page-vpn-ipsec-settings
32
##|*NAME=VPN: IPsec: Settings page
33
##|*DESCR=Allow access to the 'VPN: IPsec: Settings' page.
34
##|*MATCH=vpn_ipsec_settings.php*
35
##|-PRIV
36
37
require("functions.inc");
38
require("guiconfig.inc");
39
require_once("filter.inc");
40
require_once("shaper.inc");
41
require_once("ipsec.inc");
42
require_once("vpn.inc");
43
44
$pconfig['preferoldsa_enable'] = isset($config['ipsec']['preferoldsa']);
45
foreach ($ipsec_loglevels as $lkey => $ldescr) {
46
	if (!empty($config['ipsec']["ipsec_{$lkey}"]))
47
		$pconfig["ipsec_{$lkey}"] = $config['ipsec']["ipsec_{$lkey}"];
48
}
49
$pconfig['failoverforcereload'] = isset($config['ipsec']['failoverforcereload']);
50 737b18f2 Ermal
$pconfig['acceptunencryptedmainmode'] = isset($config['ipsec']['acceptunencryptedmainmode']);
51 71172088 jim-p
$pconfig['maxmss_enable'] = isset($config['system']['maxmss_enable']);
52
$pconfig['maxmss'] = $config['system']['maxmss'];
53
54 6ae8b844 Ermal
if ($_POST) {
55 71172088 jim-p
56
	unset($input_errors);
57
	$pconfig = $_POST;
58 a96dc32e Chris Buechler
	
59
	if (!in_array($pconfig['ipsec_dmn'], array('0', '1', '2', '3', '4', '5'), true)) {
60
		$input_errors[] = "A valid value must be specified for Daemon debug.";
61
	}
62
	if (!in_array($pconfig['ipsec_mgr'], array('0', '1', '2', '3', '4', '5'), true)) {
63
		$input_errors[] = "A valid value must be specified for SA Manager debug.";
64
	}
65
	if (!in_array($pconfig['ipsec_ike'], array('0', '1', '2', '3', '4', '5'), true)) {
66
		$input_errors[] = "A valid value must be specified for IKE SA debug.";
67
	}
68
	if (!in_array($pconfig['ipsec_chd'], array('0', '1', '2', '3', '4', '5'), true)) {
69
		$input_errors[] = "A valid value must be specified for IKE Child SA debug.";
70
	}
71
	if (!in_array($pconfig['ipsec_job'], array('0', '1', '2', '3', '4', '5'), true)) {
72
		$input_errors[] = "A valid value must be specified for Job Processing debug.";
73
	}
74
	if (!in_array($pconfig['ipsec_cfg'], array('0', '1', '2', '3', '4', '5'), true)) {
75
		$input_errors[] = "A valid value must be specified for Configuration backend debug.";
76
	}
77
	if (!in_array($pconfig['ipsec_knl'], array('0', '1', '2', '3', '4', '5'), true)) {
78
		$input_errors[] = "A valid value must be specified for Kernel Interface debug.";
79
	}
80
	if (!in_array($pconfig['ipsec_net'], array('0', '1', '2', '3', '4', '5'), true)) {
81
		$input_errors[] = "A valid value must be specified for Networking debug.";
82
	}
83
	if (!in_array($pconfig['ipsec_asn'], array('0', '1', '2', '3', '4', '5'), true)) {
84
		$input_errors[] = "A valid value must be specified for ASN Encoding debug.";
85
	}
86
	if (!in_array($pconfig['ipsec_enc'], array('0', '1', '2', '3', '4', '5'), true)) {
87
		$input_errors[] = "A valid value must be specified for Message encoding debug.";
88
	}
89
	if (!in_array($pconfig['ipsec_imc'], array('0', '1', '2', '3', '4', '5'), true)) {
90
		$input_errors[] = "A valid value must be specified for Integrity checker debug.";
91
	}
92
	if (!in_array($pconfig['ipsec_imv'], array('0', '1', '2', '3', '4', '5'), true)) {
93
		$input_errors[] = "A valid value must be specified for Integrity Verifier debug.";
94
	}
95
	if (!in_array($pconfig['ipsec_pts'], array('0', '1', '2', '3', '4', '5'), true)) {
96
		$input_errors[] = "A valid value must be specified for Platform Trust Service debug.";
97
	}
98
	if (!in_array($pconfig['ipsec_tls'], array('0', '1', '2', '3', '4', '5'), true)) {
99
		$input_errors[] = "A valid value must be specified for TLS Handler debug.";
100
	}
101
	if (!in_array($pconfig['ipsec_esp'], array('0', '1', '2', '3', '4', '5'), true)) {
102
		$input_errors[] = "A valid value must be specified for IPsec Traffic debug.";
103
	}
104
	if (!in_array($pconfig['ipsec_lib'], array('0', '1', '2', '3', '4', '5'), true)) {
105
		$input_errors[] = "A valid value must be specified for StrongSwan Lib debug.";
106
	}
107
	if (isset($pconfig['maxmss'])) {
108
		if (!is_numericint($pconfig['maxmss']) && $pconfig['maxmss'] <> '') {
109
			$input_errors[] = "An integer must be specified for Maximum MSS.";
110
		}
111
		if ($pconfig['maxmss'] <> '' && $pconfig['maxmss'] < 576 || $pconfig['maxmss'] > 65535)
112
			$input_errors[] = "An integer between 576 and 65535 must be specified for Maximum MSS";	
113
	}
114
	
115 71172088 jim-p
	if (!$input_errors) {
116
117
		if($_POST['preferoldsa_enable'] == "yes")
118
			$config['ipsec']['preferoldsa'] = true;
119
		elseif (isset($config['ipsec']['preferoldsa']))
120
			unset($config['ipsec']['preferoldsa']);
121
122
		if (is_array($config['ipsec'])) {
123
			foreach ($ipsec_loglevels as $lkey => $ldescr) {
124
				if (empty($_POST["ipsec_{$lkey}"])) {
125
					if (isset($config['ipsec']["ipsec_{$lkey}"]))
126
						unset($config['ipsec']["ipsec_{$lkey}"]);
127
				} else
128
					$config['ipsec']["ipsec_{$lkey}"] = $_POST["ipsec_{$lkey}"];
129
			}
130
		}
131
132
		if($_POST['failoverforcereload'] == "yes")
133
			$config['ipsec']['failoverforcereload'] = true;
134
		elseif (isset($config['ipsec']['failoverforcereload']))
135
			unset($config['ipsec']['failoverforcereload']);
136
137 737b18f2 Ermal
		if($_POST['acceptunencryptedmainmode'] == "yes")
138
			$config['ipsec']['acceptunencryptedmainmode'] = true;
139
		elseif (isset($config['ipsec']['acceptunencryptedmainmode']))
140
			unset($config['ipsec']['acceptunencryptedmainmode']);
141
142 71172088 jim-p
		if($_POST['maxmss_enable'] == "yes") {
143
			$config['system']['maxmss_enable'] = true;
144
			$config['system']['maxmss'] = $_POST['maxmss'];
145
		} else {
146
			unset($config['system']['maxmss_enable']);
147
			unset($config['system']['maxmss']);
148
		}
149
150
		write_config();
151
152
		$retval = 0;
153
		$retval = filter_configure();
154
		if(stristr($retval, "error") <> true)
155
			$savemsg = get_std_save_message(gettext($retval));
156
		else
157
			$savemsg = gettext($retval);
158
159
		vpn_ipsec_configure_preferoldsa();
160
		vpn_ipsec_configure();
161
		vpn_ipsec_configure_loglevels();
162
163
//		header("Location: vpn_ipsec_settings.php");
164
//		return;
165
	}
166
}
167
168
$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Settings"));
169
$shortcut_section = "ipsec";
170
171
include("head.inc");
172
?>
173
174
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
175
<?php include("fbegin.inc"); ?>
176
177
<script type="text/javascript">
178 391453a1 Colin Fleming
//<![CDATA[
179 71172088 jim-p
180
function maxmss_checked(obj) {
181
	if (obj.checked)
182
		jQuery('#maxmss').attr('disabled',false);
183
	else
184
		jQuery('#maxmss').attr('disabled','true');
185
}
186
187 391453a1 Colin Fleming
//]]>
188 71172088 jim-p
</script>
189
190
<form action="vpn_ipsec_settings.php" method="post" name="iform" id="iform">
191
192
<?php
193
	if ($savemsg)
194
		print_info_box($savemsg);
195
	if ($input_errors)
196
		print_input_errors($input_errors);
197
?>
198
199 391453a1 Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn ipsec settings">
200 71172088 jim-p
	<tr>
201
		<td class="tabnavtbl">
202
			<?php
203
				$tab_array = array();
204
				$tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php");
205
				$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
206
				$tab_array[2] = array(gettext("Pre-Shared Key"), false, "vpn_ipsec_keys.php");
207
				$tab_array[3] = array(gettext("Advanced Settings"), true, "vpn_ipsec_settings.php");
208
				display_top_tabs($tab_array);
209
			?>
210
		</td>
211
	</tr>
212
	<tr>
213
		<td id="mainarea">
214
			<div class="tabcont">
215 391453a1 Colin Fleming
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
216 71172088 jim-p
					<tr>
217 3c4fc30b Chris Buechler
						<td colspan="2" valign="top" class="listtopic"><?=gettext("IPsec Advanced Settings"); ?></td>
218 71172088 jim-p
					</tr>
219
					<tr>
220
						<td width="22%" valign="top" class="vncell"><?=gettext("Security Associations"); ?></td>
221
						<td width="78%" class="vtable">
222
							<input name="preferoldsa_enable" type="checkbox" id="preferoldsa_enable" value="yes" <?php if ($pconfig['preferoldsa_enable']) echo "checked=\"checked\""; ?> />
223
							<strong><?=gettext("Prefer older IPsec SAs"); ?></strong>
224
							<br />
225
							<?=gettext("By default, if several SAs match, the newest one is " .
226
							"preferred if it's at least 30 seconds old. Select this " .
227
							"option to always prefer old SAs over new ones."); ?>
228
						</td>
229
					</tr>
230
					<tr>
231
						<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Debug"); ?></td>
232
						<td width="78%" class="vtable">
233 3c4fc30b Chris Buechler
							<strong><?=gettext("Start IPsec in debug mode based on sections selected"); ?></strong>
234 71172088 jim-p
							<br />
235 391453a1 Colin Fleming
							<table summary="ipsec debug">
236 71172088 jim-p
						<?php foreach ($ipsec_loglevels as $lkey => $ldescr): ?>
237
							<tr>
238
								<td width="22%" valign="top" class="vncell"><?=$ldescr;?></td>
239
								<td width="78%" valign="top" class="vncell">
240
								<?php	echo "<select name=\"ipsec_{$lkey}\" id=\"ipsec_{$lkey}\">\n";
241
									foreach (array("Silent", "Audit", "Control", "Diag", "Raw", "Highest") as $lidx => $lvalue) {
242
										echo "<option value=\"{$lidx}\" ";
243
										 if ($pconfig["ipsec_{$lkey}"] == $lidx)
244
											echo "selected=\"selected\"";
245
										echo ">{$lvalue}</option>\n";
246
									}
247
								?>
248
									</select>
249
								</td>
250
							</tr>
251
						<?php endforeach; ?>
252 391453a1 Colin Fleming
							<tr style="display:none;"><td></td></tr>
253 71172088 jim-p
							</table>
254 3c4fc30b Chris Buechler
							<br /><?=gettext("Launches IPsec in debug mode so that more verbose logs " .
255 71172088 jim-p
							"will be generated to aid in troubleshooting."); ?>
256
						</td>
257
					</tr>
258
					<tr>
259
						<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Reload on Failover"); ?></td>
260
						<td width="78%" class="vtable">
261
							<input name="failoverforcereload" type="checkbox" id="failoverforcereload" value="yes" <?php if ($pconfig['failoverforcereload']) echo "checked=\"checked\""; ?> />
262
							<strong><?=gettext("Force IPsec Reload on Failover"); ?></strong>
263
							<br />
264
							<?=gettext("In some circumstances using a gateway group as the interface for " .
265
							"an IPsec tunnel does not function properly, and IPsec must be forcefully reloaded " .
266
							"when a failover occurs. Because this will disrupt all IPsec tunnels, this behavior" .
267
							" is disabled by default. Check this box to force IPsec to fully reload on failover."); ?>
268
						</td>
269
					</tr>
270 737b18f2 Ermal
					<tr>
271
						<td width="22%" valign="top" class="vncell"><?=gettext("Unencrypted payloads in IKEv1 Main Mode"); ?></td>
272
						<td width="78%" class="vtable">
273
							<input name="acceptunencryptedmainmode" type="checkbox" id="acceptunencryptedmainmode" value="yes" <?php if ($pconfig['acceptunencryptedmainmode']) echo "checked=\"checked\""; ?> />
274
							<strong><?=gettext("Accept unencrypted ID and HASH payloads in IKEv1 Main Mode"); ?></strong>
275
							<br />
276
							<?=gettext("Some implementations send the third Main Mode message unencrypted, probably to find the PSKs for the specified ID for authentication." .
277
							"This is very similar to Aggressive Mode, and has the same security implications: " .
278
							"A passive attacker can sniff the negotiated Identity, and start brute forcing the PSK using the HASH payload." .
279
							" It is recommended to keep this option to no, unless you know exactly what the implications are and require compatibility to such devices (for example, some SonicWall boxes).");?>
280
						</td>
281
					</tr>
282 71172088 jim-p
					<tr>
283
						<td width="22%" valign="top" class="vncell"><?=gettext("Maximum MSS"); ?></td>
284
						<td width="78%" class="vtable">
285
							<input name="maxmss_enable" type="checkbox" id="maxmss_enable" value="yes" <?php if ($pconfig['maxmss_enable'] == true) echo "checked=\"checked\""; ?> onclick="maxmss_checked(this)" />
286
							<strong><?=gettext("Enable MSS clamping on VPN traffic"); ?></strong>
287
							<br />
288
							<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\""; ?> />
289
							<br />
290
							<?=gettext("Enable MSS clamping on TCP flows over VPN. " .
291
							"This helps overcome problems with PMTUD on IPsec VPN links. If left blank, the default value is 1400 bytes. "); ?>
292
						</td>
293
					</tr>
294
					<tr>
295
						<td width="22%" valign="top">&nbsp;</td>
296
						<td width="78%">
297 391453a1 Colin Fleming
							<input name="submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
298 71172088 jim-p
						</td>
299
					</tr>
300
				</table>
301
			</div>
302
		</td>
303
	</tr>
304
</table>
305
</form>
306
<?php include("fend.inc"); ?>
307
</body>
308
</html>