Project

General

Profile

Download (15 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['compression'] = isset($config['ipsec']['compression']);
50
$pconfig['enableinterfacesuse'] = isset($config['ipsec']['enableinterfacesuse']);
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 (is_array($config['ipsec'])) {
119
			foreach ($ipsec_loglevels as $lkey => $ldescr) {
120
				if (empty($_POST["ipsec_{$lkey}"])) {
121
					if (isset($config['ipsec']["ipsec_{$lkey}"]))
122
						unset($config['ipsec']["ipsec_{$lkey}"]);
123
				} else
124
					$config['ipsec']["ipsec_{$lkey}"] = $_POST["ipsec_{$lkey}"];
125
			}
126
		}
127

    
128
		$needsrestart = false;
129

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

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

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

    
166
		if(!empty($_POST['uniqueids'])) {
167
			$config['ipsec']['uniqueids'] = $_POST['uniqueids'];
168
		} else {
169
			unset($config['ipsec']['uniqueids']);
170
		}
171

    
172
		if($_POST['maxmss_enable'] == "yes") {
173
			$config['system']['maxmss_enable'] = true;
174
			$config['system']['maxmss'] = $_POST['maxmss'];
175
		} else {
176
			unset($config['system']['maxmss_enable']);
177
			unset($config['system']['maxmss']);
178
		}
179

    
180
		write_config();
181

    
182
		$retval = 0;
183
		$retval = filter_configure();
184
		if(stristr($retval, "error") <> true)
185
			$savemsg = get_std_save_message(gettext($retval));
186
		else
187
			$savemsg = gettext($retval);
188

    
189
		vpn_ipsec_configure($needsrestart);
190
		vpn_ipsec_configure_loglevels();
191

    
192
//		header("Location: vpn_ipsec_settings.php");
193
//		return;
194
	}
195
}
196

    
197
$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Settings"));
198
$shortcut_section = "ipsec";
199

    
200
include("head.inc");
201
?>
202

    
203
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
204
<?php include("fbegin.inc"); ?>
205

    
206
<script type="text/javascript">
207
//<![CDATA[
208

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

    
216
//]]>
217
</script>
218

    
219
<form action="vpn_ipsec_settings.php" method="post" name="iform" id="iform">
220

    
221
<?php
222
	if ($savemsg)
223
		print_info_box($savemsg);
224
	if ($input_errors)
225
		print_input_errors($input_errors);
226
?>
227

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