Project

General

Profile

Download (11.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['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
<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
<?php
217
	if ($savemsg)
218
		print_info_box($savemsg);
219
	if ($input_errors)
220
		print_input_errors($input_errors);
221
?>
222

    
223
<?php
224

    
225
$tab_array = array();
226
$tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php");
227
$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
228
$tab_array[2] = array(gettext("Pre-Shared Key"), false, "vpn_ipsec_keys.php");
229
$tab_array[3] = array(gettext("Advanced Settings"), true, "vpn_ipsec_settings.php");
230
display_top_tabs($tab_array, false, 'pills');
231

    
232
require('classes/Form.class.php');
233
$form = new Form;
234

    
235
$section = new Form_Section('Start IPsec in debug mode based on sections selected');
236

    
237
foreach ($ipsec_loglevels as $lkey => $ldescr)
238
{
239
	$section->addInput(new Form_Select(
240
		'ipsec_' . $lkey,
241
		$ldescr,
242
		$pconfig['ipsec_' . $lkey],
243
		array('Silent', 'Audit', 'Control', 'Diag', 'Raw', 'Highest')
244
	))->setWidth(2);
245
}
246

    
247
$section->addInput(new Form_StaticText('', ''))->setHelp(
248
	'Launches IPsec in debug mode so that more verbose logs will be generated to aid in troubleshooting.'
249
);
250

    
251
$form->add($section);
252

    
253
$section = new Form_Section('IPsec Advanced Settings');
254

    
255
$section->addInput(new Form_Select(
256
	'uniqueids',
257
	'Configure Unique IDs as',
258
	$pconfig['uniqueids'],
259
	$ipsec_idhandling
260
))->setHelp(
261
	'Whether a particular participant ID should be kept unique, with any new IKE_SA using an ID ' .
262
	'deemed to replace all old ones using that ID. Participant IDs normally are unique, so a new ' .
263
	'IKE_SA using the same ID is almost invariably intended to replace an old one. ' .
264
	'The difference between <b>no</b> and <b>never</b> is that the old IKE_SAs will be replaced when receiving an ' .
265
	'INITIAL_CONTACT notify if the option is no but will ignore these notifies if <b>never</b> is configured. ' .
266
	'The daemon also accepts the value <b>keep</b> to reject ' .
267
	'new IKE_SA setups and keep the duplicate established earlier. Defaults to Yes.'
268
);
269

    
270
$section->addInput(new Form_Checkbox(
271
	'compression',
272
	'IP Compression',
273
	'Enable IPCompression',
274
	$pconfig['compression']
275
))->setHelp('IPComp compression of content is proposed on the connection.');
276

    
277
$section->addInput(new Form_Checkbox(
278
	'enableinterfacesuse',
279
	'Strict interface binding',
280
	'Enable strict interface binding',
281
	$pconfig['enableinterfacesuse']
282
))->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.');
283

    
284
$section->addInput(new Form_Checkbox(
285
	'acceptunencryptedmainmode',
286
	'Unencrypted payloads in IKEv1 Main Mode',
287
	'Accept unencrypted ID and HASH payloads in IKEv1 Main Mode',
288
	$pconfig['acceptunencryptedmainmode']
289
))->setHelp(
290
	'Some implementations send the third Main Mode message unencrypted, probably to find the PSKs for the specified ID for authentication.' .
291
	'This is very similar to Aggressive Mode, and has the same security implications: ' .
292
	'A passive attacker can sniff the negotiated Identity, and start brute forcing the PSK using the HASH payload.' .
293
	'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).'
294
);
295

    
296
$section->addInput(new Form_Checkbox(
297
	'maxmss_enable',
298
	'Enable Maximum MSS',
299
	'Enable MSS clamping on VPN traffic',
300
	$pconfig['maxmss_enable']
301
))->toggles('.toggle-maxmss', 'collapse');
302

    
303
$group = new Form_Group('Maximum MSS');
304
$group->addClass('toggle-maxmss collapse');
305

    
306
if (!empty($pconfig['maxmss_enable']))
307
	$group->addClass('in');
308

    
309
$group->add(new Form_Input(
310
	'maxmss',
311
	'Maximum MSS',
312
	'text',
313
	($pconfig['maxmss'] ? $pconfig['maxmss'] : '1400')
314
))->setHelp(
315
	'Enable MSS clamping on TCP flows over VPN. ' .
316
	'This helps overcome problems with PMTUD on IPsec VPN links. If left blank, the default value is 1400 bytes. '
317
);
318

    
319
$section->add($group);
320

    
321
$section->addInput(new Form_Checkbox(
322
	'unityplugin',
323
	'Disable Cisco Extensions',
324
	'Disable Unity Plugin',
325
	$pconfig['unityplugin']
326
))->setHelp('Disable Unity Plugin which provides Cisco Extension support as Split-Include, Split-Exclude, Split-Dns, ...');
327

    
328
$form->add($section);
329

    
330
print $form;
331

    
332
?>
333

    
334
<?php include("foot.inc"); ?>
(239-239/252)