Project

General

Profile

Download (12.5 KB) Statistics
| Branch: | Tag: | Revision:
1 71172088 jim-p
<?php
2
/*
3
	vpn_ipsec_settings.php
4
5 ed2d1343 Renato Botelho
	Copyright (C) 2015 Electric Sheep Fencing, LLC
6 71172088 jim-p
	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 4a076e36 Ermal LUÇI
$pconfig['unityplugin'] = isset($config['ipsec']['unityplugin']);
49 0887e836 Ermal LUÇI
$pconfig['shuntlaninterfaces'] = isset($config['ipsec']['shuntlaninterfaces']);
50 e57a3e40 Chris Buechler
$pconfig['compression'] = isset($config['ipsec']['compression']);
51 24acc8f4 Chris Buechler
$pconfig['enableinterfacesuse'] = isset($config['ipsec']['enableinterfacesuse']);
52 737b18f2 Ermal
$pconfig['acceptunencryptedmainmode'] = isset($config['ipsec']['acceptunencryptedmainmode']);
53 71172088 jim-p
$pconfig['maxmss_enable'] = isset($config['system']['maxmss_enable']);
54
$pconfig['maxmss'] = $config['system']['maxmss'];
55 0ca36ca3 benny
$pconfig['uniqueids'] = $config['ipsec']['uniqueids'];
56 71172088 jim-p
57 6ae8b844 Ermal
if ($_POST) {
58 71172088 jim-p
59
	unset($input_errors);
60
	$pconfig = $_POST;
61 e469aa76 Sjon Hortensius
62 a96dc32e Chris Buechler
	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 8fdeee58 Sander van Leeuwen
		if (!is_numericint($pconfig['maxmss']) && $pconfig['maxmss'] != '') {
112 a96dc32e Chris Buechler
			$input_errors[] = "An integer must be specified for Maximum MSS.";
113
		}
114 8fdeee58 Sander van Leeuwen
		if ($pconfig['maxmss'] != '' && $pconfig['maxmss'] < 576 || $pconfig['maxmss'] > 65535)
115 e469aa76 Sjon Hortensius
			$input_errors[] = "An integer between 576 and 65535 must be specified for Maximum MSS";
116 a96dc32e Chris Buechler
	}
117 e469aa76 Sjon Hortensius
118 71172088 jim-p
	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 420fce04 Ermal LUÇI
		$needsrestart = false;
131
132
		if($_POST['compression'] == "yes") {
133
			if (!isset($config['ipsec']['compression']))
134
				$needsrestart = true;
135 e57a3e40 Chris Buechler
			$config['ipsec']['compression'] = true;
136 420fce04 Ermal LUÇI
		} elseif (isset($config['ipsec']['compression'])) {
137
			$needsrestart = true;
138 e57a3e40 Chris Buechler
			unset($config['ipsec']['compression']);
139 420fce04 Ermal LUÇI
		}
140 e469aa76 Sjon Hortensius
141 24acc8f4 Chris Buechler
		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 71172088 jim-p
150 420fce04 Ermal LUÇI
		if($_POST['unityplugin'] == "yes") {
151
			if (!isset($config['ipsec']['unityplugin']))
152
				$needsrestart = true;
153 4a076e36 Ermal LUÇI
			$config['ipsec']['unityplugin'] = true;
154 420fce04 Ermal LUÇI
		} elseif (isset($config['ipsec']['unityplugin'])) {
155
			$needsrestart = true;
156 4a076e36 Ermal LUÇI
			unset($config['ipsec']['unityplugin']);
157 420fce04 Ermal LUÇI
		}
158 4a076e36 Ermal LUÇI
159 0887e836 Ermal LUÇI
		if($_POST['shuntlaninterfaces'] == "yes") {
160 b8eeddeb Ermal LUÇI
			$config['ipsec']['shuntlaninterfaces'] = true;
161 0887e836 Ermal LUÇI
		} elseif (isset($config['ipsec']['shuntlaninterfaces'])) {
162
			unset($config['ipsec']['shuntlaninterfaces']);
163
		}
164
165 420fce04 Ermal LUÇI
		if($_POST['acceptunencryptedmainmode'] == "yes") {
166
			if (!isset($config['ipsec']['acceptunencryptedmainmode']))
167
				$needsrestart = true;
168 737b18f2 Ermal
			$config['ipsec']['acceptunencryptedmainmode'] = true;
169 420fce04 Ermal LUÇI
		} elseif (isset($config['ipsec']['acceptunencryptedmainmode'])) {
170
			$needsrestart = true;
171 737b18f2 Ermal
			unset($config['ipsec']['acceptunencryptedmainmode']);
172 420fce04 Ermal LUÇI
		}
173 737b18f2 Ermal
174 86e1846f Ermal LUÇI
		if(!empty($_POST['uniqueids'])) {
175
			$config['ipsec']['uniqueids'] = $_POST['uniqueids'];
176
		} else {
177
			unset($config['ipsec']['uniqueids']);
178
		}
179 737b18f2 Ermal
180 71172088 jim-p
		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 8fdeee58 Sander van Leeuwen
		if(stristr($retval, "error") != true)
193 71172088 jim-p
			$savemsg = get_std_save_message(gettext($retval));
194
		else
195
			$savemsg = gettext($retval);
196
197 420fce04 Ermal LUÇI
		vpn_ipsec_configure($needsrestart);
198 71172088 jim-p
		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
<script type="text/javascript">
212 391453a1 Colin Fleming
//<![CDATA[
213 71172088 jim-p
214
function maxmss_checked(obj) {
215
	if (obj.checked)
216
		jQuery('#maxmss').attr('disabled',false);
217
	else
218
		jQuery('#maxmss').attr('disabled','true');
219
}
220
221 391453a1 Colin Fleming
//]]>
222 71172088 jim-p
</script>
223
224
<?php
225
	if ($savemsg)
226
		print_info_box($savemsg);
227
	if ($input_errors)
228
		print_input_errors($input_errors);
229
?>
230
231 8fdeee58 Sander van Leeuwen
<?php
232
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 748cbea6 Sander van Leeuwen
display_top_tabs($tab_array);
239 8fdeee58 Sander van Leeuwen
240
require('classes/Form.class.php');
241
$form = new Form;
242
243 18957b59 Sander van Leeuwen
$section = new Form_Section('Start IPsec in debug mode based on sections selected');
244
245
foreach ($ipsec_loglevels as $lkey => $ldescr)
246
{
247
	$section->addInput(new Form_Select(
248
		'ipsec_' . $lkey,
249
		$ldescr,
250
		$pconfig['ipsec_' . $lkey],
251
		array('Silent', 'Audit', 'Control', 'Diag', 'Raw', 'Highest')
252
	))->setWidth(2);
253
}
254
255
$section->addInput(new Form_StaticText('', ''))->setHelp(
256
	'Launches IPsec in debug mode so that more verbose logs will be generated to aid in troubleshooting.'
257
);
258
259
$form->add($section);
260
261 8fdeee58 Sander van Leeuwen
$section = new Form_Section('IPsec Advanced Settings');
262 18957b59 Sander van Leeuwen
263 8fdeee58 Sander van Leeuwen
$section->addInput(new Form_Select(
264
	'uniqueids',
265 18957b59 Sander van Leeuwen
	'Configure Unique IDs as',
266 8fdeee58 Sander van Leeuwen
	$pconfig['uniqueids'],
267
	$ipsec_idhandling
268
))->setHelp(
269 18957b59 Sander van Leeuwen
	'Whether a particular participant ID should be kept unique, with any new IKE_SA using an ID ' .
270 8fdeee58 Sander van Leeuwen
	'deemed to replace all old ones using that ID. Participant IDs normally are unique, so a new ' .
271
	'IKE_SA using the same ID is almost invariably intended to replace an old one. ' .
272
	'The difference between <b>no</b> and <b>never</b> is that the old IKE_SAs will be replaced when receiving an ' .
273
	'INITIAL_CONTACT notify if the option is no but will ignore these notifies if <b>never</b> is configured. ' .
274
	'The daemon also accepts the value <b>keep</b> to reject ' .
275
	'new IKE_SA setups and keep the duplicate established earlier. Defaults to Yes.'
276
);
277
278
$section->addInput(new Form_Checkbox(
279
	'compression',
280
	'IP Compression',
281
	'Enable IPCompression',
282
	$pconfig['compression']
283
))->setHelp('IPComp compression of content is proposed on the connection.');
284
285
$section->addInput(new Form_Checkbox(
286
	'enableinterfacesuse',
287
	'Strict interface binding',
288
	'Enable strict interface binding',
289
	$pconfig['enableinterfacesuse']
290
))->setHelp('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.');
291
292
$section->addInput(new Form_Checkbox(
293
	'acceptunencryptedmainmode',
294
	'Unencrypted payloads in IKEv1 Main Mode',
295
	'Accept unencrypted ID and HASH payloads in IKEv1 Main Mode',
296
	$pconfig['acceptunencryptedmainmode']
297
))->setHelp(
298
	'Some implementations send the third Main Mode message unencrypted, probably to find the PSKs for the specified ID for authentication.' .
299
	'This is very similar to Aggressive Mode, and has the same security implications: ' .
300
	'A passive attacker can sniff the negotiated Identity, and start brute forcing the PSK using the HASH payload.' .
301
	'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).'
302
);
303
304
$section->addInput(new Form_Checkbox(
305
	'maxmss_enable',
306
	'Enable Maximum MSS',
307
	'Enable MSS clamping on VPN traffic',
308
	$pconfig['maxmss_enable']
309 447efafd Sander van Leeuwen
))->toggles('.toggle-maxmss', 'collapse');
310 8fdeee58 Sander van Leeuwen
311 447efafd Sander van Leeuwen
$group = new Form_Group('Maximum MSS');
312
$group->addClass('toggle-maxmss collapse');
313
314
if (!empty($pconfig['maxmss_enable']))
315
	$group->addClass('in');
316
317
$group->add(new Form_Input(
318 8fdeee58 Sander van Leeuwen
	'maxmss',
319
	'Maximum MSS',
320
	'text',
321
	($pconfig['maxmss'] ? $pconfig['maxmss'] : '1400')
322
))->setHelp(
323
	'Enable MSS clamping on TCP flows over VPN. ' .
324
	'This helps overcome problems with PMTUD on IPsec VPN links. If left blank, the default value is 1400 bytes. '
325
);
326
327 447efafd Sander van Leeuwen
$section->add($group);
328
329 8fdeee58 Sander van Leeuwen
$section->addInput(new Form_Checkbox(
330
	'unityplugin',
331
	'Disable Cisco Extensions',
332
	'Disable Unity Plugin',
333
	$pconfig['unityplugin']
334
))->setHelp('Disable Unity Plugin which provides Cisco Extension support as Split-Include, Split-Exclude, Split-Dns, ...');
335
336 e469aa76 Sjon Hortensius
$section->addInput(new Form_Checkbox(
337
	'shuntlaninterfaces',
338
	'Bypass LAN address',
339
	'Enable bypass for LAN interface ip',
340
	$pconfig['shuntlaninterfaces']
341
))->setHelp('Prevent LAN ip address to be processed for IPsec traffic.');
342
343 8fdeee58 Sander van Leeuwen
$form->add($section);
344
345
print $form;
346
347
?>
348
349
<?php include("foot.inc"); ?>