Project

General

Profile

Download (17.3 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
$pconfig['unityplugin'] = isset($config['ipsec']['unityplugin']);
49
$pconfig['makebeforebreak'] = isset($config['ipsec']['makebeforebreak']);
50
$pconfig['noshuntlaninterfaces'] = isset($config['ipsec']['noshuntlaninterfaces']);
51
$pconfig['compression'] = isset($config['ipsec']['compression']);
52
$pconfig['enableinterfacesuse'] = isset($config['ipsec']['enableinterfacesuse']);
53
$pconfig['acceptunencryptedmainmode'] = isset($config['ipsec']['acceptunencryptedmainmode']);
54
$pconfig['maxmss_enable'] = isset($config['system']['maxmss_enable']);
55
$pconfig['maxmss'] = $config['system']['maxmss'];
56
$pconfig['uniqueids'] = $config['ipsec']['uniqueids'];
57

    
58
if ($_POST) {
59

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

    
121
		if (is_array($config['ipsec'])) {
122
			foreach ($ipsec_loglevels as $lkey => $ldescr) {
123
				if (empty($_POST["ipsec_{$lkey}"])) {
124
					if (isset($config['ipsec']["ipsec_{$lkey}"]))
125
						unset($config['ipsec']["ipsec_{$lkey}"]);
126
				} else
127
					$config['ipsec']["ipsec_{$lkey}"] = $_POST["ipsec_{$lkey}"];
128
			}
129
		}
130

    
131
		$needsrestart = false;
132

    
133
		if($_POST['compression'] == "yes") {
134
			if (!isset($config['ipsec']['compression']))
135
				$needsrestart = true;
136
			$config['ipsec']['compression'] = true;
137
		} elseif (isset($config['ipsec']['compression'])) {
138
			$needsrestart = true;
139
			unset($config['ipsec']['compression']);
140
		}
141
		
142
		if($_POST['enableinterfacesuse'] == "yes") {
143
			if (!isset($config['ipsec']['enableinterfacesuse']))
144
				$needsrestart = true;
145
			$config['ipsec']['enableinterfacesuse'] = true;
146
		} elseif (isset($config['ipsec']['enableinterfacesuse'])) {
147
			$needsrestart = true;
148
			unset($config['ipsec']['enableinterfacesuse']);
149
		}
150

    
151
		if($_POST['unityplugin'] == "yes") {
152
			if (!isset($config['ipsec']['unityplugin']))
153
				$needsrestart = true;
154
			$config['ipsec']['unityplugin'] = true;
155
		} elseif (isset($config['ipsec']['unityplugin'])) {
156
			$needsrestart = true;
157
			unset($config['ipsec']['unityplugin']);
158
		}
159

    
160
		if($_POST['makebeforebreak'] == "yes") {
161
			$config['ipsec']['makebeforebreak'] = true;
162
		} elseif (isset($config['ipsec']['makebeforebreak'])) {
163
			unset($config['ipsec']['makebeforebreak']);
164
		}
165

    
166
		/* The wierd logic here is to avoid negative policies when checked #4655 */
167
		if($_POST['noshuntlaninterfaces'] == "yes") {
168
			unset($config['ipsec']['noshuntlaninterfaces']);
169
		} else {
170
			$config['ipsec']['noshuntlaninterfaces'] = true;
171
		}
172

    
173
		if($_POST['acceptunencryptedmainmode'] == "yes") {
174
			if (!isset($config['ipsec']['acceptunencryptedmainmode']))
175
				$needsrestart = true;
176
			$config['ipsec']['acceptunencryptedmainmode'] = true;
177
		} elseif (isset($config['ipsec']['acceptunencryptedmainmode'])) {
178
			$needsrestart = true;
179
			unset($config['ipsec']['acceptunencryptedmainmode']);
180
		}
181

    
182
		if(!empty($_POST['uniqueids'])) {
183
			$config['ipsec']['uniqueids'] = $_POST['uniqueids'];
184
		} else {
185
			unset($config['ipsec']['uniqueids']);
186
		}
187

    
188
		if($_POST['maxmss_enable'] == "yes") {
189
			$config['system']['maxmss_enable'] = true;
190
			$config['system']['maxmss'] = $_POST['maxmss'];
191
		} else {
192
			unset($config['system']['maxmss_enable']);
193
			unset($config['system']['maxmss']);
194
		}
195

    
196
		write_config();
197

    
198
		$retval = 0;
199
		$retval = filter_configure();
200
		if(stristr($retval, "error") <> true)
201
			$savemsg = get_std_save_message(gettext($retval));
202
		else
203
			$savemsg = gettext($retval);
204

    
205
		vpn_ipsec_configure($needsrestart);
206
		vpn_ipsec_configure_loglevels();
207

    
208
		header("Location: vpn_ipsec_settings.php");
209
		return;
210
	}
211

    
212
	// The logic value sent by $POST is opposite to the way it is stored in the config.
213
	// Reset the $pconfig value so it reflects the opposite of what was $POSTed.
214
	if ($_POST['noshuntlaninterfaces'] == "yes") {
215
		$pconfig['noshuntlaninterfaces'] = false;
216
	} else {
217
		$pconfig['noshuntlaninterfaces'] = true;
218
	}
219
}
220

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

    
224
include("head.inc");
225
?>
226

    
227
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
228
<?php include("fbegin.inc"); ?>
229

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

    
233
function maxmss_checked(obj) {
234
	if (obj.checked)
235
		jQuery('#maxmss').attr('disabled',false);
236
	else
237
		jQuery('#maxmss').attr('disabled','true');
238
}
239

    
240
//]]>
241
</script>
242

    
243
<form action="vpn_ipsec_settings.php" method="post" name="iform" id="iform">
244

    
245
<?php
246
	if ($savemsg)
247
		print_info_box($savemsg);
248
	if ($input_errors)
249
		print_input_errors($input_errors);
250
?>
251

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