Project

General

Profile

Download (15.1 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
$pconfig['uniqueids'] = $config['ipsec']['uniqueids'];
55

    
56
if ($_POST) {
57

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

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

    
129
		$needsrestart = false;
130

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

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

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

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

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

    
181
		write_config();
182

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

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

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

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

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

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

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

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

    
217
//]]>
218
</script>
219

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

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

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