Project

General

Profile

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

    
57
if ($_POST) {
58

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

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

    
130
		$needsrestart = false;
131

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

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

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

    
165
		if($_POST['acceptunencryptedmainmode'] == "yes") {
166
			if (!isset($config['ipsec']['acceptunencryptedmainmode']))
167
				$needsrestart = true;
168
			$config['ipsec']['acceptunencryptedmainmode'] = true;
169
		} elseif (isset($config['ipsec']['acceptunencryptedmainmode'])) {
170
			$needsrestart = true;
171
			unset($config['ipsec']['acceptunencryptedmainmode']);
172
		}
173

    
174
		if(!empty($_POST['uniqueids'])) {
175
			$config['ipsec']['uniqueids'] = $_POST['uniqueids'];
176
		} else {
177
			unset($config['ipsec']['uniqueids']);
178
		}
179

    
180
		if($_POST['maxmss_enable'] == "yes") {
181
			$config['system']['maxmss_enable'] = true;
182
			$config['system']['maxmss'] = $_POST['maxmss'];
183
		} else {
184
			unset($config['system']['maxmss_enable']);
185
			unset($config['system']['maxmss']);
186
		}
187

    
188
		write_config();
189

    
190
		$retval = 0;
191
		$retval = filter_configure();
192
		if(stristr($retval, "error") <> true)
193
			$savemsg = get_std_save_message(gettext($retval));
194
		else
195
			$savemsg = gettext($retval);
196

    
197
		vpn_ipsec_configure($needsrestart);
198
		vpn_ipsec_configure_loglevels();
199

    
200
//		header("Location: vpn_ipsec_settings.php");
201
//		return;
202
	}
203
}
204

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

    
208
include("head.inc");
209
?>
210

    
211
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
212
<?php include("fbegin.inc"); ?>
213

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

    
217
function maxmss_checked(obj) {
218
	if (obj.checked)
219
		jQuery('#maxmss').attr('disabled',false);
220
	else
221
		jQuery('#maxmss').attr('disabled','true');
222
}
223

    
224
//]]>
225
</script>
226

    
227
<form action="vpn_ipsec_settings.php" method="post" name="iform" id="iform">
228

    
229
<?php
230
	if ($savemsg)
231
		print_info_box($savemsg);
232
	if ($input_errors)
233
		print_input_errors($input_errors);
234
?>
235

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