Project

General

Profile

Download (17.4 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
		if (is_array($config['ipsec'])) {
124
			foreach ($ipsec_loglevels as $lkey => $ldescr) {
125
				if (empty($_POST["ipsec_{$lkey}"])) {
126
					if (isset($config['ipsec']["ipsec_{$lkey}"])) {
127
						unset($config['ipsec']["ipsec_{$lkey}"]);
128
					}
129
				} else {
130
					$config['ipsec']["ipsec_{$lkey}"] = $_POST["ipsec_{$lkey}"];
131
				}
132
			}
133
		}
134

    
135
		$needsrestart = false;
136

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

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

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

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

    
173
		if ($_POST['noshuntlaninterfaces'] == "yes") {
174
			unset($config['ipsec']['noshuntlaninterfaces']);
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 {
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
			unset($config['system']['maxmss_enable']);
200
			unset($config['system']['maxmss']);
201
		}
202

    
203
		write_config();
204

    
205
		$retval = 0;
206
		$retval = filter_configure();
207
		if (stristr($retval, "error") <> true) {
208
			$savemsg = get_std_save_message(gettext($retval));
209
		} else {
210
			$savemsg = gettext($retval);
211
		}
212

    
213
		vpn_ipsec_configure($needsrestart);
214
		vpn_ipsec_configure_loglevels();
215

    
216
		header("Location: vpn_ipsec_settings.php");
217
		return;
218
	}
219

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

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

    
232
include("head.inc");
233
?>
234

    
235
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
236
<?php include("fbegin.inc"); ?>
237

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

    
241
function maxmss_checked(obj) {
242
	if (obj.checked) {
243
		jQuery('#maxmss').attr('disabled',false);
244
	} else {
245
		jQuery('#maxmss').attr('disabled','true');
246
	}
247
}
248

    
249
//]]>
250
</script>
251

    
252
<form action="vpn_ipsec_settings.php" method="post" name="iform" id="iform">
253

    
254
<?php
255
	if ($savemsg) {
256
		print_info_box($savemsg);
257
	}
258
	if ($input_errors) {
259
		print_input_errors($input_errors);
260
	}
261
?>
262

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