Project

General

Profile

Download (26.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?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
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31

    
32
##|+PRIV
33
##|*IDENT=page-vpn-ipsec-editphase1
34
##|*NAME=VPN: IPsec: Edit Phase 1 page
35
##|*DESCR=Allow access to the 'VPN: IPsec: Edit Phase 1' page.
36
##|*MATCH=vpn_ipsec_phase1.php*
37
##|-PRIV
38

    
39
require("functions.inc");
40
require("guiconfig.inc");
41

    
42
if (!is_array($config['ipsec']['phase1']))
43
	$config['ipsec']['phase1'] = array();
44

    
45
if (!is_array($config['ipsec']['phase2']))
46
	$config['ipsec']['phase2'] = array();
47

    
48
$a_phase1 = &$config['ipsec']['phase1'];
49
$a_phase2 = &$config['ipsec']['phase2'];
50

    
51
$p1index = $_GET['p1index'];
52
if (isset($_POST['p1index']))
53
	$p1index = $_POST['p1index'];
54

    
55
if (isset($_GET['dup'])) {
56
	$p1index = $_GET['dup'];
57
}
58

    
59
if (isset($p1index) && $a_phase1[$p1index])
60
{
61
	// don't copy the ikeid on dup
62
	if (!isset($_GET['dup']))
63
		$pconfig['ikeid'] = $a_phase1[$p1index]['ikeid'];
64

    
65
	$old_ph1ent = $a_phase1[$p1index];
66

    
67
	$pconfig['disabled'] = isset($a_phase1[$p1index]['disabled']);
68

    
69
	if ($a_phase1[$p1index]['interface'])
70
		$pconfig['interface'] = $a_phase1[$p1index]['interface'];
71
	else
72
		$pconfig['interface'] = "wan";
73

    
74
	list($pconfig['remotenet'],$pconfig['remotebits']) = explode("/", $a_phase1[$p1index]['remote-subnet']);
75

    
76
	if (isset($a_phase1[$p1index]['mobile']))
77
		$pconfig['mobile'] = 'true';
78
	else
79
		$pconfig['remotegw'] = $a_phase1[$p1index]['remote-gateway'];
80

    
81
	$pconfig['mode'] = $a_phase1[$p1index]['mode'];
82
	$pconfig['myid_type'] = $a_phase1[$p1index]['myid_type'];
83
	$pconfig['myid_data'] = $a_phase1[$p1index]['myid_data'];
84
	$pconfig['peerid_type'] = $a_phase1[$p1index]['peerid_type'];
85
	$pconfig['peerid_data'] = $a_phase1[$p1index]['peerid_data'];
86
	$pconfig['ealgo'] = $a_phase1[$p1index]['encryption-algorithm'];
87
	$pconfig['halgo'] = $a_phase1[$p1index]['hash-algorithm'];
88
	$pconfig['dhgroup'] = $a_phase1[$p1index]['dhgroup'];
89
	$pconfig['lifetime'] = $a_phase1[$p1index]['lifetime'];
90
	$pconfig['authentication_method'] = $a_phase1[$p1index]['authentication_method'];
91

    
92
	if (($pconfig['authentication_method'] == "pre_shared_key")||
93
		($pconfig['authentication_method'] == "xauth_psk_server")) {
94
		$pconfig['pskey'] = $a_phase1[$p1index]['pre-shared-key'];
95
	} else {
96
		$pconfig['certref'] = $a_phase1[$p1index]['certref'];
97
	}
98

    
99
	$pconfig['descr'] = $a_phase1[$p1index]['descr'];
100
	$pconfig['nat_traversal'] = $a_phase1[$p1index]['nat_traversal'];
101

    
102
	if ($a_phase1[$p1index]['dpd_delay'] &&	$a_phase1[$p1index]['dpd_maxfail']) {
103
		$pconfig['dpd_enable'] = true;
104
		$pconfig['dpd_delay'] = $a_phase1[$p1index]['dpd_delay'];
105
		$pconfig['dpd_maxfail'] = $a_phase1[$p1index]['dpd_maxfail'];
106
	}
107
}
108
else
109
{
110
	/* defaults */
111
	$pconfig['interface'] = "wan";
112
	if($config['interfaces']['lan']) 
113
		$pconfig['localnet'] = "lan";
114
	$pconfig['mode'] = "aggressive";
115
	$pconfig['myid_type'] = "myaddress";
116
	$pconfig['peerid_type'] = "peeraddress";
117
	$pconfig['authentication_method'] = "pre_shared_key";
118
	$pconfig['ealgo'] = array( name => "3des" );
119
	$pconfig['halgo'] = "sha1";
120
	$pconfig['dhgroup'] = "2";
121
	$pconfig['lifetime'] = "28800";
122
	$pconfig['nat_traversal'] = "on";
123
	$pconfig['dpd_enable'] = true;
124

    
125
	/* mobile client */
126
	if($_GET['mobile'])
127
		$pconfig['mobile']=true;
128
}
129

    
130
if (isset($_GET['dup']))
131
	unset($p1index);
132

    
133
if ($_POST) {
134
	unset($input_errors);
135
	$pconfig = $_POST;
136

    
137
	/* input validation */
138

    
139
	$method = $pconfig['authentication_method'];
140
	if (($method == "pre_shared_key")||($method == "xauth_psk_server")) {
141
		$reqdfields = explode(" ", "pskey");
142
		$reqdfieldsn = explode(",", "Pre-Shared Key");
143
	} else {
144
		$reqdfields = explode(" ", "certref");
145
		$reqdfieldsn = explode(",", "My Certificate");
146
	}
147
	if (!$pconfig['mobile']) {
148
		$reqdfields[] = "remotegw";
149
		$reqdfieldsn[] = "Remote gateway";
150
	}
151

    
152
	do_input_validation($pconfig, $reqdfields, $reqdfieldsn, &$input_errors);
153

    
154
	if (($pconfig['lifetime'] && !is_numeric($pconfig['lifetime'])))
155
		$input_errors[] = "The P1 lifetime must be an integer.";
156

    
157
	if (($pconfig['remotegw'] && !is_ipaddr($pconfig['remotegw']) && !is_domain($pconfig['remotegw']))) 
158
		$input_errors[] = "A valid remote gateway address or host name must be specified.";
159

    
160
	if (($pconfig['remotegw'] && is_ipaddr($pconfig['remotegw']) && !isset($pconfig['disabled']) )) {
161
		$t = 0;
162
		foreach ($a_phase1 as $ph1tmp) {
163
			if ($p1index <> $t) {
164
				$tremotegw = $pconfig['remotegw'];
165
				if (($ph1tmp['remote-gateway'] == $tremotegw) && !isset($ph1tmp['disabled'])) {
166
					$input_errors[] = "The remote gateway \"$tremotegw\" is already used by phase1 \"${ph1tmp['descr']}\".";
167
				}
168
			}
169
			$t++;
170
		}
171
	}
172

    
173
	/* My identity */
174

    
175
	if ($pconfig['myid_type'] == "myaddress")
176
		$pconfig['myid_data'] = "";
177

    
178
	if ($pconfig['myid_type'] == "address" and $pconfig['myid_data'] == "")
179
		$input_errors[] = gettext("Please enter an address for 'My Identifier'");
180

    
181
	if ($pconfig['myid_type'] == "keyid tag" and $pconfig['myid_data'] == "")
182
		$input_errors[] = gettext("Please enter a keyid tag for 'My Identifier'");
183

    
184
	if ($pconfig['myid_type'] == "fqdn" and $pconfig['myid_data'] == "")
185
		$input_errors[] = gettext("Please enter a fully qualified domain name for 'My Identifier'");
186

    
187
	if ($pconfig['myid_type'] == "user_fqdn" and $pconfig['myid_data'] == "")
188
		$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'My Identifier'");
189

    
190
	if ($pconfig['myid_type'] == "dyn_dns" and $pconfig['myid_data'] == "")
191
		$input_errors[] = gettext("Please enter a dynamic domain name for 'My Identifier'");
192

    
193
	if ((($pconfig['myid_type'] == "address") && !is_ipaddr($pconfig['myid_data'])))
194
		$input_errors[] = "A valid IP address for 'My identifier' must be specified.";
195

    
196
	if ((($pconfig['myid_type'] == "fqdn") && !is_domain($pconfig['myid_data'])))
197
		$input_errors[] = "A valid domain name for 'My identifier' must be specified.";
198

    
199
	if ($pconfig['myid_type'] == "fqdn")
200
		if (is_domain($pconfig['myid_data']) == false)
201
			$input_errors[] = "A valid FQDN for 'My identifier' must be specified.";
202

    
203
	if ($pconfig['myid_type'] == "user_fqdn") {
204
		$user_fqdn = explode("@",$pconfig['myid_data']);
205
		if (is_domain($user_fqdn[1]) == false)
206
			$input_errors[] = "A valid User FQDN in the form of user@my.domain.com for 'My identifier' must be specified.";
207
	}
208

    
209
	if ($pconfig['myid_type'] == "dyn_dns")
210
		if (is_domain($pconfig['myid_data']) == false)
211
			$input_errors[] = "A valid Dynamic DNS address for 'My identifier' must be specified.";
212

    
213
	/* Peer identity */
214

    
215
	if ($pconfig['myid_type'] == "peeraddress")
216
		$pconfig['peerid_data'] = "";
217

    
218
	if ($pconfig['peerid_type'] == "address" and $pconfig['peerid_data'] == "")
219
		$input_errors[] = gettext("Please enter an address for 'Peer Identifier'");
220

    
221
	if ($pconfig['peerid_type'] == "keyid tag" and $pconfig['peerid_data'] == "")
222
		$input_errors[] = gettext("Please enter a keyid tag for 'Peer Identifier'");
223

    
224
	if ($pconfig['peerid_type'] == "fqdn" and $pconfig['peerid_data'] == "")
225
		$input_errors[] = gettext("Please enter a fully qualified domain name for 'Peer Identifier'");
226

    
227
	if ($pconfig['peerid_type'] == "user_fqdn" and $pconfig['peerid_data'] == "")
228
		$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'Peer Identifier'");
229

    
230
	if ((($pconfig['peerid_type'] == "address") && !is_ipaddr($pconfig['peerid_data'])))
231
		$input_errors[] = "A valid IP address for 'Peer identifier' must be specified.";
232

    
233
	if ((($pconfig['peerid_type'] == "fqdn") && !is_domain($pconfig['peerid_data'])))
234
		$input_errors[] = "A valid domain name for 'Peer identifier' must be specified.";
235

    
236
	if ($pconfig['peerid_type'] == "fqdn")
237
		if (is_domain($pconfig['peerid_data']) == false)
238
			$input_errors[] = "A valid FQDN for 'Peer identifier' must be specified.";
239

    
240
	if ($pconfig['peerid_type'] == "user_fqdn") {
241
		$user_fqdn = explode("@",$pconfig['peerid_data']);
242
		if (is_domain($user_fqdn[1]) == false)
243
			$input_errors[] = "A valid User FQDN in the form of user@my.domain.com for 'Peer identifier' must be specified.";
244
	}
245

    
246
	if ($pconfig['dpd_enable']) {
247
		if (!is_numeric($pconfig['dpd_delay']))
248
			$input_errors[] = "A numeric value must be specified for DPD delay.";
249

    
250
		if (!is_numeric($pconfig['dpd_maxfail']))
251
			$input_errors[] = "A numeric value must be specified for DPD retries.";
252
	}
253

    
254
	/* build our encryption algorithms array */
255
	$pconfig['ealgo'] = array();
256
	$pconfig['ealgo']['name'] = $_POST['ealgo'];
257
	if($pconfig['ealgo_keylen'])
258
		$pconfig['ealgo']['keylen'] = $_POST['ealgo_keylen'];
259

    
260
	if (!$input_errors) {
261
		$ph1ent['ikeid'] = $pconfig['ikeid'];
262
		$ph1ent['disabled'] = $pconfig['disabled'] ? true : false;
263
		$ph1ent['interface'] = $pconfig['interface'];
264
		/* if the remote gateway changed and the interface is not WAN then remove route */
265
		/* the vpn_ipsec_configure() handles adding the route */
266
		if ($pconfig['interface'] <> "wan") {
267
			if($old_ph1ent['remote-gateway'] <> $pconfig['remotegw']) {
268
				mwexec("/sbin/route delete -host {$oldph1ent['remote-gateway']}");
269
			}
270
		}
271

    
272
		if ($pconfig['mobile'])
273
			$ph1ent['mobile'] = true;
274
		else
275
			$ph1ent['remote-gateway'] = $pconfig['remotegw'];
276

    
277
		$ph1ent['mode'] = $pconfig['mode'];
278

    
279
		$ph1ent['myid_type'] = $pconfig['myid_type'];
280
		$ph1ent['myid_data'] = $pconfig['myid_data'];
281
		$ph1ent['peerid_type'] = $pconfig['peerid_type'];
282
		$ph1ent['peerid_data'] = $pconfig['peerid_data'];
283

    
284
		$ph1ent['encryption-algorithm'] = $pconfig['ealgo'];
285
		$ph1ent['hash-algorithm'] = $pconfig['halgo'];
286
		$ph1ent['dhgroup'] = $pconfig['dhgroup'];
287
		$ph1ent['lifetime'] = $pconfig['lifetime'];
288
		$ph1ent['pre-shared-key'] = $pconfig['pskey'];
289
		$ph1ent['private-key'] = base64_encode($pconfig['privatekey']);
290
		$ph1ent['certref'] = $pconfig['certref'];
291
		$ph1ent['authentication_method'] = $pconfig['authentication_method'];
292

    
293
		$ph1ent['descr'] = $pconfig['descr'];
294
		$ph1ent['nat_traversal'] = $pconfig['nat_traversal'];
295

    
296
		if (isset($pconfig['dpd_enable'])) {
297
			$ph1ent['dpd_delay'] = $pconfig['dpd_delay'];
298
			$ph1ent['dpd_maxfail'] = $pconfig['dpd_maxfail'];
299
		}
300

    
301
		/* generate unique phase1 ikeid */
302
		if ($ph1ent['ikeid'] == 0)
303
			$ph1ent['ikeid'] = ipsec_ikeid_next();
304

    
305
		if (isset($p1index) && $a_phase1[$p1index])
306
			$a_phase1[$p1index] = $ph1ent;
307
		else
308
			$a_phase1[] = $ph1ent;
309

    
310
		/* now we need to find all phase2 entries for this host */
311
		if (is_array($a_phase2) && (count($a_phase2))) {
312
			foreach ($a_phase2 as $phase2) {
313
				if($phase2['ikeid'] == $ph1ent['ikeid']) {
314
					log_error("Reload {$ph1ent['descr']} tunnel(s)");
315
					$old_ph1ent['remote-gateway'] = resolve_retry($old_ph1ent['remote-gateway']);
316
					$old_phase2 = $phase2;
317
					reload_tunnel_spd_policy ($ph1ent, $phase2, $old_ph1ent, $old_phase2);
318
				}
319
			}
320
		}
321
		write_config();
322
		mark_subsystem_dirty('ipsec');
323

    
324
		header("Location: vpn_ipsec.php");
325
		exit;
326
	}
327
}
328

    
329
if ($pconfig['mobile'])
330
	$pgtitle = array("VPN","IPsec","Edit Phase 1", "Mobile Client");
331
else
332
	$pgtitle = array("VPN","IPsec","Edit Phase 1");
333

    
334
include("head.inc");
335

    
336
?>
337

    
338
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
339
<?php include("fbegin.inc"); ?>
340
<script language="JavaScript">
341
<!--
342

    
343
function myidsel_change() {
344
	index = document.iform.myid_type.selectedIndex;
345
	value = document.iform.myid_type.options[index].value;
346
	if (value == 'myaddress')
347
			document.getElementById('myid_data').style.visibility = 'hidden';
348
	else
349
			document.getElementById('myid_data').style.visibility = 'visible';
350
}
351

    
352
function peeridsel_change() {
353
	index = document.iform.peerid_type.selectedIndex;
354
	value = document.iform.peerid_type.options[index].value;
355
	if (value == 'peeraddress')
356
			document.getElementById('peerid_data').style.visibility = 'hidden';
357
	else
358
			document.getElementById('peerid_data').style.visibility = 'visible';
359
}
360

    
361
function methodsel_change() {
362
	index = document.iform.authentication_method.selectedIndex;
363
	value = document.iform.authentication_method.options[index].value;
364

    
365
	switch (value) {
366
		case 'hybrid_rsa_server':
367
			document.getElementById('opt_psk').style.display = 'none';
368
			document.getElementById('opt_cert').style.display = '';
369
			break;
370
		case 'xauth_rsa_server':
371
		case 'rsasig':
372
			document.getElementById('opt_psk').style.display = 'none';
373
			document.getElementById('opt_cert').style.display = '';
374
			break;
375
		default: /* psk modes*/
376
			document.getElementById('opt_psk').style.display = '';
377
			document.getElementById('opt_cert').style.display = 'none';
378
			break;
379
	}
380
}
381

    
382
/* PHP generated java script for variable length keys */
383
function ealgosel_change(bits) {
384
	switch (document.iform.ealgo.selectedIndex) {
385
<?php
386
  $i = 0;
387
  foreach ($p1_ealgos as $algo => $algodata) {
388
    if (is_array($algodata['keysel'])) {
389
      echo "		case {$i}:\n";
390
      echo "			document.iform.ealgo_keylen.style.visibility = 'visible';\n";
391
      echo "			document.iform.ealgo_keylen.options.length = 0;\n";
392
//      echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( 'auto', 'auto' );\n";
393

    
394
      $key_hi = $algodata['keysel']['hi'];
395
      $key_lo = $algodata['keysel']['lo'];
396
      $key_step = $algodata['keysel']['step'];
397

    
398
      for ($keylen = $key_hi; $keylen >= $key_lo; $keylen -= $key_step)
399
        echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( '{$keylen} bits', '{$keylen}' );\n";
400
      echo "			break;\n";
401
    } else {
402
      echo "		case {$i}:\n";
403
      echo "			document.iform.ealgo_keylen.style.visibility = 'hidden';\n";
404
      echo "			document.iform.ealgo_keylen.options.length = 0;\n";
405
      echo "			break;\n";
406
    }
407
    $i++;
408
  }
409
?>
410
	}
411

    
412
	if( bits )
413
		document.iform.ealgo_keylen.value = bits;
414
}
415

    
416
function dpdchkbox_change() {
417
	if( document.iform.dpd_enable.checked )
418
		document.getElementById('opt_dpd').style.display = '';
419
	else
420
		document.getElementById('opt_dpd').style.display = 'none';
421

    
422
	if (!document.iform.dpd_delay.value)
423
		document.iform.dpd_delay.value = "10";
424

    
425
	if (!document.iform.dpd_maxfail.value)
426
		document.iform.dpd_maxfail.value = "5";
427
}
428

    
429
//-->
430
</script>
431

    
432
<form action="vpn_ipsec_phase1.php" method="post" name="iform" id="iform">
433

    
434
<?php
435
	if ($input_errors)
436
		print_input_errors($input_errors);
437
?>
438

    
439
<table width="100%" border="0" cellpadding="0" cellspacing="0">
440
	<tr class="tabnavtbl">
441
		<td id="tabnav">
442
			<?php
443
				$tab_array = array();
444
				$tab_array[0] = array("Tunnels", true, "vpn_ipsec.php");
445
				$tab_array[1] = array("Mobile clients", false, "vpn_ipsec_mobile.php");
446
				display_top_tabs($tab_array);
447
			?>
448
		</td>
449
	</tr>
450
	<tr>
451
		<td id="mainarea">
452
			<div class="tabcont">
453
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
454
					<tr>
455
						<td colspan="2" valign="top" class="listtopic">General information</td>
456
					</tr>
457
					<tr>
458
						<td width="22%" valign="top" class="vncellreq">Disabled</td>
459
						<td width="78%" class="vtable">
460
							<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
461
							<strong>Disable this phase1 entry</strong><br>
462
							<span class="vexpl">
463
								Set this option to disable this phase1 without
464
								removing it from the list.
465
							</span>
466
						</td>
467
					</tr>
468
					<tr>
469
						<td width="22%" valign="top" class="vncellreq">Interface</td>
470
						<td width="78%" class="vtable">
471
							<select name="interface" class="formselect">
472
							<?php 
473
								$interfaces = get_configured_interface_with_descr();
474
								$carpips = find_number_of_needed_carp_interfaces();
475
								for ($i=0; $i<$carpips; $i++) {
476
									$carpip = find_interface_ip("carp" . $i);
477
									$interfaces['carp' . $i] = "CARP{$i} ({$carpip})"; 
478
								}
479
								foreach ($interfaces as $iface => $ifacename):
480
							?>
481
								<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
482
									<?=htmlspecialchars($ifacename);?>
483
								</option>
484
							<?php endforeach; ?>
485
							</select>
486
							<br>
487
							<span class="vexpl">Select the interface for the local endpoint of this phase1 entry.</span>
488
						</td>
489
					</tr>
490

    
491
					<?php if (!$pconfig['mobile']): ?>
492

    
493
					<tr>
494
						<td width="22%" valign="top" class="vncellreq">Remote gateway</td>
495
						<td width="78%" class="vtable">
496
							<?=$mandfldhtml;?><input name="remotegw" type="text" class="formfld unknown" id="remotegw" size="20" value="<?=$pconfig['remotegw'];?>">
497
							<br>
498
							Enter the public IP address or host name of the remote gateway
499
						</td>
500
					</tr>
501

    
502
					<?php endif; ?>
503

    
504
					<tr>
505
						<td width="22%" valign="top" class="vncell">Description</td>
506
						<td width="78%" class="vtable">
507
							<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
508
							<br>
509
							<span class="vexpl">
510
								You may enter a description here
511
								for your reference (not parsed).
512
							</span>
513
						</td>
514
					</tr>
515
					<tr>
516
						<td colspan="2" class="list" height="12"></td>
517
					</tr>
518
					<tr>
519
						<td colspan="2" valign="top" class="listtopic">
520
							Phase 1 proposal (Authentication)
521
						</td>
522
					</tr>
523
					<tr>
524
						<td width="22%" valign="top" class="vncellreq">Negotiation mode</td>
525
						<td width="78%" class="vtable">
526
							<select name="mode" class="formselect">
527
							<?php
528
								$modes = explode(" ", "main aggressive");
529
								foreach ($modes as $mode):
530
							?>
531
								<option value="<?=$mode;?>" <?php if ($mode == $pconfig['mode']) echo "selected"; ?>>
532
									<?=htmlspecialchars($mode);?>
533
								</option>
534
							<?php endforeach; ?>
535
							</select> <br> <span class="vexpl">Aggressive is more flexible, but less secure.</span>
536
						</td>
537
					</tr>
538
					<tr>
539
						<td width="22%" valign="top" class="vncellreq">My identifier</td>
540
						<td width="78%" class="vtable">
541
							<select name="myid_type" class="formselect" onChange="myidsel_change()">
542
							<?php foreach ($my_identifier_list as $id_type => $id_params): ?>
543
								<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['myid_type']) echo "selected"; ?>>
544
									<?=htmlspecialchars($id_params['desc']);?>
545
								</option>
546
							<?php endforeach; ?>
547
							</select>
548
							<input name="myid_data" type="text" class="formfld unknown" id="myid_data" size="30" value="<?=$pconfig['myid_data'];?>">
549
						</td>
550
					</tr>
551
					<tr>
552
						<td width="22%" valign="top" class="vncellreq">Peer identifier</td>
553
						<td width="78%" class="vtable">
554
							<select name="peerid_type" class="formselect" onChange="peeridsel_change()">
555
							<?php
556
								foreach ($peer_identifier_list as $id_type => $id_params):
557
									if ($pconfig['mobile'] && !$id_params['mobile'])
558
										continue;
559
							?>
560
							<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['peerid_type']) echo "selected"; ?>>
561
								<?=htmlspecialchars($id_params['desc']);?>
562
							</option>
563
							<?php endforeach; ?>
564
							</select>
565
							<input name="peerid_data" type="text" class="formfld unknown" id="peerid_data" size="30" value="<?=$pconfig['peerid_data'];?>">
566
						</td>
567
					</tr>
568
					<tr>
569
						<td width="22%" valign="top" class="vncellreq">Encryption algorithm</td>
570
						<td width="78%" class="vtable">
571
							<select name="ealgo" class="formselect" onChange="ealgosel_change()">
572
							<?php
573
								foreach ($p1_ealgos as $algo => $algodata):
574
									$selected = '';
575
									if ($algo == $pconfig['ealgo']['name'])
576
										$selected = ' selected';
577
							?>
578
								<option value="<?=$algo;?>"<?=$selected?>>
579
									<?=htmlspecialchars($algodata['name']);?>
580
								</option>
581
							<?php endforeach; ?>
582
							</select>
583
							<select name="ealgo_keylen" width="30" class="formselect">
584
							</select>
585
						</td>
586
					</tr>
587
					<tr>
588
						<td width="22%" valign="top" class="vncellreq">Hash algorithm</td>
589
						<td width="78%" class="vtable">
590
							<select name="halgo" class="formselect">
591
							<?php foreach ($p1_halgos as $algo => $algoname): ?>
592
								<option value="<?=$algo;?>" <?php if ($algo == $pconfig['halgo']) echo "selected"; ?>>
593
									<?=htmlspecialchars($algoname);?>
594
								</option>
595
							<?php endforeach; ?>
596
							</select>
597
							<br>
598
							<span class="vexpl">
599
								Must match the setting chosen on the remote side.
600
							</span>
601
						</td>
602
					</tr>
603
					<tr>
604
						<td width="22%" valign="top" class="vncellreq">DH key group</td>
605
						<td width="78%" class="vtable">
606
							<select name="dhgroup" class="formselect">
607
							<?php $keygroups = explode(" ", "1 2 5"); foreach ($keygroups as $keygroup): ?>
608
								<option value="<?=$keygroup;?>" <?php if ($keygroup == $pconfig['dhgroup']) echo "selected"; ?>>
609
									<?=htmlspecialchars($keygroup);?>
610
								</option>
611
							<?php endforeach; ?>
612
							</select>
613
							<br>
614
							<span class="vexpl">
615
								<em>1 = 768 bit, 2 = 1024 bit, 5 = 1536 bit</em>
616
								<br>
617
								Must match the setting chosen on the remote side.
618
							</span>
619
						</td>
620
					</tr>
621
					<tr>
622
						<td width="22%" valign="top" class="vncell">Lifetime</td>
623
						<td width="78%" class="vtable">
624
							<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="20" value="<?=$pconfig['lifetime'];?>">
625
							seconds
626
						</td>
627
					</tr>
628
					<tr>
629
						<td width="22%" valign="top" class="vncellreq">Authentication method</td>
630
						<td width="78%" class="vtable">
631
							<select name="authentication_method" class="formselect" onChange="methodsel_change()">
632
							<?php
633
								foreach ($p1_authentication_methods as $method_type => $method_params):
634
									if (!$pconfig['mobile'] && $method_params['mobile'])
635
										continue;
636
							?>
637
								<option value="<?=$method_type;?>" <?php if ($method_type == $pconfig['authentication_method']) echo "selected"; ?>>
638
									<?=htmlspecialchars($method_params['name']);?>
639
								</option>
640
							<?php endforeach; ?>
641
							</select>
642
							<br>
643
							<span class="vexpl">
644
								Must match the setting chosen on the remote side.
645
							</span>
646
						</td>
647
					</tr>
648
					<tr id="opt_psk">
649
						<td width="22%" valign="top" class="vncellreq">Pre-Shared Key</td>
650
						<td width="78%" class="vtable">
651
							<?=$mandfldhtml;?>
652
							<input name="pskey" type="text" class="formfld unknown" id="pskey" size="40" value="<?=htmlspecialchars($pconfig['pskey']);?>">
653
							<span class="vexpl">
654
							<br>
655
								Input your pre-shared key string.
656
							</span>
657
						</td>
658
					</tr>
659
					<tr id="opt_cert">
660
						<td width="22%" valign="top" class="vncellreq">My Certificate</td>
661
						<td width="78%" class="vtable">
662
							<select name='certref' class="formselect">
663
							<?php
664
								foreach ($config['system']['cert'] as $cert):
665
									$selected = "";
666
									if ($pconfig['certref'] == $cert['refid'])
667
										$selected = "selected";
668
							?>
669
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['name'];?></option>
670
							<?php endforeach; ?>
671
							</select>
672
							<br>
673
							<span class="vexpl">
674
								Select a certificate previously configured in the Certificate Manager.
675
							</span>
676
						</td>
677
					</tr>
678
					<tr>
679
						<td colspan="2" class="list" height="12"></td>
680
					</tr>
681
					<tr>
682
						<td colspan="2" valign="top" class="listtopic">Advanced Options</td>
683
					</tr>
684
					<tr>
685
						<td width="22%" valign="top" class="vncell">NAT Traversal</td>
686
						<td width="78%" class="vtable">
687
							<select name="nat_traversal" class="formselect">
688
								<option value="off" <?php if ($pconfig['nat_traversal'] == "off") echo "selected"; ?>>Disable</option>
689
								<option value="on" <?php if ($pconfig['nat_traversal'] == "on") echo "selected"; ?>>Enable</option>
690
								<option value="force" <?php if ($pconfig['nat_traversal'] == "force") echo "selected"; ?>>Force</option>
691
							</select>
692
							<br/>
693
							<span class="vexpl">
694
								Set this option to enable the use of NAT-T (i.e. the encapsulation of ESP in UDP packets) if needed,
695
								which can help with clients that are behind restrictive firewalls.
696
							</span>
697
						</td>
698
					</tr>
699
					<tr>
700
						<td width="22%" valign="top" class="vncell">Dead Peer Detection</td>
701
						<td width="78%" class="vtable">
702
							<input name="dpd_enable" type="checkbox" id="dpd_enable" value="yes" <?php if (isset($pconfig['dpd_enable'])) echo "checked"; ?> onClick="dpdchkbox_change()">
703
							Enable DPD<br>
704
							<div id="opt_dpd">
705
								<br>
706
								<input name="dpd_delay" type="text" class="formfld unknown" id="dpd_delay" size="5" value="<?=$pconfig['dpd_delay'];?>">
707
								seconds<br>
708
								<span class="vexpl">
709
									Delay between requesting peer acknowledgement.
710
								</span><br>
711
								<br>
712
								<input name="dpd_maxfail" type="text" class="formfld unknown" id="dpd_maxfail" size="5" value="<?=$pconfig['dpd_maxfail'];?>">
713
								retries<br>
714
								<span class="vexpl">
715
									Number of consecutive failures allowed before disconnect.
716
								</span>
717
								<br>
718
							</div>
719
						</td>
720
					</tr>
721
					<tr>
722
						<td width="22%" valign="top">&nbsp;</td>
723
						<td width="78%">
724
							<?php if (isset($p1index) && $a_phase1[$p1index]): ?>
725
							<input name="p1index" type="hidden" value="<?=$p1index;?>">
726
							<?php endif; ?>
727
							<?php if ($pconfig['mobile']): ?>
728
							<input name="mobile" type="hidden" value="true">
729
							<?php endif; ?>
730
							<input name="ikeid" type="hidden" value="<?=$pconfig['ikeid'];?>">
731
							<input name="Submit" type="submit" class="formbtn" value="Save">
732
						</td>
733
					</tr>
734
				</table>
735
			</div>
736
		</td>
737
	</tr>
738
</table>
739
</form>
740

    
741
<script lannguage="JavaScript">
742
<!--
743
<?php
744
	/* determine if we should init the key length */
745
	$keyset = '';
746
	if (isset($pconfig['ealgo']['keylen']))
747
		if (is_numeric($pconfig['ealgo']['keylen']))
748
			$keyset = $pconfig['ealgo']['keylen'];
749
?>
750
myidsel_change();
751
peeridsel_change();
752
methodsel_change();
753
ealgosel_change(<?=$keyset;?>);
754
dpdchkbox_change();
755
//-->
756
</script>
757
<?php include("fend.inc"); ?>
758
</body>
759
</html>
(202-202/217)