Project

General

Profile

Download (17.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	vpn_ipsec_settings.php
4

    
5
	Copyright (C) 2015 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
foreach ($ipsec_loglevels as $lkey => $ldescr) {
45
	if (!empty($config['ipsec']["ipsec_{$lkey}"])) {
46
		$pconfig["ipsec_{$lkey}"] = $config['ipsec']["ipsec_{$lkey}"];
47
	}
48
}
49
$pconfig['unityplugin'] = isset($config['ipsec']['unityplugin']);
50
$pconfig['makebeforebreak'] = isset($config['ipsec']['makebeforebreak']);
51
$pconfig['noshuntlaninterfaces'] = isset($config['ipsec']['noshuntlaninterfaces']);
52
$pconfig['compression'] = isset($config['ipsec']['compression']);
53
$pconfig['enableinterfacesuse'] = isset($config['ipsec']['enableinterfacesuse']);
54
$pconfig['acceptunencryptedmainmode'] = isset($config['ipsec']['acceptunencryptedmainmode']);
55
$pconfig['maxmss_enable'] = isset($config['system']['maxmss_enable']);
56
$pconfig['maxmss'] = $config['system']['maxmss'];
57
$pconfig['uniqueids'] = $config['ipsec']['uniqueids'];
58

    
59
if ($_POST) {
60

    
61
	unset($input_errors);
62
	$pconfig = $_POST;
63

    
64
	if (!in_array($pconfig['ipsec_dmn'], array('0', '1', '2', '3', '4', '5'), true)) {
65
		$input_errors[] = "A valid value must be specified for Daemon debug.";
66
	}
67
	if (!in_array($pconfig['ipsec_mgr'], array('0', '1', '2', '3', '4', '5'), true)) {
68
		$input_errors[] = "A valid value must be specified for SA Manager debug.";
69
	}
70
	if (!in_array($pconfig['ipsec_ike'], array('0', '1', '2', '3', '4', '5'), true)) {
71
		$input_errors[] = "A valid value must be specified for IKE SA debug.";
72
	}
73
	if (!in_array($pconfig['ipsec_chd'], array('0', '1', '2', '3', '4', '5'), true)) {
74
		$input_errors[] = "A valid value must be specified for IKE Child SA debug.";
75
	}
76
	if (!in_array($pconfig['ipsec_job'], array('0', '1', '2', '3', '4', '5'), true)) {
77
		$input_errors[] = "A valid value must be specified for Job Processing debug.";
78
	}
79
	if (!in_array($pconfig['ipsec_cfg'], array('0', '1', '2', '3', '4', '5'), true)) {
80
		$input_errors[] = "A valid value must be specified for Configuration backend debug.";
81
	}
82
	if (!in_array($pconfig['ipsec_knl'], array('0', '1', '2', '3', '4', '5'), true)) {
83
		$input_errors[] = "A valid value must be specified for Kernel Interface debug.";
84
	}
85
	if (!in_array($pconfig['ipsec_net'], array('0', '1', '2', '3', '4', '5'), true)) {
86
		$input_errors[] = "A valid value must be specified for Networking debug.";
87
	}
88
	if (!in_array($pconfig['ipsec_asn'], array('0', '1', '2', '3', '4', '5'), true)) {
89
		$input_errors[] = "A valid value must be specified for ASN Encoding debug.";
90
	}
91
	if (!in_array($pconfig['ipsec_enc'], array('0', '1', '2', '3', '4', '5'), true)) {
92
		$input_errors[] = "A valid value must be specified for Message encoding debug.";
93
	}
94
	if (!in_array($pconfig['ipsec_imc'], array('0', '1', '2', '3', '4', '5'), true)) {
95
		$input_errors[] = "A valid value must be specified for Integrity checker debug.";
96
	}
97
	if (!in_array($pconfig['ipsec_imv'], array('0', '1', '2', '3', '4', '5'), true)) {
98
		$input_errors[] = "A valid value must be specified for Integrity Verifier debug.";
99
	}
100
	if (!in_array($pconfig['ipsec_pts'], array('0', '1', '2', '3', '4', '5'), true)) {
101
		$input_errors[] = "A valid value must be specified for Platform Trust Service debug.";
102
	}
103
	if (!in_array($pconfig['ipsec_tls'], array('0', '1', '2', '3', '4', '5'), true)) {
104
		$input_errors[] = "A valid value must be specified for TLS Handler debug.";
105
	}
106
	if (!in_array($pconfig['ipsec_esp'], array('0', '1', '2', '3', '4', '5'), true)) {
107
		$input_errors[] = "A valid value must be specified for IPsec Traffic debug.";
108
	}
109
	if (!in_array($pconfig['ipsec_lib'], array('0', '1', '2', '3', '4', '5'), true)) {
110
		$input_errors[] = "A valid value must be specified for StrongSwan Lib debug.";
111
	}
112
	if (isset($pconfig['maxmss'])) {
113
		if (!is_numericint($pconfig['maxmss']) && $pconfig['maxmss'] <> '') {
114
			$input_errors[] = "An integer must be specified for Maximum MSS.";
115
		}
116
		if ($pconfig['maxmss'] <> '' && $pconfig['maxmss'] < 576 || $pconfig['maxmss'] > 65535) {
117
			$input_errors[] = "An integer between 576 and 65535 must be specified for Maximum MSS";
118
		}
119
	}
120

    
121
	if (!$input_errors) {
122

    
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
				}
128
			} else {
129
				$config['ipsec']["ipsec_{$lkey}"] = $_POST["ipsec_{$lkey}"];
130
			}
131
		}
132

    
133
		$needsrestart = false;
134

    
135
		if ($_POST['compression'] == "yes") {
136
			if (!isset($config['ipsec']['compression'])) {
137
				$needsrestart = true;
138
			}
139
			$config['ipsec']['compression'] = true;
140
		} elseif (isset($config['ipsec']['compression'])) {
141
			$needsrestart = true;
142
			unset($config['ipsec']['compression']);
143
		}
144

    
145
		if ($_POST['enableinterfacesuse'] == "yes") {
146
			if (!isset($config['ipsec']['enableinterfacesuse'])) {
147
				$needsrestart = true;
148
			}
149
			$config['ipsec']['enableinterfacesuse'] = true;
150
		} elseif (isset($config['ipsec']['enableinterfacesuse'])) {
151
			$needsrestart = true;
152
			unset($config['ipsec']['enableinterfacesuse']);
153
		}
154

    
155
		if ($_POST['unityplugin'] == "yes") {
156
			if (!isset($config['ipsec']['unityplugin'])) {
157
				$needsrestart = true;
158
			}
159
			$config['ipsec']['unityplugin'] = true;
160
		} elseif (isset($config['ipsec']['unityplugin'])) {
161
			$needsrestart = true;
162
			unset($config['ipsec']['unityplugin']);
163
		}
164

    
165
		if ($_POST['makebeforebreak'] == "yes") {
166
			$config['ipsec']['makebeforebreak'] = true;
167
		} elseif (isset($config['ipsec']['makebeforebreak'])) {
168
			unset($config['ipsec']['makebeforebreak']);
169
		}
170

    
171
		if ($_POST['noshuntlaninterfaces'] == "yes") {
172
			if (isset($config['ipsec']['noshuntlaninterfaces'])) {
173
				unset($config['ipsec']['noshuntlaninterfaces']);
174
			}
175
		} else {
176
			$config['ipsec']['noshuntlaninterfaces'] = true;
177
		}
178

    
179
		if ($_POST['acceptunencryptedmainmode'] == "yes") {
180
			if (!isset($config['ipsec']['acceptunencryptedmainmode'])) {
181
				$needsrestart = true;
182
			}
183
			$config['ipsec']['acceptunencryptedmainmode'] = true;
184
		} elseif (isset($config['ipsec']['acceptunencryptedmainmode'])) {
185
			$needsrestart = true;
186
			unset($config['ipsec']['acceptunencryptedmainmode']);
187
		}
188

    
189
		if (!empty($_POST['uniqueids'])) {
190
			$config['ipsec']['uniqueids'] = $_POST['uniqueids'];
191
		} else if (isset($config['ipsec']['uniqueids'])) {
192
			unset($config['ipsec']['uniqueids']);
193
		}
194

    
195
		if ($_POST['maxmss_enable'] == "yes") {
196
			$config['system']['maxmss_enable'] = true;
197
			$config['system']['maxmss'] = $_POST['maxmss'];
198
		} else {
199
			if (isset($config['system']['maxmss_enable'])) {
200
				unset($config['system']['maxmss_enable']);
201
			}
202
			if (isset($config['system']['maxmss'])) {
203
				unset($config['system']['maxmss']);
204
			}
205
		}
206

    
207
		write_config();
208

    
209
		$retval = 0;
210
		$retval = filter_configure();
211
		if (stristr($retval, "error") <> true) {
212
			$savemsg = get_std_save_message(gettext($retval));
213
		} else {
214
			$savemsg = gettext($retval);
215
		}
216

    
217
		vpn_ipsec_configure($needsrestart);
218
		vpn_ipsec_configure_loglevels();
219

    
220
		header("Location: vpn_ipsec_settings.php");
221
		return;
222
	}
223

    
224
	// The logic value sent by $POST is opposite to the way it is stored in the config.
225
	// Reset the $pconfig value so it reflects the opposite of what was $POSTed.
226
	if ($_POST['noshuntlaninterfaces'] == "yes") {
227
		$pconfig['noshuntlaninterfaces'] = false;
228
	} else {
229
		$pconfig['noshuntlaninterfaces'] = true;
230
	}
231
}
232

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

    
236
include("head.inc");
237
?>
238

    
239
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
240
<?php include("fbegin.inc"); ?>
241

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

    
245
function maxmss_checked(obj) {
246
	if (obj.checked) {
247
		jQuery('#maxmss').attr('disabled', false);
248
	} else {
249
		jQuery('#maxmss').attr('disabled', 'true');
250
	}
251
}
252

    
253
//]]>
254
</script>
255

    
256
<form action="vpn_ipsec_settings.php" method="post" name="iform" id="iform">
257

    
258
<?php
259
	if ($savemsg) {
260
		print_info_box($savemsg);
261
	}
262
	if ($input_errors) {
263
		print_input_errors($input_errors);
264
	}
265
?>
266

    
267
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn ipsec settings">
268
	<tr>
269
		<td class="tabnavtbl">
270
			<?php
271
				$tab_array = array();
272
				$tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php");
273
				$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
274
				$tab_array[2] = array(gettext("Pre-Shared Key"), false, "vpn_ipsec_keys.php");
275
				$tab_array[3] = array(gettext("Advanced Settings"), true, "vpn_ipsec_settings.php");
276
				display_top_tabs($tab_array);
277
			?>
278
		</td>
279
	</tr>
280
	<tr>
281
		<td id="mainarea">
282
			<div class="tabcont">
283
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
284
					<tr>
285
						<td colspan="2" valign="top" class="listtopic"><?=gettext("IPsec Advanced Settings"); ?></td>
286
					</tr>
287
					<tr>
288
						<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Debug"); ?></td>
289
						<td width="78%" class="vtable">
290
							<strong><?=gettext("Start IPsec in debug mode based on sections selected"); ?></strong>
291
							<br />
292
							<table summary="ipsec debug">
293
							<?php foreach ($ipsec_loglevels as $lkey => $ldescr): ?>
294
								<tr>
295
									<td width="22%" valign="top" class="vncell"><?=$ldescr;?></td>
296
									<td width="78%" valign="top" class="vncell">
297
										<?php
298
										echo "<select name=\"ipsec_{$lkey}\" id=\"ipsec_{$lkey}\">\n";
299
										foreach (array("Silent", "Audit", "Control", "Diag", "Raw", "Highest") as $lidx => $lvalue) {
300
											echo "<option value=\"{$lidx}\" ";
301
											if ($pconfig["ipsec_{$lkey}"] == $lidx) {
302
												echo "selected=\"selected\"";
303
											}
304
											echo ">{$lvalue}</option>\n";
305
										}
306
										?>
307
										</select>
308
									</td>
309
								</tr>
310
							<?php endforeach; ?>
311
								<tr style="display:none;">
312
									<td></td>
313
								</tr>
314
							</table>
315
							<br /><?=gettext("Launches IPsec in debug mode so that more verbose logs " .
316
							"will be generated to aid in troubleshooting."); ?>
317
						</td>
318
					</tr>
319
					<tr>
320
						<td width="22%" valign="top" class="vncell"><?=gettext("Unique IDs"); ?></td>
321
						<td width="78%" class="vtable">
322
							<strong><?=gettext("Configure Unique IDs as: "); ?></strong>
323
							<?php
324
								echo "<select name=\"uniqueids\" id=\"uniqueids\">\n";
325
								foreach ($ipsec_idhandling as $value => $lvalue) {
326
									echo "<option value=\"{$value}\" ";
327
									if ($pconfig['uniqueids'] == $value) {
328
										echo "selected=\"selected\"";
329
									}
330
									echo ">{$lvalue}</option>\n";
331
								}
332
							?>
333
							</select>
334
							<br />
335
							<?=gettext("whether a particular participant ID should be kept unique, with any new IKE_SA using an ID " .
336
								"deemed to replace all old ones using that ID. Participant IDs normally are unique, so a new " .
337
								"IKE_SA using the same ID is almost invariably intended to replace an old one. " .
338
								"The difference between <b>no</b> and <b>never</b> is that the old IKE_SAs will be replaced when receiving an " .
339
								"INITIAL_CONTACT notify if the option is no but will ignore these notifies if <b>never</b> is configured. " .
340
								"The daemon also accepts the value <b>keep</b> to reject " .
341
								"new IKE_SA setups and keep the duplicate established earlier. Defaults to Yes."); ?>
342
						</td>
343
					</tr>
344
					<tr>
345
						<td width="22%" valign="top" class="vncell"><?=gettext("IP Compression"); ?></td>
346
						<td width="78%" class="vtable">
347
							<input name="compression" type="checkbox" id="compression" value="yes" <?php if ($pconfig['compression']) echo "checked=\"checked\""; ?> />
348
							<strong><?=gettext("Enable IPCompression"); ?></strong>
349
							<br />
350
							<?=gettext("IPComp compression of content is proposed on the connection."); ?>
351
						</td>
352
					</tr>
353
					<tr>
354
						<td width="22%" valign="top" class="vncell"><?=gettext("Strict interface binding"); ?></td>
355
						<td width="78%" class="vtable">
356
							<input name="enableinterfacesuse" type="checkbox" id="enableinterfacesuse" value="yes" <?php if ($pconfig['enableinterfacesuse']) echo "checked=\"checked\""; ?> />
357
							<strong><?=gettext("Enable strict interface binding"); ?></strong>
358
							<br />
359
							<?=gettext("Enable strongSwan's interfaces_use option to bind specific interfaces only. This option is known to break IPsec with dynamic IP interfaces. This is not recommended at this time."); ?>
360
						</td>
361
					</tr>
362
					<tr>
363
						<td width="22%" valign="top" class="vncell"><?=gettext("Unencrypted payloads in IKEv1 Main Mode"); ?></td>
364
						<td width="78%" class="vtable">
365
							<input name="acceptunencryptedmainmode" type="checkbox" id="acceptunencryptedmainmode" value="yes" <?php if ($pconfig['acceptunencryptedmainmode']) echo "checked=\"checked\""; ?> />
366
							<strong><?=gettext("Accept unencrypted ID and HASH payloads in IKEv1 Main Mode"); ?></strong>
367
							<br />
368
							<?=gettext("Some implementations send the third Main Mode message unencrypted, probably to find the PSKs for the specified ID for authentication." .
369
							"This is very similar to Aggressive Mode, and has the same security implications: " .
370
							"A passive attacker can sniff the negotiated Identity, and start brute forcing the PSK using the HASH payload." .
371
							" 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).");?>
372
						</td>
373
					</tr>
374
					<tr>
375
						<td width="22%" valign="top" class="vncell"><?=gettext("Maximum MSS"); ?></td>
376
						<td width="78%" class="vtable">
377
							<input name="maxmss_enable" type="checkbox" id="maxmss_enable" value="yes" <?php if ($pconfig['maxmss_enable'] == true) echo "checked=\"checked\""; ?> onclick="maxmss_checked(this)" />
378
							<strong><?=gettext("Enable MSS clamping on VPN traffic"); ?></strong>
379
							<br />
380
							<input name="maxmss" id="maxmss" value="<?php if ($pconfig['maxmss'] <> "") echo htmlspecialchars($pconfig['maxmss']); else "1400"; ?>" class="formfld unknown" <?php if ($pconfig['maxmss_enable'] == false) echo "disabled=\"disabled\""; ?> />
381
							<br />
382
							<?=gettext("Enable MSS clamping on TCP flows over VPN. " .
383
							"This helps overcome problems with PMTUD on IPsec VPN links. If left blank, the default value is 1400 bytes. "); ?>
384
						</td>
385
					</tr>
386
					<tr>
387
						<td width="22%" valign="top" class="vncell"><?=gettext("Disable Cisco Extensions"); ?></td>
388
						<td width="78%" class="vtable">
389
							<input name="unityplugin" type="checkbox" id="unityplugin" value="yes" <?php if ($pconfig['unityplugin'] == true) echo "checked=\"checked\""; ?> />
390
							<strong><?=gettext("Disable Unity Plugin"); ?></strong>
391
							<br />
392
							<?=gettext("Disable Unity Plugin which provides Cisco Extension support as Split-Include, Split-Exclude, Split-Dns, ..."); ?>
393
						</td>
394
					</tr>
395
					<tr>
396
						<td width="22%" valign="top" class="vncell"><?=gettext("Make before Break"); ?></td>
397
						<td width="78%" class="vtable">
398
							<input name="makebeforebreak" type="checkbox" id="makebeforebreak" value="yes" <?php if ($pconfig['makebeforebreak'] == true) echo "checked=\"checked\""; ?> />
399
							<strong><?=gettext("Initiate IKEv2 reauthentication with a make-before-break"); ?></strong>
400
							<br />
401
							<?=gettext("instead of a break-before-make scheme. Make-before-break uses overlapping IKE and CHILD_SA during reauthentication " .
402
								"by first recreating all new SAs before deleting the old ones. This behavior can be beneficial to avoid connectivity gaps " .
403
								"during reauthentication, but requires support for overlapping SAs by the peer.");?>
404
						</td>
405
					</tr>
406
					<tr>
407
						<td width="22%" valign="top" class="vncell"><?=gettext("Auto-exclude LAN address"); ?></td>
408
						<td width="78%" class="vtable">
409
							<input name="noshuntlaninterfaces" type="checkbox" id="noshuntlaninterfaces" value="yes" <?php if ($pconfig['noshuntlaninterfaces'] != true) echo "checked=\"checked\""; ?> />
410
							<strong><?=gettext("Enable bypass for LAN interface IP"); ?></strong>
411
							<br />
412
							<?=gettext("Exclude traffic from LAN subnet to LAN IP address from IPsec."); ?>
413
						</td>
414
					</tr>
415
					<tr>
416
						<td width="22%" valign="top">&nbsp;</td>
417
						<td width="78%">
418
							<input name="submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
419
						</td>
420
					</tr>
421
				</table>
422
			</div>
423
		</td>
424
	</tr>
425
</table>
426
</form>
427
<?php include("fend.inc"); ?>
428
</body>
429
</html>
(239-239/252)