Project

General

Profile

Download (37.2 KB) Statistics
| Branch: | Tag: | Revision:
1 a93e56c5 Matthew Grooms
<?php
2
/*
3
	vpn_ipsec_phase1.php
4
	part of m0n0wall (http://m0n0.ch/wall)
5
6
	Copyright (C) 2008 Shrew Soft Inc
7
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
8 fa4e059e Ermal
	Copyright (C) 2014 Ermal LUÇI
9 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
10 a93e56c5 Matthew Grooms
	All rights reserved.
11
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17
18
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33
34 6b07c15a Matthew Grooms
##|+PRIV
35
##|*IDENT=page-vpn-ipsec-editphase1
36
##|*NAME=VPN: IPsec: Edit Phase 1 page
37
##|*DESCR=Allow access to the 'VPN: IPsec: Edit Phase 1' page.
38
##|*MATCH=vpn_ipsec_phase1.php*
39
##|-PRIV
40
41 0f84b741 Scott Ullrich
require("functions.inc");
42 a93e56c5 Matthew Grooms
require("guiconfig.inc");
43 483e6de8 Scott Ullrich
require_once("ipsec.inc");
44
require_once("vpn.inc");
45 caaaf9ce Renato Botelho
require_once("filter.inc");
46 a93e56c5 Matthew Grooms
47
if (!is_array($config['ipsec']['phase1']))
48
	$config['ipsec']['phase1'] = array();
49
50 647c7c48 Seth Mos
if (!is_array($config['ipsec']['phase2']))
51
	$config['ipsec']['phase2'] = array();
52
53 a93e56c5 Matthew Grooms
$a_phase1 = &$config['ipsec']['phase1'];
54 647c7c48 Seth Mos
$a_phase2 = &$config['ipsec']['phase2'];
55 a93e56c5 Matthew Grooms
56 e41ec584 Renato Botelho
if (is_numericint($_GET['p1index']))
57
	$p1index = $_GET['p1index'];
58 9caf5eca Renato Botelho
if (isset($_POST['p1index']) && is_numericint($_POST['p1index']))
59 a93e56c5 Matthew Grooms
	$p1index = $_POST['p1index'];
60
61 e41ec584 Renato Botelho
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
62 a93e56c5 Matthew Grooms
	$p1index = $_GET['dup'];
63
64 fad728ab sullrich
if (isset($p1index) && $a_phase1[$p1index]) {
65 99bbd213 Matthew Grooms
	// don't copy the ikeid on dup
66 e41ec584 Renato Botelho
	if (!isset($_GET['dup']) || !is_numericint($_GET['dup']))
67 99bbd213 Matthew Grooms
		$pconfig['ikeid'] = $a_phase1[$p1index]['ikeid'];
68 7fc26246 Seth Mos
69 647c7c48 Seth Mos
	$old_ph1ent = $a_phase1[$p1index];
70 99bbd213 Matthew Grooms
71 a93e56c5 Matthew Grooms
	$pconfig['disabled'] = isset($a_phase1[$p1index]['disabled']);
72
73
	if ($a_phase1[$p1index]['interface'])
74
		$pconfig['interface'] = $a_phase1[$p1index]['interface'];
75
	else
76
		$pconfig['interface'] = "wan";
77
78
	list($pconfig['remotenet'],$pconfig['remotebits']) = explode("/", $a_phase1[$p1index]['remote-subnet']);
79 3462a529 Matthew Grooms
80
	if (isset($a_phase1[$p1index]['mobile']))
81
		$pconfig['mobile'] = 'true';
82
	else
83
		$pconfig['remotegw'] = $a_phase1[$p1index]['remote-gateway'];
84
85 fa4e059e Ermal
	if (empty($a_phase1[$p1index]['iketype']))
86
		$pconfig['iketype'] = "ikev1";
87
	else
88
		$pconfig['iketype'] = $a_phase1[$p1index]['iketype'];
89 a93e56c5 Matthew Grooms
	$pconfig['mode'] = $a_phase1[$p1index]['mode'];
90 e79b24ab Seth Mos
	$pconfig['protocol'] = $a_phase1[$p1index]['protocol'];
91 a93e56c5 Matthew Grooms
	$pconfig['myid_type'] = $a_phase1[$p1index]['myid_type'];
92
	$pconfig['myid_data'] = $a_phase1[$p1index]['myid_data'];
93
	$pconfig['peerid_type'] = $a_phase1[$p1index]['peerid_type'];
94
	$pconfig['peerid_data'] = $a_phase1[$p1index]['peerid_data'];
95
	$pconfig['ealgo'] = $a_phase1[$p1index]['encryption-algorithm'];
96
	$pconfig['halgo'] = $a_phase1[$p1index]['hash-algorithm'];
97
	$pconfig['dhgroup'] = $a_phase1[$p1index]['dhgroup'];
98
	$pconfig['lifetime'] = $a_phase1[$p1index]['lifetime'];
99
	$pconfig['authentication_method'] = $a_phase1[$p1index]['authentication_method'];
100 4e2af464 Matthew Grooms
101 ab2ccd9f Renato Botelho
	if (($pconfig['authentication_method'] == "pre_shared_key") ||
102 4e2af464 Matthew Grooms
		($pconfig['authentication_method'] == "xauth_psk_server")) {
103
		$pconfig['pskey'] = $a_phase1[$p1index]['pre-shared-key'];
104
	} else {
105 73fbece8 mgrooms
		$pconfig['certref'] = $a_phase1[$p1index]['certref'];
106 a22d475f jim-p
		$pconfig['caref'] = $a_phase1[$p1index]['caref'];
107 4e2af464 Matthew Grooms
	}
108 a93e56c5 Matthew Grooms
109
	$pconfig['descr'] = $a_phase1[$p1index]['descr'];
110
	$pconfig['nat_traversal'] = $a_phase1[$p1index]['nat_traversal'];
111 3462a529 Matthew Grooms
112 ce21dfca Ermal
	if (isset($a_phase1[$p1index]['reauth_enable']))
113 0e7aad67 Ermal
		$pconfig['reauth_enable'] = true;
114 ce21dfca Ermal
	if (isset($a_phase1[$p1index]['rekey_enable']))
115 0e7aad67 Ermal
		$pconfig['rekey_enable'] = true;
116 87808568 Ermal LUÇI
	if (isset($a_phase1[$p1index]['responderonly']))
117
		$pconfig['responderonly'] = true;
118 0e7aad67 Ermal
119 3462a529 Matthew Grooms
	if ($a_phase1[$p1index]['dpd_delay'] &&	$a_phase1[$p1index]['dpd_maxfail']) {
120
		$pconfig['dpd_enable'] = true;
121
		$pconfig['dpd_delay'] = $a_phase1[$p1index]['dpd_delay'];
122
		$pconfig['dpd_maxfail'] = $a_phase1[$p1index]['dpd_maxfail'];
123
	}
124 fad728ab sullrich
} else {
125 a93e56c5 Matthew Grooms
	/* defaults */
126
	$pconfig['interface'] = "wan";
127 ab2ccd9f Renato Botelho
	if($config['interfaces']['lan'])
128 a93e56c5 Matthew Grooms
		$pconfig['localnet'] = "lan";
129 460719c8 Chris Buechler
	$pconfig['mode'] = "main";
130 e79b24ab Seth Mos
	$pconfig['protocol'] = "inet";
131 a93e56c5 Matthew Grooms
	$pconfig['myid_type'] = "myaddress";
132
	$pconfig['peerid_type'] = "peeraddress";
133
	$pconfig['authentication_method'] = "pre_shared_key";
134 c5ddb6ad Chris Buechler
	$pconfig['ealgo'] = array( name => "aes" );
135 a93e56c5 Matthew Grooms
	$pconfig['halgo'] = "sha1";
136
	$pconfig['dhgroup'] = "2";
137
	$pconfig['lifetime'] = "28800";
138 86ef7a0a Ermal
	$pconfig['nat_traversal'] = 'on';
139 3462a529 Matthew Grooms
	$pconfig['dpd_enable'] = true;
140 20452c68 Ermal
	$pconfig['iketype'] = "ikev1";
141 3462a529 Matthew Grooms
142
	/* mobile client */
143 460719c8 Chris Buechler
	if($_GET['mobile']) {
144 3462a529 Matthew Grooms
		$pconfig['mobile']=true;
145 460719c8 Chris Buechler
                $pconfig['mode'] = "aggressive";
146
	}
147 a93e56c5 Matthew Grooms
}
148
149 e41ec584 Renato Botelho
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
150 a93e56c5 Matthew Grooms
	unset($p1index);
151
152
if ($_POST) {
153
	unset($input_errors);
154
	$pconfig = $_POST;
155
156
	/* input validation */
157 3462a529 Matthew Grooms
158
	$method = $pconfig['authentication_method'];
159 f27526cd Evgeny Yurchenko
	// Unset ca and cert if not required to avaoid storing in config
160 c7a7a4ee Ermal Luçi
	if ($method == "pre_shared_key" || $method == "xauth_psk_server"){
161 ab2ccd9f Renato Botelho
		unset($pconfig['caref']);
162
		unset($pconfig['certref']);
163 f27526cd Evgeny Yurchenko
	}
164 99642234 jim-p
165 1f65618b jim-p
	// Only require PSK here for normal PSK tunnels (not mobile) or xauth.
166 0a7c9c8e jim-p
	// For RSA methods, require the CA/Cert.
167 99642234 jim-p
	switch ($method) {
168 10e2acb5 Ermal LUÇI
		case 'eap-mschapv2':
169
			if ($pconfig['iketype'] != 'ikev2')
170
				$input_errors[] = gettext("EAP-MSChapv2 can only be used with IKEv2 type VPNs.");
171
			break;
172 fa4e059e Ermal
		case "eap-tls":
173
			if ($pconfig['iketype'] != 'ikev2')
174
				$input_errors[] = gettext("EAP-TLS can only be used with IKEv2 type VPNs.");
175
			break;
176 99642234 jim-p
		case "pre_shared_key":
177 ab2ccd9f Renato Botelho
			// If this is a mobile PSK tunnel the user PSKs go on
178 0a7c9c8e jim-p
			//    the PSK tab, not here, so skip the check.
179 99642234 jim-p
			if ($pconfig['mobile'])
180
				break;
181
		case "xauth_psk_server":
182
			$reqdfields = explode(" ", "pskey");
183
			$reqdfieldsn = array(gettext("Pre-Shared Key"));
184 69b79ff0 Renato Botelho
			$validate_pskey = true;
185 99642234 jim-p
			break;
186
		case "hybrid_rsa_server":
187
		case "xauth_rsa_server":
188
		case "rsasig":
189
			$reqdfields = explode(" ", "caref certref");
190
			$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
191
			break;
192 a93e56c5 Matthew Grooms
	}
193 3462a529 Matthew Grooms
	if (!$pconfig['mobile']) {
194
		$reqdfields[] = "remotegw";
195 2fbb33f1 Carlos Eduardo Ramos
		$reqdfieldsn[] = gettext("Remote gateway");
196 3462a529 Matthew Grooms
	}
197 a93e56c5 Matthew Grooms
198 1e9b4611 Renato Botelho
	do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
199 a93e56c5 Matthew Grooms
200 69b79ff0 Renato Botelho
	if (isset($validate_pskey) && isset($pconfig['pskey']) && !preg_match('/^[[:ascii:]]*$/', $pconfig['pskey'])) {
201
		unset($validate_pskey);
202
		$input_errors[] = gettext("Pre-Shared Key contains invalid characters.");
203
	}
204
205 3462a529 Matthew Grooms
	if (($pconfig['lifetime'] && !is_numeric($pconfig['lifetime'])))
206 2fbb33f1 Carlos Eduardo Ramos
		$input_errors[] = gettext("The P1 lifetime must be an integer.");
207 a93e56c5 Matthew Grooms
208 e4ffca08 Renato Botelho
	if ($pconfig['remotegw']) {
209
		if (!is_ipaddr($pconfig['remotegw']) && !is_domain($pconfig['remotegw']))
210
			$input_errors[] = gettext("A valid remote gateway address or host name must be specified.");
211
		elseif (is_ipaddrv4($pconfig['remotegw']) && ($pconfig['protocol'] != "inet"))
212
			$input_errors[] = gettext("A valid remote gateway IPv4 address must be specified or you need to change protocol to IPv6");
213
		elseif (is_ipaddrv6($pconfig['remotegw']) && ($pconfig['protocol'] != "inet6"))
214
			$input_errors[] = gettext("A valid remote gateway IPv6 address must be specified or you need to change protocol to IPv4");
215
	}
216 a93e56c5 Matthew Grooms
217 3462a529 Matthew Grooms
	if (($pconfig['remotegw'] && is_ipaddr($pconfig['remotegw']) && !isset($pconfig['disabled']) )) {
218 a93e56c5 Matthew Grooms
		$t = 0;
219
		foreach ($a_phase1 as $ph1tmp) {
220
			if ($p1index <> $t) {
221
				$tremotegw = $pconfig['remotegw'];
222
				if (($ph1tmp['remote-gateway'] == $tremotegw) && !isset($ph1tmp['disabled'])) {
223 ddc55e12 Erik Fonnesbeck
					$input_errors[] = sprintf(gettext('The remote gateway "%1$s" is already used by phase1 "%2$s".'), $tremotegw, $ph1tmp['descr']);
224 a93e56c5 Matthew Grooms
				}
225
			}
226
			$t++;
227
		}
228
	}
229
230 e4ffca08 Renato Botelho
	if (is_array($a_phase2) && (count($a_phase2))) {
231
		foreach ($a_phase2 as $phase2) {
232
			if($phase2['ikeid'] == $pconfig['ikeid']) {
233
				if (($pconfig['protocol'] == "inet") && ($phase2['mode'] == "tunnel6")) {
234
					$input_errors[] = gettext("There is a Phase 2 using IPv6, you cannot use IPv4.");
235
					break;
236
				}
237
				if (($pconfig['protocol'] == "inet6") && ($phase2['mode'] == "tunnel")) {
238
					$input_errors[] = gettext("There is a Phase 2 using IPv4, you cannot use IPv6.");
239
					break;
240
				}
241
			}
242
		}
243
	}
244
245 a93e56c5 Matthew Grooms
	/* My identity */
246
247 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "myaddress")
248
		$pconfig['myid_data'] = "";
249 a93e56c5 Matthew Grooms
250 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "address" and $pconfig['myid_data'] == "")
251 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter an address for 'My Identifier'");
252
253 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "keyid tag" and $pconfig['myid_data'] == "")
254 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter a keyid tag for 'My Identifier'");
255
256 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "fqdn" and $pconfig['myid_data'] == "")
257 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter a fully qualified domain name for 'My Identifier'");
258
259 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "user_fqdn" and $pconfig['myid_data'] == "")
260 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'My Identifier'");
261
262 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "dyn_dns" and $pconfig['myid_data'] == "")
263 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter a dynamic domain name for 'My Identifier'");
264
265 3462a529 Matthew Grooms
	if ((($pconfig['myid_type'] == "address") && !is_ipaddr($pconfig['myid_data'])))
266 2fbb33f1 Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid IP address for 'My identifier' must be specified.");
267 a93e56c5 Matthew Grooms
268 3462a529 Matthew Grooms
	if ((($pconfig['myid_type'] == "fqdn") && !is_domain($pconfig['myid_data'])))
269 2fbb33f1 Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid domain name for 'My identifier' must be specified.");
270 a93e56c5 Matthew Grooms
271 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "fqdn")
272
		if (is_domain($pconfig['myid_data']) == false)
273 2fbb33f1 Carlos Eduardo Ramos
			$input_errors[] = gettext("A valid FQDN for 'My identifier' must be specified.");
274 a93e56c5 Matthew Grooms
275 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "user_fqdn") {
276
		$user_fqdn = explode("@",$pconfig['myid_data']);
277 a93e56c5 Matthew Grooms
		if (is_domain($user_fqdn[1]) == false)
278 2fbb33f1 Carlos Eduardo Ramos
			$input_errors[] = gettext("A valid User FQDN in the form of user@my.domain.com for 'My identifier' must be specified.");
279 a93e56c5 Matthew Grooms
	}
280
281 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "dyn_dns")
282
		if (is_domain($pconfig['myid_data']) == false)
283 2fbb33f1 Carlos Eduardo Ramos
			$input_errors[] = gettext("A valid Dynamic DNS address for 'My identifier' must be specified.");
284 a93e56c5 Matthew Grooms
285
	/* Peer identity */
286
287 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "peeraddress")
288
		$pconfig['peerid_data'] = "";
289
290 1f65618b jim-p
	// Only enforce peer ID if we are not dealing with a pure-psk mobile config.
291
	if (!(($pconfig['authentication_method'] == "pre_shared_key") && ($pconfig['mobile']))) {
292
		if ($pconfig['peerid_type'] == "address" and $pconfig['peerid_data'] == "")
293
			$input_errors[] = gettext("Please enter an address for 'Peer Identifier'");
294 a93e56c5 Matthew Grooms
295 1f65618b jim-p
		if ($pconfig['peerid_type'] == "keyid tag" and $pconfig['peerid_data'] == "")
296
			$input_errors[] = gettext("Please enter a keyid tag for 'Peer Identifier'");
297 a93e56c5 Matthew Grooms
298 1f65618b jim-p
		if ($pconfig['peerid_type'] == "fqdn" and $pconfig['peerid_data'] == "")
299
			$input_errors[] = gettext("Please enter a fully qualified domain name for 'Peer Identifier'");
300 a93e56c5 Matthew Grooms
301 1f65618b jim-p
		if ($pconfig['peerid_type'] == "user_fqdn" and $pconfig['peerid_data'] == "")
302
			$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'Peer Identifier'");
303 a93e56c5 Matthew Grooms
304 1f65618b jim-p
		if ((($pconfig['peerid_type'] == "address") && !is_ipaddr($pconfig['peerid_data'])))
305 2fbb33f1 Carlos Eduardo Ramos
			$input_errors[] = gettext("A valid IP address for 'Peer identifier' must be specified.");
306 a93e56c5 Matthew Grooms
307 1f65618b jim-p
		if ((($pconfig['peerid_type'] == "fqdn") && !is_domain($pconfig['peerid_data'])))
308 2fbb33f1 Carlos Eduardo Ramos
			$input_errors[] = gettext("A valid domain name for 'Peer identifier' must be specified.");
309 a93e56c5 Matthew Grooms
310 1f65618b jim-p
		if ($pconfig['peerid_type'] == "fqdn")
311
			if (is_domain($pconfig['peerid_data']) == false)
312 2fbb33f1 Carlos Eduardo Ramos
				$input_errors[] = gettext("A valid FQDN for 'Peer identifier' must be specified.");
313 a93e56c5 Matthew Grooms
314 1f65618b jim-p
		if ($pconfig['peerid_type'] == "user_fqdn") {
315
			$user_fqdn = explode("@",$pconfig['peerid_data']);
316
			if (is_domain($user_fqdn[1]) == false)
317 2fbb33f1 Carlos Eduardo Ramos
				$input_errors[] = gettext("A valid User FQDN in the form of user@my.domain.com for 'Peer identifier' must be specified.");
318 1f65618b jim-p
		}
319 a93e56c5 Matthew Grooms
	}
320
321 3462a529 Matthew Grooms
	if ($pconfig['dpd_enable']) {
322
		if (!is_numeric($pconfig['dpd_delay']))
323 2fbb33f1 Carlos Eduardo Ramos
			$input_errors[] = gettext("A numeric value must be specified for DPD delay.");
324 a93e56c5 Matthew Grooms
325 3462a529 Matthew Grooms
		if (!is_numeric($pconfig['dpd_maxfail']))
326 2fbb33f1 Carlos Eduardo Ramos
			$input_errors[] = gettext("A numeric value must be specified for DPD retries.");
327 a93e56c5 Matthew Grooms
	}
328
329 ddabd9d6 Ermal
	if (!empty($pconfig['iketype']) && $pconfig['iketype'] != "ikev1" && $pconfig['iketype'] != "ikev2" && $pconfig['iketype'] != "auto")
330
		$input_errors[] = gettext("Valid arguments for IKE type is v1 or v2 or auto");
331 20452c68 Ermal
332 a93e56c5 Matthew Grooms
	/* build our encryption algorithms array */
333
	$pconfig['ealgo'] = array();
334
	$pconfig['ealgo']['name'] = $_POST['ealgo'];
335 3462a529 Matthew Grooms
	if($pconfig['ealgo_keylen'])
336 a93e56c5 Matthew Grooms
		$pconfig['ealgo']['keylen'] = $_POST['ealgo_keylen'];
337
338
	if (!$input_errors) {
339 3462a529 Matthew Grooms
		$ph1ent['ikeid'] = $pconfig['ikeid'];
340 20452c68 Ermal
		$ph1ent['iketype'] = $pconfig['iketype'];
341 8e87f714 Ermal LUÇI
		if ($pconfig['iketype'] != 'ikev1')
342
			unset($ph1ent['mode']);
343
		else
344
			$ph1ent['mode'] = $pconfig['mode'];
345 3462a529 Matthew Grooms
		$ph1ent['disabled'] = $pconfig['disabled'] ? true : false;
346 a93e56c5 Matthew Grooms
		$ph1ent['interface'] = $pconfig['interface'];
347
		/* if the remote gateway changed and the interface is not WAN then remove route */
348
		/* the vpn_ipsec_configure() handles adding the route */
349 3462a529 Matthew Grooms
		if ($pconfig['interface'] <> "wan") {
350 7fc26246 Seth Mos
			if($old_ph1ent['remote-gateway'] <> $pconfig['remotegw']) {
351 3acab378 smos
				mwexec("/sbin/route delete -host {$old_ph1ent['remote-gateway']}");
352 a93e56c5 Matthew Grooms
			}
353
		}
354
355 3462a529 Matthew Grooms
		if ($pconfig['mobile'])
356
			$ph1ent['mobile'] = true;
357
		else
358
			$ph1ent['remote-gateway'] = $pconfig['remotegw'];
359
360 e79b24ab Seth Mos
		$ph1ent['protocol'] = $pconfig['protocol'];
361 3462a529 Matthew Grooms
362
		$ph1ent['myid_type'] = $pconfig['myid_type'];
363
		$ph1ent['myid_data'] = $pconfig['myid_data'];
364
		$ph1ent['peerid_type'] = $pconfig['peerid_type'];
365
		$ph1ent['peerid_data'] = $pconfig['peerid_data'];
366 a93e56c5 Matthew Grooms
367
		$ph1ent['encryption-algorithm'] = $pconfig['ealgo'];
368 3462a529 Matthew Grooms
		$ph1ent['hash-algorithm'] = $pconfig['halgo'];
369
		$ph1ent['dhgroup'] = $pconfig['dhgroup'];
370
		$ph1ent['lifetime'] = $pconfig['lifetime'];
371
		$ph1ent['pre-shared-key'] = $pconfig['pskey'];
372
		$ph1ent['private-key'] = base64_encode($pconfig['privatekey']);
373 73fbece8 mgrooms
		$ph1ent['certref'] = $pconfig['certref'];
374 a22d475f jim-p
		$ph1ent['caref'] = $pconfig['caref'];
375 3462a529 Matthew Grooms
		$ph1ent['authentication_method'] = $pconfig['authentication_method'];
376
		$ph1ent['descr'] = $pconfig['descr'];
377
		$ph1ent['nat_traversal'] = $pconfig['nat_traversal'];
378
379 0e7aad67 Ermal
		if (isset($pconfig['reauth_enable']))
380
			$ph1ent['reauth_enable'] = true;
381 a6a42b6d Ermal LUÇI
		else
382
			unset($ph1ent['reauth_enable']);
383 0e7aad67 Ermal
		if (isset($pconfig['rekey_enable']))
384
			$ph1ent['rekey_enable'] = true;
385 a6a42b6d Ermal LUÇI
		else
386
			unset($ph1ent['rekey_enable']);
387 0e7aad67 Ermal
388 87808568 Ermal LUÇI
		if (isset($pconfig['responderonly']))
389
			$ph1ent['responderonly'] = true;
390
		else
391
			unset($ph1ent['responderonly']);
392
393 3462a529 Matthew Grooms
		if (isset($pconfig['dpd_enable'])) {
394
			$ph1ent['dpd_delay'] = $pconfig['dpd_delay'];
395
			$ph1ent['dpd_maxfail'] = $pconfig['dpd_maxfail'];
396
		}
397
398 a93e56c5 Matthew Grooms
		/* generate unique phase1 ikeid */
399 d799787e Matthew Grooms
		if ($ph1ent['ikeid'] == 0)
400
			$ph1ent['ikeid'] = ipsec_ikeid_next();
401 a93e56c5 Matthew Grooms
402
		if (isset($p1index) && $a_phase1[$p1index])
403
			$a_phase1[$p1index] = $ph1ent;
404
		else
405
			$a_phase1[] = $ph1ent;
406
407
		write_config();
408 a368a026 Ermal Lu?i
		mark_subsystem_dirty('ipsec');
409 a93e56c5 Matthew Grooms
410
		header("Location: vpn_ipsec.php");
411
		exit;
412
	}
413
}
414
415 3462a529 Matthew Grooms
if ($pconfig['mobile'])
416 2fbb33f1 Carlos Eduardo Ramos
	$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1"), gettext("Mobile Client"));
417 3462a529 Matthew Grooms
else
418 2fbb33f1 Carlos Eduardo Ramos
	$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1"));
419 b32dd0a6 jim-p
$shortcut_section = "ipsec";
420 6deedfde jim-p
421 3462a529 Matthew Grooms
422 a93e56c5 Matthew Grooms
include("head.inc");
423
424
?>
425
426
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
427
<?php include("fbegin.inc"); ?>
428 91f026b0 ayvis
<script type="text/javascript">
429 a0fca224 Colin Fleming
//<![CDATA[
430 3462a529 Matthew Grooms
431
function myidsel_change() {
432
	index = document.iform.myid_type.selectedIndex;
433
	value = document.iform.myid_type.options[index].value;
434
	if (value == 'myaddress')
435 5a3b0d3b mgrooms
			document.getElementById('myid_data').style.visibility = 'hidden';
436 3462a529 Matthew Grooms
	else
437 5a3b0d3b mgrooms
			document.getElementById('myid_data').style.visibility = 'visible';
438 3462a529 Matthew Grooms
}
439
440 0771969b Ermal LUÇI
function iketype_change() {
441
	index = document.iform.iketype.selectedIndex;
442
	value = document.iform.iketype.options[index].value;
443
	if (value == 'ikev2')
444
			document.getElementById('negmode').style.display= 'none';
445
	else
446
			document.getElementById('negmode').style.display = '';
447
}
448
449 3462a529 Matthew Grooms
function peeridsel_change() {
450
	index = document.iform.peerid_type.selectedIndex;
451
	value = document.iform.peerid_type.options[index].value;
452
	if (value == 'peeraddress')
453 5a3b0d3b mgrooms
			document.getElementById('peerid_data').style.visibility = 'hidden';
454 3462a529 Matthew Grooms
	else
455 5a3b0d3b mgrooms
			document.getElementById('peerid_data').style.visibility = 'visible';
456 3462a529 Matthew Grooms
}
457
458 a93e56c5 Matthew Grooms
function methodsel_change() {
459 3462a529 Matthew Grooms
	index = document.iform.authentication_method.selectedIndex;
460
	value = document.iform.authentication_method.options[index].value;
461
462
	switch (value) {
463 10e2acb5 Ermal LUÇI
	case 'eap-mschapv2':
464 fa4e059e Ermal
	case 'eap-tls':
465
		document.getElementById('opt_psk').style.display = 'none';
466
		document.getElementById('opt_peerid').style.display = '';
467
		document.getElementById('opt_cert').style.display = '';
468
		document.getElementById('opt_ca').style.display = '';
469
		document.getElementById('opt_cert').disabled = false;
470
		document.getElementById('opt_ca').disabled = false;
471
		break;
472
	case 'hybrid_rsa_server':
473
		document.getElementById('opt_psk').style.display = 'none';
474
		document.getElementById('opt_peerid').style.display = '';
475
		document.getElementById('opt_cert').style.display = '';
476
		document.getElementById('opt_ca').style.display = '';
477
		document.getElementById('opt_cert').disabled = false;
478
		document.getElementById('opt_ca').disabled = false;
479
		break;
480
	case 'xauth_rsa_server':
481
	case 'rsasig':
482
		document.getElementById('opt_psk').style.display = 'none';
483
		document.getElementById('opt_peerid').style.display = '';
484
		document.getElementById('opt_cert').style.display = '';
485
		document.getElementById('opt_ca').style.display = '';
486
		document.getElementById('opt_cert').disabled = false;
487
		document.getElementById('opt_ca').disabled = false;
488
		break;
489 1f65618b jim-p
<?php if ($pconfig['mobile']) { ?>
490 fa4e059e Ermal
	case 'pre_shared_key':
491
		document.getElementById('opt_psk').style.display = 'none';
492
		document.getElementById('opt_peerid').style.display = 'none';
493
		document.getElementById('opt_cert').style.display = 'none';
494
		document.getElementById('opt_ca').style.display = 'none';
495
		document.getElementById('opt_cert').disabled = true;
496
		document.getElementById('opt_ca').disabled = true;
497
		break;
498 1f65618b jim-p
<?php } ?>
499 fa4e059e Ermal
	default: /* psk modes*/
500
		document.getElementById('opt_psk').style.display = '';
501
		document.getElementById('opt_peerid').style.display = '';
502
		document.getElementById('opt_cert').style.display = 'none';
503
		document.getElementById('opt_ca').style.display = 'none';
504
		document.getElementById('opt_cert').disabled = true;
505
		document.getElementById('opt_ca').disabled = true;
506
		break;
507 a93e56c5 Matthew Grooms
	}
508
}
509
510
/* PHP generated java script for variable length keys */
511
function ealgosel_change(bits) {
512
	switch (document.iform.ealgo.selectedIndex) {
513
<?php
514 ab2ccd9f Renato Botelho
$i = 0;
515
foreach ($p1_ealgos as $algo => $algodata) {
516
	if (is_array($algodata['keysel'])) {
517
		echo "		case {$i}:\n";
518
		echo "			document.iform.ealgo_keylen.style.visibility = 'visible';\n";
519
		echo "			document.iform.ealgo_keylen.options.length = 0;\n";
520
	//      echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( 'auto', 'auto' );\n";
521
522
		$key_hi = $algodata['keysel']['hi'];
523
		$key_lo = $algodata['keysel']['lo'];
524
		$key_step = $algodata['keysel']['step'];
525
526
		for ($keylen = $key_hi; $keylen >= $key_lo; $keylen -= $key_step)
527
			echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( '{$keylen} bits', '{$keylen}' );\n";
528
		echo "			break;\n";
529
	} else {
530
		echo "		case {$i}:\n";
531
		echo "			document.iform.ealgo_keylen.style.visibility = 'hidden';\n";
532
		echo "			document.iform.ealgo_keylen.options.length = 0;\n";
533
		echo "			break;\n";
534
	}
535
	$i++;
536
}
537 a93e56c5 Matthew Grooms
?>
538
	}
539
540
	if( bits )
541
		document.iform.ealgo_keylen.value = bits;
542
}
543 3462a529 Matthew Grooms
544 a93e56c5 Matthew Grooms
function dpdchkbox_change() {
545 5a3b0d3b mgrooms
	if( document.iform.dpd_enable.checked )
546
		document.getElementById('opt_dpd').style.display = '';
547
	else
548
		document.getElementById('opt_dpd').style.display = 'none';
549 3462a529 Matthew Grooms
550
	if (!document.iform.dpd_delay.value)
551
		document.iform.dpd_delay.value = "10";
552
553
	if (!document.iform.dpd_maxfail.value)
554
		document.iform.dpd_maxfail.value = "5";
555 a93e56c5 Matthew Grooms
}
556 3462a529 Matthew Grooms
557 a0fca224 Colin Fleming
//]]>
558 a93e56c5 Matthew Grooms
</script>
559 5a3b0d3b mgrooms
560
<form action="vpn_ipsec_phase1.php" method="post" name="iform" id="iform">
561
562
<?php
563
	if ($input_errors)
564
		print_input_errors($input_errors);
565
?>
566
567 a0fca224 Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn ipsec phase-1">
568 5a3b0d3b mgrooms
	<tr class="tabnavtbl">
569
		<td id="tabnav">
570
			<?php
571
				$tab_array = array();
572 2fbb33f1 Carlos Eduardo Ramos
				$tab_array[0] = array(gettext("Tunnels"), true, "vpn_ipsec.php");
573
				$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
574 2a2b247b jim-p
				$tab_array[2] = array(gettext("Pre-Shared Keys"), false, "vpn_ipsec_keys.php");
575 71172088 jim-p
				$tab_array[3] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
576 5a3b0d3b mgrooms
				display_top_tabs($tab_array);
577
			?>
578
		</td>
579
	</tr>
580
	<tr>
581
		<td id="mainarea">
582
			<div class="tabcont">
583 a0fca224 Colin Fleming
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
584 5a3b0d3b mgrooms
					<tr>
585 2fbb33f1 Carlos Eduardo Ramos
						<td colspan="2" valign="top" class="listtopic"><?=gettext("General information"); ?></td>
586 5a3b0d3b mgrooms
					</tr>
587
					<tr>
588 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
589 5a3b0d3b mgrooms
						<td width="78%" class="vtable">
590 a0fca224 Colin Fleming
							<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked=\"checked\""; ?> />
591 8cd558b6 ayvis
							<strong><?=gettext("Disable this phase1 entry"); ?></strong><br />
592 5a3b0d3b mgrooms
							<span class="vexpl">
593 2fbb33f1 Carlos Eduardo Ramos
								<?=gettext("Set this option to disable this phase1 without " .
594
								"removing it from the list"); ?>.
595 5a3b0d3b mgrooms
							</span>
596
						</td>
597
					</tr>
598 20452c68 Ermal
					<tr>
599
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Key Exchange version"); ?></td>
600
						<td width="78%" class="vtable">
601 0771969b Ermal LUÇI
							<select name="iketype" class="formselect" onchange='iketype_change()'>
602 20452c68 Ermal
							<?php
603 ddabd9d6 Ermal
								$keyexchange = array("ikev1" => "V1", "ikev2" => "V2", "auto" => "Auto");
604 20452c68 Ermal
								foreach ($keyexchange as $kidx => $name):
605
							?>
606 a0fca224 Colin Fleming
								<option value="<?=$kidx;?>" <?php if ($kidx == $pconfig['iketype']) echo "selected=\"selected\""; ?>>
607 20452c68 Ermal
									<?=htmlspecialchars($name);?>
608
								</option>
609
							<?php endforeach; ?>
610 24aa9e40 Chris Buechler
							</select> <br /> <span class="vexpl"><?=gettext("Select the Internet Key Exchange protocol version to be used, IKEv1 or IKEv2"); ?>.</span>
611 20452c68 Ermal
						</td>
612
					</tr>
613 e79b24ab Seth Mos
					<tr>
614
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Internet Protocol"); ?></td>
615
						<td width="78%" class="vtable">
616
							<select name="protocol" class="formselect">
617
							<?php
618
								$protocols = array("inet" => "IPv4", "inet6" => "IPv6");
619
								foreach ($protocols as $protocol => $name):
620
							?>
621 a0fca224 Colin Fleming
								<option value="<?=$protocol;?>" <?php if ($protocol == $pconfig['protocol']) echo "selected=\"selected\""; ?>>
622 e79b24ab Seth Mos
									<?=htmlspecialchars($name);?>
623
								</option>
624
							<?php endforeach; ?>
625 8cd558b6 ayvis
							</select> <br /> <span class="vexpl"><?=gettext("Select the Internet Protocol family from this dropdown"); ?>.</span>
626 e79b24ab Seth Mos
						</td>
627
					</tr>
628 5a3b0d3b mgrooms
					<tr>
629 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
630 5a3b0d3b mgrooms
						<td width="78%" class="vtable">
631
							<select name="interface" class="formselect">
632 ab2ccd9f Renato Botelho
							<?php
633 5a3b0d3b mgrooms
								$interfaces = get_configured_interface_with_descr();
634 6dbffeda smos
635 abcb2bed Ermal Lu?i
								$carplist = get_configured_carp_interface_list();
636
								foreach ($carplist as $cif => $carpip)
637 dd62256f Pierre POMES
									$interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")";
638 6dbffeda smos
639 25f6730a Pierre POMES
								$aliaslist = get_configured_ip_aliases_list();
640
								foreach ($aliaslist as $aliasip => $aliasif)
641 96b4c29a Pierre POMES
									$interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
642 6dbffeda smos
643
								$grouplist = return_gateway_groups_array();
644
								foreach ($grouplist as $name => $group) {
645
									if($group[0]['vip'] <> "")
646
										$vipif = $group[0]['vip'];
647
									else
648
										$vipif = $group[0]['int'];
649
									$interfaces[$name] = "GW Group {$name}";
650
								}
651
652
653 5a3b0d3b mgrooms
								foreach ($interfaces as $iface => $ifacename):
654
							?>
655 a0fca224 Colin Fleming
								<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected=\"selected\""; ?>>
656 5a3b0d3b mgrooms
									<?=htmlspecialchars($ifacename);?>
657
								</option>
658
							<?php endforeach; ?>
659
							</select>
660 8cd558b6 ayvis
							<br />
661 2fbb33f1 Carlos Eduardo Ramos
							<span class="vexpl"><?=gettext("Select the interface for the local endpoint of this phase1 entry"); ?>.</span>
662 5a3b0d3b mgrooms
						</td>
663
					</tr>
664
665
					<?php if (!$pconfig['mobile']): ?>
666
667
					<tr>
668 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote gateway"); ?></td>
669 5a3b0d3b mgrooms
						<td width="78%" class="vtable">
670 a0fca224 Colin Fleming
							<?=$mandfldhtml;?><input name="remotegw" type="text" class="formfld unknown" id="remotegw" size="28" value="<?=htmlspecialchars($pconfig['remotegw']);?>" />
671 8cd558b6 ayvis
							<br />
672 2fbb33f1 Carlos Eduardo Ramos
							<?=gettext("Enter the public IP address or host name of the remote gateway"); ?>
673 5a3b0d3b mgrooms
						</td>
674
					</tr>
675
676
					<?php endif; ?>
677
678
					<tr>
679 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
680 5a3b0d3b mgrooms
						<td width="78%" class="vtable">
681 a0fca224 Colin Fleming
							<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
682 8cd558b6 ayvis
							<br />
683 5a3b0d3b mgrooms
							<span class="vexpl">
684 2fbb33f1 Carlos Eduardo Ramos
								<?=gettext("You may enter a description here " .
685
								"for your reference (not parsed)"); ?>.
686 5a3b0d3b mgrooms
							</span>
687
						</td>
688
					</tr>
689
					<tr>
690
						<td colspan="2" class="list" height="12"></td>
691
					</tr>
692
					<tr>
693
						<td colspan="2" valign="top" class="listtopic">
694 2fbb33f1 Carlos Eduardo Ramos
							<?=gettext("Phase 1 proposal (Authentication)"); ?>
695 5a3b0d3b mgrooms
						</td>
696
					</tr>
697 71d61aa5 jim-p
					<tr>
698 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication method"); ?></td>
699 71d61aa5 jim-p
						<td width="78%" class="vtable">
700 a0fca224 Colin Fleming
							<select name="authentication_method" class="formselect" onchange="methodsel_change()">
701 71d61aa5 jim-p
							<?php
702
								foreach ($p1_authentication_methods as $method_type => $method_params):
703
									if (!$pconfig['mobile'] && $method_params['mobile'])
704
										continue;
705
							?>
706 a0fca224 Colin Fleming
								<option value="<?=$method_type;?>" <?php if ($method_type == $pconfig['authentication_method']) echo "selected=\"selected\""; ?>>
707 71d61aa5 jim-p
									<?=htmlspecialchars($method_params['name']);?>
708
								</option>
709
							<?php endforeach; ?>
710
							</select>
711 8cd558b6 ayvis
							<br />
712 71d61aa5 jim-p
							<span class="vexpl">
713 2fbb33f1 Carlos Eduardo Ramos
								<?=gettext("Must match the setting chosen on the remote side"); ?>.
714 71d61aa5 jim-p
							</span>
715
						</td>
716
					</tr>
717 0771969b Ermal LUÇI
					<tr id='negmode' >
718 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Negotiation mode"); ?></td>
719 5a3b0d3b mgrooms
						<td width="78%" class="vtable">
720
							<select name="mode" class="formselect">
721
							<?php
722 fc835b04 Ermal
								$modes = array("main" => "Main", "aggressive" => "Aggressive");
723 0dc05b20 Ermal
								foreach ($modes as $mode => $mdescr):
724 5a3b0d3b mgrooms
							?>
725 a0fca224 Colin Fleming
								<option value="<?=$mode;?>" <?php if ($mode == $pconfig['mode']) echo "selected=\"selected\""; ?>>
726 0dc05b20 Ermal
									<?=htmlspecialchars($mdescr);?>
727 5a3b0d3b mgrooms
								</option>
728
							<?php endforeach; ?>
729 8cd558b6 ayvis
							</select> <br /> <span class="vexpl"><?=gettext("Aggressive is more flexible, but less secure"); ?>.</span>
730 5a3b0d3b mgrooms
						</td>
731
					</tr>
732
					<tr>
733 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("My identifier"); ?></td>
734 5a3b0d3b mgrooms
						<td width="78%" class="vtable">
735 a0fca224 Colin Fleming
							<select name="myid_type" class="formselect" onchange="myidsel_change()">
736 5a3b0d3b mgrooms
							<?php foreach ($my_identifier_list as $id_type => $id_params): ?>
737 a0fca224 Colin Fleming
								<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['myid_type']) echo "selected=\"selected\""; ?>>
738 5a3b0d3b mgrooms
									<?=htmlspecialchars($id_params['desc']);?>
739
								</option>
740
							<?php endforeach; ?>
741
							</select>
742 a0fca224 Colin Fleming
							<input name="myid_data" type="text" class="formfld unknown" id="myid_data" size="30" value="<?=htmlspecialchars($pconfig['myid_data']);?>" />
743 5a3b0d3b mgrooms
						</td>
744
					</tr>
745 1f65618b jim-p
					<tr id="opt_peerid">
746 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer identifier"); ?></td>
747 5a3b0d3b mgrooms
						<td width="78%" class="vtable">
748 a0fca224 Colin Fleming
							<select name="peerid_type" class="formselect" onchange="peeridsel_change()">
749 5a3b0d3b mgrooms
							<?php
750
								foreach ($peer_identifier_list as $id_type => $id_params):
751
									if ($pconfig['mobile'] && !$id_params['mobile'])
752
										continue;
753
							?>
754 a0fca224 Colin Fleming
							<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['peerid_type']) echo "selected=\"selected\""; ?>>
755 5a3b0d3b mgrooms
								<?=htmlspecialchars($id_params['desc']);?>
756
							</option>
757
							<?php endforeach; ?>
758
							</select>
759 a0fca224 Colin Fleming
							<input name="peerid_data" type="text" class="formfld unknown" id="peerid_data" size="30" value="<?=htmlspecialchars($pconfig['peerid_data']);?>" />
760 1f65618b jim-p
						<?php if ($pconfig['mobile']) { ?>
761 8cd558b6 ayvis
							<br /><br /><?=gettext("NOTE: This is known as the \"group\" setting on some VPN client implementations"); ?>.
762 1f65618b jim-p
						<?php } ?>
763 5a3b0d3b mgrooms
						</td>
764
					</tr>
765 71d61aa5 jim-p
					<tr id="opt_psk">
766 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Pre-Shared Key"); ?></td>
767 71d61aa5 jim-p
						<td width="78%" class="vtable">
768
							<?=$mandfldhtml;?>
769 a0fca224 Colin Fleming
							<input name="pskey" type="text" class="formfld unknown" id="pskey" size="40" value="<?=htmlspecialchars($pconfig['pskey']);?>" />
770 71d61aa5 jim-p
							<span class="vexpl">
771 8cd558b6 ayvis
							<br />
772 2a2b247b jim-p
								<?=gettext("Input your Pre-Shared Key string"); ?>.
773 71d61aa5 jim-p
							</span>
774
						</td>
775
					</tr>
776 fa4e059e Ermal
					<tr id="opt_cert">
777
						<td width="22%" valign="top" class="vncellreq"><?=gettext("My Certificate"); ?></td>
778
						<td width="78%" class="vtable">
779
							<select name="certref" class="formselect">
780
							<?php
781
								foreach ($config['cert'] as $cert):
782
									$selected = "";
783
									if ($pconfig['certref'] == $cert['refid'])
784
										$selected = "selected=\"selected\"";
785
							?>
786
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['descr'];?></option>
787
							<?php endforeach; ?>
788
							</select>
789
							<br />
790
							<span class="vexpl">
791
								<?=gettext("Select a certificate previously configured in the Certificate Manager"); ?>.
792
							</span>
793
						</td>
794
					</tr>
795
					<tr id="opt_ca">
796
						<td width="22%" valign="top" class="vncellreq"><?=gettext("My Certificate Authority"); ?></td>
797
						<td width="78%" class="vtable">
798
							<select name="caref" class="formselect">
799
							<?php
800
								foreach ($config['ca'] as $ca):
801
									$selected = "";
802
									if ($pconfig['caref'] == $ca['refid'])
803
										$selected = "selected=\"selected\"";
804
							?>
805
								<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['descr'];?></option>
806
							<?php endforeach; ?>
807
							</select>
808
							<br />
809
							<span class="vexpl">
810
								<?=gettext("Select a certificate authority previously configured in the Certificate Manager"); ?>.
811
							</span>
812
						</td>
813
					</tr>
814
					<tr>
815
						<td colspan="2" valign="top" class="listtopic">
816
							<?=gettext("Phase 1 proposal (Algorithms)"); ?>
817
						</td>
818
					</tr>
819 5a3b0d3b mgrooms
					<tr>
820 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Encryption algorithm"); ?></td>
821 5a3b0d3b mgrooms
						<td width="78%" class="vtable">
822 a0fca224 Colin Fleming
							<select name="ealgo" class="formselect" onchange="ealgosel_change()">
823 5a3b0d3b mgrooms
							<?php
824
								foreach ($p1_ealgos as $algo => $algodata):
825 a0fca224 Colin Fleming
									$selected = "";
826 5a3b0d3b mgrooms
									if ($algo == $pconfig['ealgo']['name'])
827 a0fca224 Colin Fleming
										$selected = " selected=\"selected\"";
828 5a3b0d3b mgrooms
							?>
829
								<option value="<?=$algo;?>"<?=$selected?>>
830
									<?=htmlspecialchars($algodata['name']);?>
831
								</option>
832
							<?php endforeach; ?>
833
							</select>
834
							<select name="ealgo_keylen" width="30" class="formselect">
835
							</select>
836
						</td>
837
					</tr>
838
					<tr>
839 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Hash algorithm"); ?></td>
840 5a3b0d3b mgrooms
						<td width="78%" class="vtable">
841
							<select name="halgo" class="formselect">
842
							<?php foreach ($p1_halgos as $algo => $algoname): ?>
843 a0fca224 Colin Fleming
								<option value="<?=$algo;?>" <?php if ($algo == $pconfig['halgo']) echo "selected=\"selected\""; ?>>
844 5a3b0d3b mgrooms
									<?=htmlspecialchars($algoname);?>
845
								</option>
846
							<?php endforeach; ?>
847
							</select>
848 8cd558b6 ayvis
							<br />
849 5a3b0d3b mgrooms
							<span class="vexpl">
850 2fbb33f1 Carlos Eduardo Ramos
								<?=gettext("Must match the setting chosen on the remote side"); ?>.
851 5a3b0d3b mgrooms
							</span>
852
						</td>
853
					</tr>
854
					<tr>
855 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("DH key group"); ?></td>
856 5a3b0d3b mgrooms
						<td width="78%" class="vtable">
857
							<select name="dhgroup" class="formselect">
858 665340db jim-p
							<?php foreach ($p1_dhgroups as $keygroup => $keygroupname): ?>
859 a0fca224 Colin Fleming
								<option value="<?=$keygroup;?>" <?php if ($keygroup == $pconfig['dhgroup']) echo "selected=\"selected\""; ?>>
860 665340db jim-p
									<?=htmlspecialchars($keygroupname);?>
861 5a3b0d3b mgrooms
								</option>
862
							<?php endforeach; ?>
863
							</select>
864 8cd558b6 ayvis
							<br />
865 5a3b0d3b mgrooms
							<span class="vexpl">
866 2fbb33f1 Carlos Eduardo Ramos
								<?=gettext("Must match the setting chosen on the remote side"); ?>.
867 5a3b0d3b mgrooms
							</span>
868
						</td>
869
					</tr>
870
					<tr>
871 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Lifetime"); ?></td>
872 5a3b0d3b mgrooms
						<td width="78%" class="vtable">
873 a0fca224 Colin Fleming
							<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="20" value="<?=htmlspecialchars($pconfig['lifetime']);?>" />
874 2fbb33f1 Carlos Eduardo Ramos
							<?=gettext("seconds"); ?>
875 5a3b0d3b mgrooms
						</td>
876
					</tr>
877
					<tr>
878
						<td colspan="2" class="list" height="12"></td>
879
					</tr>
880
					<tr>
881 2fbb33f1 Carlos Eduardo Ramos
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced Options"); ?></td>
882 5a3b0d3b mgrooms
					</tr>
883 0e7aad67 Ermal
					<tr>
884 3b9ef0ef Ermal
						<td width="22%" valign="top" class="vncell"><?=gettext("Disable Rekey");?></td>
885 0e7aad67 Ermal
						<td width="78%" class="vtable">
886
							<input name="rekey_enable" type="checkbox" id="rekey_enable" value="yes" <?php if (isset($pconfig['rekey_enable'])) echo "checked=\"checked\""; ?> />
887
							<?=gettext("Whether a connection should be renegotiated when it is about to expire."); ?><br />
888
						</td>
889
					</tr>
890
					<tr>
891 3b9ef0ef Ermal
						<td width="22%" valign="top" class="vncell"><?=gettext("Disable Reauth");?></td>
892 0e7aad67 Ermal
						<td width="78%" class="vtable">
893
							<input name="reauth_enable" type="checkbox" id="reauth_enable" value="yes" <?php if (isset($pconfig['reauth_enable'])) echo "checked=\"checked\""; ?> />
894 76266acd Ermal
							<?=gettext("Whether rekeying of an IKE_SA should also reauthenticate the peer. In IKEv1, reauthentication is always done."); ?><br />
895 0e7aad67 Ermal
						</td>
896
					</tr>
897 87808568 Ermal LUÇI
					<tr>
898
						<td width="22%" valign="top" class="vncell"><?=gettext("Only repsonder");?></td>
899
						<td width="78%" class="vtable">
900
							<input name="responderonly" type="checkbox" id="responderonly" value="yes" <?php if (isset($pconfig['responderonly'])) echo "checked=\"checked\""; ?> />
901
							<?=gettext("Whether a connection should be passive on a connection and just wait connectivity from the other peer.."); ?><br />
902
						</td>
903
					</tr>
904 5a3b0d3b mgrooms
					<tr>
905 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("NAT Traversal"); ?></td>
906 5a3b0d3b mgrooms
						<td width="78%" class="vtable">
907
							<select name="nat_traversal" class="formselect">
908 0810a719 Ermal
								<option value="on" <?php if ($pconfig['nat_traversal'] != 'on') echo "selected=\"selected\""; ?>><?=gettext("Auto"); ?></option>
909
								<option value="force" <?php if ($pconfig['nat_traversal'] == 'force') echo "selected=\"selected\""; ?>><?=gettext("Force"); ?></option>
910 5a3b0d3b mgrooms
							</select>
911 8cd558b6 ayvis
							<br />
912 5a3b0d3b mgrooms
							<span class="vexpl">
913 2fbb33f1 Carlos Eduardo Ramos
								<?=gettext("Set this option to enable the use of NAT-T (i.e. the encapsulation of ESP in UDP packets) if needed, " .
914
								"which can help with clients that are behind restrictive firewalls"); ?>.
915 5a3b0d3b mgrooms
							</span>
916
						</td>
917
					</tr>
918
					<tr>
919 2fbb33f1 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Dead Peer Detection"); ?></td>
920 5a3b0d3b mgrooms
						<td width="78%" class="vtable">
921 a0fca224 Colin Fleming
							<input name="dpd_enable" type="checkbox" id="dpd_enable" value="yes" <?php if (isset($pconfig['dpd_enable'])) echo "checked=\"checked\""; ?> onclick="dpdchkbox_change()" />
922 8cd558b6 ayvis
							<?=gettext("Enable DPD"); ?><br />
923 5a3b0d3b mgrooms
							<div id="opt_dpd">
924 8cd558b6 ayvis
								<br />
925 a0fca224 Colin Fleming
								<input name="dpd_delay" type="text" class="formfld unknown" id="dpd_delay" size="5" value="<?=htmlspecialchars($pconfig['dpd_delay']);?>" />
926 8cd558b6 ayvis
								<?=gettext("seconds"); ?><br />
927 5a3b0d3b mgrooms
								<span class="vexpl">
928 2fbb33f1 Carlos Eduardo Ramos
									<?=gettext("Delay between requesting peer acknowledgement"); ?>.
929 8cd558b6 ayvis
								</span><br />
930
								<br />
931 a0fca224 Colin Fleming
								<input name="dpd_maxfail" type="text" class="formfld unknown" id="dpd_maxfail" size="5" value="<?=htmlspecialchars($pconfig['dpd_maxfail']);?>" />
932 8cd558b6 ayvis
								<?=gettext("retries"); ?><br />
933 5a3b0d3b mgrooms
								<span class="vexpl">
934 2fbb33f1 Carlos Eduardo Ramos
									<?=gettext("Number of consecutive failures allowed before disconnect"); ?>.
935 5a3b0d3b mgrooms
								</span>
936 8cd558b6 ayvis
								<br />
937 5a3b0d3b mgrooms
							</div>
938
						</td>
939
					</tr>
940
					<tr>
941
						<td width="22%" valign="top">&nbsp;</td>
942
						<td width="78%">
943
							<?php if (isset($p1index) && $a_phase1[$p1index]): ?>
944 a0fca224 Colin Fleming
							<input name="p1index" type="hidden" value="<?=htmlspecialchars($p1index);?>" />
945 5a3b0d3b mgrooms
							<?php endif; ?>
946
							<?php if ($pconfig['mobile']): ?>
947 a0fca224 Colin Fleming
							<input name="mobile" type="hidden" value="true" />
948 5a3b0d3b mgrooms
							<?php endif; ?>
949 a0fca224 Colin Fleming
							<input name="ikeid" type="hidden" value="<?=htmlspecialchars($pconfig['ikeid']);?>" />
950
							<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
951 5a3b0d3b mgrooms
						</td>
952
					</tr>
953
				</table>
954
			</div>
955
		</td>
956
	</tr>
957
</table>
958 a93e56c5 Matthew Grooms
</form>
959 5a3b0d3b mgrooms
960 a0fca224 Colin Fleming
<script type="text/javascript">
961
//<![CDATA[
962 a93e56c5 Matthew Grooms
<?php
963
	/* determine if we should init the key length */
964
	$keyset = '';
965
	if (isset($pconfig['ealgo']['keylen']))
966
		if (is_numeric($pconfig['ealgo']['keylen']))
967
			$keyset = $pconfig['ealgo']['keylen'];
968
?>
969 3462a529 Matthew Grooms
myidsel_change();
970
peeridsel_change();
971 0771969b Ermal LUÇI
iketype_change();
972 a93e56c5 Matthew Grooms
methodsel_change();
973
ealgosel_change(<?=$keyset;?>);
974
dpdchkbox_change();
975 a0fca224 Colin Fleming
//]]>
976 a93e56c5 Matthew Grooms
</script>
977
<?php include("fend.inc"); ?>
978 3462a529 Matthew Grooms
</body>
979
</html>