Project

General

Profile

Download (14.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
$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['unityplugin'] = isset($config['ipsec']['unityplugin']);
50
$pconfig['compression'] = isset($config['ipsec']['compression']);
51
$pconfig['acceptunencryptedmainmode'] = isset($config['ipsec']['acceptunencryptedmainmode']);
52
$pconfig['maxmss_enable'] = isset($config['system']['maxmss_enable']);
53
$pconfig['maxmss'] = $config['system']['maxmss'];
54

    
55
if ($_POST) {
56

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

    
118
		if($_POST['preferoldsa_enable'] == "yes")
119
			$config['ipsec']['preferoldsa'] = true;
120
		elseif (isset($config['ipsec']['preferoldsa']))
121
			unset($config['ipsec']['preferoldsa']);
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
				} 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
			$config['ipsec']['compression'] = true;
139
		} elseif (isset($config['ipsec']['compression'])) {
140
			$needsrestart = true;
141
			unset($config['ipsec']['compression']);
142
		}
143

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

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

    
162
		if(!empty($_POST['uniqueids'])) {
163
			$config['ipsec']['uniqueids'] = $_POST['uniqueids'];
164
		} else {
165
			unset($config['ipsec']['uniqueids']);
166
		}
167

    
168
		if($_POST['maxmss_enable'] == "yes") {
169
			$config['system']['maxmss_enable'] = true;
170
			$config['system']['maxmss'] = $_POST['maxmss'];
171
		} else {
172
			unset($config['system']['maxmss_enable']);
173
			unset($config['system']['maxmss']);
174
		}
175

    
176
		write_config();
177

    
178
		$retval = 0;
179
		$retval = filter_configure();
180
		if(stristr($retval, "error") <> true)
181
			$savemsg = get_std_save_message(gettext($retval));
182
		else
183
			$savemsg = gettext($retval);
184

    
185
		vpn_ipsec_configure_preferoldsa();
186
		vpn_ipsec_configure($needsrestart);
187
		vpn_ipsec_configure_loglevels();
188

    
189
//		header("Location: vpn_ipsec_settings.php");
190
//		return;
191
	}
192
}
193

    
194
$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Settings"));
195
$shortcut_section = "ipsec";
196

    
197
include("head.inc");
198
?>
199

    
200
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
201
<?php include("fbegin.inc"); ?>
202

    
203
<script type="text/javascript">
204
//<![CDATA[
205

    
206
function maxmss_checked(obj) {
207
	if (obj.checked)
208
		jQuery('#maxmss').attr('disabled',false);
209
	else
210
		jQuery('#maxmss').attr('disabled','true');
211
}
212

    
213
//]]>
214
</script>
215

    
216
<form action="vpn_ipsec_settings.php" method="post" name="iform" id="iform">
217

    
218
<?php
219
	if ($savemsg)
220
		print_info_box($savemsg);
221
	if ($input_errors)
222
		print_input_errors($input_errors);
223
?>
224

    
225
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn ipsec settings">
226
	<tr>
227
		<td class="tabnavtbl">
228
			<?php
229
				$tab_array = array();
230
				$tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php");
231
				$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
232
				$tab_array[2] = array(gettext("Pre-Shared Key"), false, "vpn_ipsec_keys.php");
233
				$tab_array[3] = array(gettext("Advanced Settings"), true, "vpn_ipsec_settings.php");
234
				display_top_tabs($tab_array);
235
			?>
236
		</td>
237
	</tr>
238
	<tr>
239
		<td id="mainarea">
240
			<div class="tabcont">
241
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
242
					<tr>
243
						<td colspan="2" valign="top" class="listtopic"><?=gettext("IPsec Advanced Settings"); ?></td>
244
					</tr>
245
					<tr>
246
						<td width="22%" valign="top" class="vncell"><?=gettext("Security Associations"); ?></td>
247
						<td width="78%" class="vtable">
248
							<input name="preferoldsa_enable" type="checkbox" id="preferoldsa_enable" value="yes" <?php if ($pconfig['preferoldsa_enable']) echo "checked=\"checked\""; ?> />
249
							<strong><?=gettext("Prefer older IPsec SAs"); ?></strong>
250
							<br />
251
							<?=gettext("By default, if several SAs match, the newest one is " .
252
							"preferred if it's at least 30 seconds old. Select this " .
253
							"option to always prefer old SAs over new ones."); ?>
254
						</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("Handle 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."); ?>
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("Unencrypted payloads in IKEv1 Main Mode"); ?></td>
318
						<td width="78%" class="vtable">
319
							<input name="acceptunencryptedmainmode" type="checkbox" id="acceptunencryptedmainmode" value="yes" <?php if ($pconfig['acceptunencryptedmainmode']) echo "checked=\"checked\""; ?> />
320
							<strong><?=gettext("Accept unencrypted ID and HASH payloads in IKEv1 Main Mode"); ?></strong>
321
							<br />
322
							<?=gettext("Some implementations send the third Main Mode message unencrypted, probably to find the PSKs for the specified ID for authentication." .
323
							"This is very similar to Aggressive Mode, and has the same security implications: " .
324
							"A passive attacker can sniff the negotiated Identity, and start brute forcing the PSK using the HASH payload." .
325
							" 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).");?>
326
						</td>
327
					</tr>
328
					<tr>
329
						<td width="22%" valign="top" class="vncell"><?=gettext("Maximum MSS"); ?></td>
330
						<td width="78%" class="vtable">
331
							<input name="maxmss_enable" type="checkbox" id="maxmss_enable" value="yes" <?php if ($pconfig['maxmss_enable'] == true) echo "checked=\"checked\""; ?> onclick="maxmss_checked(this)" />
332
							<strong><?=gettext("Enable MSS clamping on VPN traffic"); ?></strong>
333
							<br />
334
							<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\""; ?> />
335
							<br />
336
							<?=gettext("Enable MSS clamping on TCP flows over VPN. " .
337
							"This helps overcome problems with PMTUD on IPsec VPN links. If left blank, the default value is 1400 bytes. "); ?>
338
						</td>
339
					</tr>
340
					<tr>
341
						<td width="22%" valign="top" class="vncell"><?=gettext("Disable Cisco Extensions"); ?></td>
342
						<td width="78%" class="vtable">
343
							<input name="unityplugin" type="checkbox" id="unityplugin" value="yes" <?php if ($pconfig['unityplugin'] == true) echo "checked=\"checked\""; ?> />
344
							<strong><?=gettext("Disable Unity Plugin"); ?></strong>
345
							<br />
346
							<?=gettext("Disable Unity Plugin which provides Cisco Extension support as Split-Include, Split-Exclude, Split-Dns, ..."); ?>
347
						</td>
348
					</tr>
349
					<tr>
350
						<td width="22%" valign="top">&nbsp;</td>
351
						<td width="78%">
352
							<input name="submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
353
						</td>
354
					</tr>
355
				</table>
356
			</div>
357
		</td>
358
	</tr>
359
</table>
360
</form>
361
<?php include("fend.inc"); ?>
362
</body>
363
</html>
(243-243/256)