Project

General

Profile

Download (32.9 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
require_once("ipsec.inc");
42
require_once("vpn.inc");
43

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

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

    
50
$a_phase1 = &$config['ipsec']['phase1'];
51
$a_phase2 = &$config['ipsec']['phase2'];
52

    
53
$p1index = $_GET['p1index'];
54
if (isset($_POST['p1index']))
55
	$p1index = $_POST['p1index'];
56

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

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

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

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

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

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

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

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

    
95
	if (($pconfig['authentication_method'] == "pre_shared_key") || 
96
		($pconfig['authentication_method'] == "xauth_psk_server")) {
97
		$pconfig['pskey'] = $a_phase1[$p1index]['pre-shared-key'];
98
	} else {
99
		$pconfig['certref'] = $a_phase1[$p1index]['certref'];
100
		$pconfig['caref'] = $a_phase1[$p1index]['caref'];
101
	}
102

    
103
	$pconfig['descr'] = $a_phase1[$p1index]['descr'];
104
	$pconfig['nat_traversal'] = $a_phase1[$p1index]['nat_traversal'];
105

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

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

    
132
if (isset($_GET['dup']))
133
	unset($p1index);
134

    
135
if ($_POST) {
136
	unset($input_errors);
137
	$pconfig = $_POST;
138

    
139
	/* input validation */
140

    
141
	$method = $pconfig['authentication_method'];
142

    
143
	// Only require PSK here for normal PSK tunnels (not mobile) or xauth.
144
	// For RSA methods, require the CA/Cert.
145
	switch ($method) {
146
		case "pre_shared_key":
147
			// If this is a mobile PSK tunnel the user PSKs go on 
148
			//    the PSK tab, not here, so skip the check.
149
			if ($pconfig['mobile'])
150
				break;
151
		case "xauth_psk_server":
152
			$reqdfields = explode(" ", "pskey");
153
			$reqdfieldsn = array(gettext("Pre-Shared Key"));
154
			break;
155
		case "hybrid_rsa_server":
156
		case "xauth_rsa_server":
157
		case "rsasig":
158
			$reqdfields = explode(" ", "caref certref");
159
			$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
160
			break;
161
	}
162
	if (!$pconfig['mobile']) {
163
		$reqdfields[] = "remotegw";
164
		$reqdfieldsn[] = gettext("Remote gateway");
165
	}
166

    
167
	do_input_validation($pconfig, $reqdfields, $reqdfieldsn, &$input_errors);
168

    
169
	if (($pconfig['lifetime'] && !is_numeric($pconfig['lifetime'])))
170
		$input_errors[] = gettext("The P1 lifetime must be an integer.");
171

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

    
175
	if (($pconfig['remotegw'] && is_ipaddr($pconfig['remotegw']) && !isset($pconfig['disabled']) )) {
176
		$t = 0;
177
		foreach ($a_phase1 as $ph1tmp) {
178
			if ($p1index <> $t) {
179
				$tremotegw = $pconfig['remotegw'];
180
				if (($ph1tmp['remote-gateway'] == $tremotegw) && !isset($ph1tmp['disabled'])) {
181
					$input_errors[] = sprintf(gettext('The remote gateway "%1$s" is already used by phase1 "%2$s".'), $tremotegw, $ph1tmp['descr']);
182
				}
183
			}
184
			$t++;
185
		}
186
	}
187

    
188
	/* My identity */
189

    
190
	if ($pconfig['myid_type'] == "myaddress")
191
		$pconfig['myid_data'] = "";
192

    
193
	if ($pconfig['myid_type'] == "address" and $pconfig['myid_data'] == "")
194
		$input_errors[] = gettext("Please enter an address for 'My Identifier'");
195

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

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

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

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

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

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

    
214
	if ($pconfig['myid_type'] == "fqdn")
215
		if (is_domain($pconfig['myid_data']) == false)
216
			$input_errors[] = gettext("A valid FQDN for 'My identifier' must be specified.");
217

    
218
	if ($pconfig['myid_type'] == "user_fqdn") {
219
		$user_fqdn = explode("@",$pconfig['myid_data']);
220
		if (is_domain($user_fqdn[1]) == false)
221
			$input_errors[] = gettext("A valid User FQDN in the form of user@my.domain.com for 'My identifier' must be specified.");
222
	}
223

    
224
	if ($pconfig['myid_type'] == "dyn_dns")
225
		if (is_domain($pconfig['myid_data']) == false)
226
			$input_errors[] = gettext("A valid Dynamic DNS address for 'My identifier' must be specified.");
227

    
228
	/* Peer identity */
229

    
230
	if ($pconfig['myid_type'] == "peeraddress")
231
		$pconfig['peerid_data'] = "";
232

    
233
	// Only enforce peer ID if we are not dealing with a pure-psk mobile config.
234
	if (!(($pconfig['authentication_method'] == "pre_shared_key") && ($pconfig['mobile']))) {
235
		if ($pconfig['peerid_type'] == "address" and $pconfig['peerid_data'] == "")
236
			$input_errors[] = gettext("Please enter an address for 'Peer Identifier'");
237

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

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

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

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

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

    
253
		if ($pconfig['peerid_type'] == "fqdn")
254
			if (is_domain($pconfig['peerid_data']) == false)
255
				$input_errors[] = gettext("A valid FQDN for 'Peer identifier' must be specified.");
256

    
257
		if ($pconfig['peerid_type'] == "user_fqdn") {
258
			$user_fqdn = explode("@",$pconfig['peerid_data']);
259
			if (is_domain($user_fqdn[1]) == false)
260
				$input_errors[] = gettext("A valid User FQDN in the form of user@my.domain.com for 'Peer identifier' must be specified.");
261
		}
262
	}
263

    
264
	if ($pconfig['dpd_enable']) {
265
		if (!is_numeric($pconfig['dpd_delay']))
266
			$input_errors[] = gettext("A numeric value must be specified for DPD delay.");
267

    
268
		if (!is_numeric($pconfig['dpd_maxfail']))
269
			$input_errors[] = gettext("A numeric value must be specified for DPD retries.");
270
	}
271

    
272
	/* build our encryption algorithms array */
273
	$pconfig['ealgo'] = array();
274
	$pconfig['ealgo']['name'] = $_POST['ealgo'];
275
	if($pconfig['ealgo_keylen'])
276
		$pconfig['ealgo']['keylen'] = $_POST['ealgo_keylen'];
277

    
278
	if (!$input_errors) {
279
		$ph1ent['ikeid'] = $pconfig['ikeid'];
280
		$ph1ent['disabled'] = $pconfig['disabled'] ? true : false;
281
		$ph1ent['interface'] = $pconfig['interface'];
282
		/* if the remote gateway changed and the interface is not WAN then remove route */
283
		/* the vpn_ipsec_configure() handles adding the route */
284
		if ($pconfig['interface'] <> "wan") {
285
			if($old_ph1ent['remote-gateway'] <> $pconfig['remotegw']) {
286
				mwexec("/sbin/route delete -host {$old_ph1ent['remote-gateway']}");
287
			}
288
		}
289

    
290
		if ($pconfig['mobile'])
291
			$ph1ent['mobile'] = true;
292
		else
293
			$ph1ent['remote-gateway'] = $pconfig['remotegw'];
294

    
295
		$ph1ent['mode'] = $pconfig['mode'];
296

    
297
		$ph1ent['myid_type'] = $pconfig['myid_type'];
298
		$ph1ent['myid_data'] = $pconfig['myid_data'];
299
		$ph1ent['peerid_type'] = $pconfig['peerid_type'];
300
		$ph1ent['peerid_data'] = $pconfig['peerid_data'];
301

    
302
		$ph1ent['encryption-algorithm'] = $pconfig['ealgo'];
303
		$ph1ent['hash-algorithm'] = $pconfig['halgo'];
304
		$ph1ent['dhgroup'] = $pconfig['dhgroup'];
305
		$ph1ent['lifetime'] = $pconfig['lifetime'];
306
		$ph1ent['pre-shared-key'] = $pconfig['pskey'];
307
		$ph1ent['private-key'] = base64_encode($pconfig['privatekey']);
308
		$ph1ent['certref'] = $pconfig['certref'];
309
		$ph1ent['caref'] = $pconfig['caref'];
310
		$ph1ent['authentication_method'] = $pconfig['authentication_method'];
311
		$ph1ent['generate_policy'] = $pconfig['generate_policy'];
312
		$ph1ent['proposal_check'] = $pconfig['proposal_check'];
313
		$ph1ent['descr'] = $pconfig['descr'];
314
		$ph1ent['nat_traversal'] = $pconfig['nat_traversal'];
315

    
316
		if (isset($pconfig['dpd_enable'])) {
317
			$ph1ent['dpd_delay'] = $pconfig['dpd_delay'];
318
			$ph1ent['dpd_maxfail'] = $pconfig['dpd_maxfail'];
319
		}
320

    
321
		/* generate unique phase1 ikeid */
322
		if ($ph1ent['ikeid'] == 0)
323
			$ph1ent['ikeid'] = ipsec_ikeid_next();
324

    
325
		if (isset($p1index) && $a_phase1[$p1index])
326
			$a_phase1[$p1index] = $ph1ent;
327
		else
328
			$a_phase1[] = $ph1ent;
329

    
330
		/* now we need to find all phase2 entries for this host */
331
		if (is_array($a_phase2) && (count($a_phase2))) {
332
			foreach ($a_phase2 as $phase2) {
333
				if($phase2['ikeid'] == $ph1ent['ikeid']) {
334
					log_error("Reload {$ph1ent['descr']} tunnel(s)");
335
					$old_ph1ent['remote-gateway'] = resolve_retry($old_ph1ent['remote-gateway']);
336
					$old_phase2 = $phase2;
337
					reload_tunnel_spd_policy ($ph1ent, $phase2, $old_ph1ent, $old_phase2);
338
				}
339
			}
340
		}
341
		write_config();
342
		mark_subsystem_dirty('ipsec');
343

    
344
		header("Location: vpn_ipsec.php");
345
		exit;
346
	}
347
}
348

    
349
if ($pconfig['mobile'])
350
	$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1"), gettext("Mobile Client"));
351
else
352
	$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1"));
353
$statusurl = "diag_ipsec.php";
354
$logurl = "diag_logs_ipsec.php";
355

    
356

    
357
include("head.inc");
358

    
359
?>
360

    
361
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
362
<?php include("fbegin.inc"); ?>
363
<script language="JavaScript">
364
<!--
365

    
366
function myidsel_change() {
367
	index = document.iform.myid_type.selectedIndex;
368
	value = document.iform.myid_type.options[index].value;
369
	if (value == 'myaddress')
370
			document.getElementById('myid_data').style.visibility = 'hidden';
371
	else
372
			document.getElementById('myid_data').style.visibility = 'visible';
373
}
374

    
375
function peeridsel_change() {
376
	index = document.iform.peerid_type.selectedIndex;
377
	value = document.iform.peerid_type.options[index].value;
378
	if (value == 'peeraddress')
379
			document.getElementById('peerid_data').style.visibility = 'hidden';
380
	else
381
			document.getElementById('peerid_data').style.visibility = 'visible';
382
}
383

    
384
function methodsel_change() {
385
	index = document.iform.authentication_method.selectedIndex;
386
	value = document.iform.authentication_method.options[index].value;
387

    
388
	switch (value) {
389
		case 'hybrid_rsa_server':
390
			document.getElementById('opt_psk').style.display = 'none';
391
			document.getElementById('opt_peerid').style.display = '';
392
			document.getElementById('opt_cert').style.display = '';
393
			document.getElementById('opt_ca').style.display = '';
394
			document.getElementById('opt_cert').disabled = false;
395
			document.getElementById('opt_ca').disabled = false;
396
			break;
397
		case 'xauth_rsa_server':
398
		case 'rsasig':
399
			document.getElementById('opt_psk').style.display = 'none';
400
			document.getElementById('opt_peerid').style.display = '';
401
			document.getElementById('opt_cert').style.display = '';
402
			document.getElementById('opt_ca').style.display = '';
403
			document.getElementById('opt_cert').disabled = false;
404
			document.getElementById('opt_ca').disabled = false;
405
			break;
406
<?php if ($pconfig['mobile']) { ?>
407
		case 'pre_shared_key':
408
			document.getElementById('opt_psk').style.display = 'none';
409
			document.getElementById('opt_peerid').style.display = 'none';
410
			document.getElementById('opt_cert').style.display = 'none';
411
			document.getElementById('opt_ca').style.display = 'none';
412
			document.getElementById('opt_cert').disabled = true;
413
			document.getElementById('opt_ca').disabled = true;
414
			break;
415
<?php } ?>
416
		default: /* psk modes*/
417
			document.getElementById('opt_psk').style.display = '';
418
			document.getElementById('opt_peerid').style.display = '';
419
			document.getElementById('opt_cert').style.display = 'none';
420
			document.getElementById('opt_ca').style.display = 'none';
421
			document.getElementById('opt_cert').disabled = true;
422
			document.getElementById('opt_ca').disabled = true;
423
			break;
424
	}
425
}
426

    
427
/* PHP generated java script for variable length keys */
428
function ealgosel_change(bits) {
429
	switch (document.iform.ealgo.selectedIndex) {
430
<?php
431
  $i = 0;
432
  foreach ($p1_ealgos as $algo => $algodata) {
433
    if (is_array($algodata['keysel'])) {
434
      echo "		case {$i}:\n";
435
      echo "			document.iform.ealgo_keylen.style.visibility = 'visible';\n";
436
      echo "			document.iform.ealgo_keylen.options.length = 0;\n";
437
//      echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( 'auto', 'auto' );\n";
438

    
439
      $key_hi = $algodata['keysel']['hi'];
440
      $key_lo = $algodata['keysel']['lo'];
441
      $key_step = $algodata['keysel']['step'];
442

    
443
      for ($keylen = $key_hi; $keylen >= $key_lo; $keylen -= $key_step)
444
        echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( '{$keylen} bits', '{$keylen}' );\n";
445
      echo "			break;\n";
446
    } else {
447
      echo "		case {$i}:\n";
448
      echo "			document.iform.ealgo_keylen.style.visibility = 'hidden';\n";
449
      echo "			document.iform.ealgo_keylen.options.length = 0;\n";
450
      echo "			break;\n";
451
    }
452
    $i++;
453
  }
454
?>
455
	}
456

    
457
	if( bits )
458
		document.iform.ealgo_keylen.value = bits;
459
}
460

    
461
function dpdchkbox_change() {
462
	if( document.iform.dpd_enable.checked )
463
		document.getElementById('opt_dpd').style.display = '';
464
	else
465
		document.getElementById('opt_dpd').style.display = 'none';
466

    
467
	if (!document.iform.dpd_delay.value)
468
		document.iform.dpd_delay.value = "10";
469

    
470
	if (!document.iform.dpd_maxfail.value)
471
		document.iform.dpd_maxfail.value = "5";
472
}
473

    
474
//-->
475
</script>
476

    
477
<form action="vpn_ipsec_phase1.php" method="post" name="iform" id="iform">
478

    
479
<?php
480
	if ($input_errors)
481
		print_input_errors($input_errors);
482
?>
483

    
484
<table width="100%" border="0" cellpadding="0" cellspacing="0">
485
	<tr class="tabnavtbl">
486
		<td id="tabnav">
487
			<?php
488
				$tab_array = array();
489
				$tab_array[0] = array(gettext("Tunnels"), true, "vpn_ipsec.php");
490
				$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
491
				$tab_array[2] = array(gettext("Pre-shared keys"), false, "vpn_ipsec_keys.php");
492
				display_top_tabs($tab_array);
493
			?>
494
		</td>
495
	</tr>
496
	<tr>
497
		<td id="mainarea">
498
			<div class="tabcont">
499
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
500
					<tr>
501
						<td colspan="2" valign="top" class="listtopic"><?=gettext("General information"); ?></td>
502
					</tr>
503
					<tr>
504
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
505
						<td width="78%" class="vtable">
506
							<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
507
							<strong><?=gettext("Disable this phase1 entry"); ?></strong><br>
508
							<span class="vexpl">
509
								<?=gettext("Set this option to disable this phase1 without " .
510
								"removing it from the list"); ?>.
511
							</span>
512
						</td>
513
					</tr>
514
					<tr>
515
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
516
						<td width="78%" class="vtable">
517
							<select name="interface" class="formselect">
518
							<?php 
519
								$interfaces = get_configured_interface_with_descr();
520
								$carplist = get_configured_carp_interface_list();
521
								foreach ($carplist as $cif => $carpip)
522
									$interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")";
523
								$aliaslist = get_configured_ip_aliases_list();
524
								foreach ($aliaslist as $aliasip => $aliasif)
525
									$interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
526
								foreach ($interfaces as $iface => $ifacename):
527
							?>
528
								<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
529
									<?=htmlspecialchars($ifacename);?>
530
								</option>
531
							<?php endforeach; ?>
532
							</select>
533
							<br>
534
							<span class="vexpl"><?=gettext("Select the interface for the local endpoint of this phase1 entry"); ?>.</span>
535
						</td>
536
					</tr>
537

    
538
					<?php if (!$pconfig['mobile']): ?>
539

    
540
					<tr>
541
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote gateway"); ?></td>
542
						<td width="78%" class="vtable">
543
							<?=$mandfldhtml;?><input name="remotegw" type="text" class="formfld unknown" id="remotegw" size="20" value="<?=htmlspecialchars($pconfig['remotegw']);?>">
544
							<br>
545
							<?=gettext("Enter the public IP address or host name of the remote gateway"); ?>
546
						</td>
547
					</tr>
548

    
549
					<?php endif; ?>
550

    
551
					<tr>
552
						<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
553
						<td width="78%" class="vtable">
554
							<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
555
							<br>
556
							<span class="vexpl">
557
								<?=gettext("You may enter a description here " .
558
								"for your reference (not parsed)"); ?>.
559
							</span>
560
						</td>
561
					</tr>
562
					<tr>
563
						<td colspan="2" class="list" height="12"></td>
564
					</tr>
565
					<tr>
566
						<td colspan="2" valign="top" class="listtopic">
567
							<?=gettext("Phase 1 proposal (Authentication)"); ?>
568
						</td>
569
					</tr>
570
					<tr>
571
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication method"); ?></td>
572
						<td width="78%" class="vtable">
573
							<select name="authentication_method" class="formselect" onChange="methodsel_change()">
574
							<?php
575
								foreach ($p1_authentication_methods as $method_type => $method_params):
576
									if (!$pconfig['mobile'] && $method_params['mobile'])
577
										continue;
578
							?>
579
								<option value="<?=$method_type;?>" <?php if ($method_type == $pconfig['authentication_method']) echo "selected"; ?>>
580
									<?=htmlspecialchars($method_params['name']);?>
581
								</option>
582
							<?php endforeach; ?>
583
							</select>
584
							<br>
585
							<span class="vexpl">
586
								<?=gettext("Must match the setting chosen on the remote side"); ?>.
587
							</span>
588
						</td>
589
					</tr>
590
					<tr>
591
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Negotiation mode"); ?></td>
592
						<td width="78%" class="vtable">
593
							<select name="mode" class="formselect">
594
							<?php
595
								$modes = array(gettext("main"),gettext("aggressive"));
596
								foreach ($modes as $mode):
597
							?>
598
								<option value="<?=$mode;?>" <?php if ($mode == $pconfig['mode']) echo "selected"; ?>>
599
									<?=htmlspecialchars($mode);?>
600
								</option>
601
							<?php endforeach; ?>
602
							</select> <br> <span class="vexpl"><?=gettext("Aggressive is more flexible, but less secure"); ?>.</span>
603
						</td>
604
					</tr>
605
					<tr>
606
						<td width="22%" valign="top" class="vncellreq"><?=gettext("My identifier"); ?></td>
607
						<td width="78%" class="vtable">
608
							<select name="myid_type" class="formselect" onChange="myidsel_change()">
609
							<?php foreach ($my_identifier_list as $id_type => $id_params): ?>
610
								<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['myid_type']) echo "selected"; ?>>
611
									<?=htmlspecialchars($id_params['desc']);?>
612
								</option>
613
							<?php endforeach; ?>
614
							</select>
615
							<input name="myid_data" type="text" class="formfld unknown" id="myid_data" size="30" value="<?=htmlspecialchars($pconfig['myid_data']);?>">
616
						</td>
617
					</tr>
618
					<tr id="opt_peerid">
619
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer identifier"); ?></td>
620
						<td width="78%" class="vtable">
621
							<select name="peerid_type" class="formselect" onChange="peeridsel_change()">
622
							<?php
623
								foreach ($peer_identifier_list as $id_type => $id_params):
624
									if ($pconfig['mobile'] && !$id_params['mobile'])
625
										continue;
626
							?>
627
							<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['peerid_type']) echo "selected"; ?>>
628
								<?=htmlspecialchars($id_params['desc']);?>
629
							</option>
630
							<?php endforeach; ?>
631
							</select>
632
							<input name="peerid_data" type="text" class="formfld unknown" id="peerid_data" size="30" value="<?=htmlspecialchars($pconfig['peerid_data']);?>">
633
						<?php if ($pconfig['mobile']) { ?>
634
							<br/><br/><?=gettext("NOTE: This is known as the \"group\" setting on some VPN client implementations"); ?>.
635
						<?php } ?>
636
						</td>
637
					</tr>
638
					<tr id="opt_psk">
639
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Pre-Shared Key"); ?></td>
640
						<td width="78%" class="vtable">
641
							<?=$mandfldhtml;?>
642
							<input name="pskey" type="text" class="formfld unknown" id="pskey" size="40" value="<?=htmlspecialchars($pconfig['pskey']);?>">
643
							<span class="vexpl">
644
							<br>
645
								<?=gettext("Input your pre-shared key string"); ?>.
646
							</span>
647
						</td>
648
					</tr>
649
					<tr id="generate_policy">
650
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Policy Generation"); ?></td>
651
						<td width="78%" class="vtable">
652
							<select name="generate_policy" class="formselect">
653
								<option value="" <?php if (empty($pconfig['generate_policy'])) echo "selected"; ?>>Default</option>
654
								<option value="on" <?php if ($pconfig['generate_policy'] == "on") echo "selected"; ?>>On</option>
655
								<option value="off" <?php if ($pconfig['generate_policy'] == "off") echo "selected"; ?>>Off</option>
656
								<option value="require" <?php if ($pconfig['generate_policy'] == "require") echo "selected"; ?>>Require</option>
657
								<option value="unique" <?php if ($pconfig['generate_policy'] == "unique") echo "selected"; ?>>Unique</option>
658
							</select>
659
							<br>
660
							<span class="vexpl">
661
								<?=gettext("When working as a responder (as with mobile clients), this controls how policies are generated based on SA proposals."); ?>
662
							</span>
663
						</td>
664
					</tr>
665
					<tr id="proposal_check">
666
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Proposal Checking"); ?></td>
667
						<td width="78%" class="vtable">
668
							<select name="proposal_check" class="formselect">
669
								<option value="" <?php if (empty($pconfig['proposal_check'])) echo "selected"; ?>>Default</option>
670
								<option value="obey" <?php if ($pconfig['proposal_check'] == "obey") echo "selected"; ?>>Obey</option>
671
								<option value="strict" <?php if ($pconfig['proposal_check'] == "strict") echo "selected"; ?>>Strict</option>
672
								<option value="claim" <?php if ($pconfig['proposal_check'] == "claim") echo "selected"; ?>>Claim</option>
673
								<option value="exact" <?php if ($pconfig['proposal_check'] == "exact") echo "selected"; ?>>Exact</option>
674
							</select>
675
							<br>
676
							<span class="vexpl">
677
								<?=gettext("Specifies the action of lifetime length, key length, and PFS of the phase 2 selection on the responder side, and the action of lifetime check in phase 1."); ?>
678
							</span>
679
						</td>
680
					</tr>
681
					<tr>
682
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Encryption algorithm"); ?></td>
683
						<td width="78%" class="vtable">
684
							<select name="ealgo" class="formselect" onChange="ealgosel_change()">
685
							<?php
686
								foreach ($p1_ealgos as $algo => $algodata):
687
									$selected = '';
688
									if ($algo == $pconfig['ealgo']['name'])
689
										$selected = ' selected';
690
							?>
691
								<option value="<?=$algo;?>"<?=$selected?>>
692
									<?=htmlspecialchars($algodata['name']);?>
693
								</option>
694
							<?php endforeach; ?>
695
							</select>
696
							<select name="ealgo_keylen" width="30" class="formselect">
697
							</select>
698
						</td>
699
					</tr>
700
					<tr>
701
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Hash algorithm"); ?></td>
702
						<td width="78%" class="vtable">
703
							<select name="halgo" class="formselect">
704
							<?php foreach ($p1_halgos as $algo => $algoname): ?>
705
								<option value="<?=$algo;?>" <?php if ($algo == $pconfig['halgo']) echo "selected"; ?>>
706
									<?=htmlspecialchars($algoname);?>
707
								</option>
708
							<?php endforeach; ?>
709
							</select>
710
							<br>
711
							<span class="vexpl">
712
								<?=gettext("Must match the setting chosen on the remote side"); ?>.
713
							</span>
714
						</td>
715
					</tr>
716
					<tr>
717
						<td width="22%" valign="top" class="vncellreq"><?=gettext("DH key group"); ?></td>
718
						<td width="78%" class="vtable">
719
							<select name="dhgroup" class="formselect">
720
							<?php $keygroups = explode(" ", "1 2 5"); foreach ($keygroups as $keygroup): ?>
721
								<option value="<?=$keygroup;?>" <?php if ($keygroup == $pconfig['dhgroup']) echo "selected"; ?>>
722
									<?=htmlspecialchars($keygroup);?>
723
								</option>
724
							<?php endforeach; ?>
725
							</select>
726
							<br>
727
							<span class="vexpl">
728
								<em><?=gettext("1 = 768 bit, 2 = 1024 bit, 5 = 1536 bit"); ?></em>
729
								<br>
730
								<?=gettext("Must match the setting chosen on the remote side"); ?>.
731
							</span>
732
						</td>
733
					</tr>
734
					<tr>
735
						<td width="22%" valign="top" class="vncell"><?=gettext("Lifetime"); ?></td>
736
						<td width="78%" class="vtable">
737
							<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="20" value="<?=htmlspecialchars($pconfig['lifetime']);?>">
738
							<?=gettext("seconds"); ?>
739
						</td>
740
					</tr>
741
					<tr id="opt_cert">
742
						<td width="22%" valign="top" class="vncellreq"><?=gettext("My Certificate"); ?></td>
743
						<td width="78%" class="vtable">
744
							<select name='certref' class="formselect">
745
							<?php
746
								foreach ($config['cert'] as $cert):
747
									$selected = "";
748
									if ($pconfig['certref'] == $cert['refid'])
749
										$selected = "selected";
750
							?>
751
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['descr'];?></option>
752
							<?php endforeach; ?>
753
							</select>
754
							<br>
755
							<span class="vexpl">
756
								<?=gettext("Select a certificate previously configured in the Certificate Manager"); ?>.
757
							</span>
758
						</td>
759
					</tr>
760
					<tr id="opt_ca">
761
						<td width="22%" valign="top" class="vncellreq"><?=gettext("My Certificate Authority"); ?></td>
762
						<td width="78%" class="vtable">
763
							<select name='caref' class="formselect">
764
							<?php
765
								foreach ($config['ca'] as $ca):
766
									$selected = "";
767
									if ($pconfig['caref'] == $ca['refid'])
768
										$selected = "selected";
769
							?>
770
								<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['descr'];?></option>
771
							<?php endforeach; ?>
772
							</select>
773
							<br>
774
							<span class="vexpl">
775
								<?=gettext("Select a certificate authority previously configured in the Certificate Manager"); ?>.
776
							</span>
777
						</td>
778
					</tr>
779
					<tr>
780
						<td colspan="2" class="list" height="12"></td>
781
					</tr>
782
					<tr>
783
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced Options"); ?></td>
784
					</tr>
785
					<tr>
786
						<td width="22%" valign="top" class="vncell"><?=gettext("NAT Traversal"); ?></td>
787
						<td width="78%" class="vtable">
788
							<select name="nat_traversal" class="formselect">
789
								<option value="off" <?php if ($pconfig['nat_traversal'] == "off") echo "selected"; ?>><?=gettext("Disable"); ?></option>
790
								<option value="on" <?php if ($pconfig['nat_traversal'] == "on") echo "selected"; ?>><?=gettext("Enable"); ?></option>
791
								<option value="force" <?php if ($pconfig['nat_traversal'] == "force") echo "selected"; ?>><?=gettext("Force"); ?></option>
792
							</select>
793
							<br/>
794
							<span class="vexpl">
795
								<?=gettext("Set this option to enable the use of NAT-T (i.e. the encapsulation of ESP in UDP packets) if needed, " .
796
								"which can help with clients that are behind restrictive firewalls"); ?>.
797
							</span>
798
						</td>
799
					</tr>
800
					<tr>
801
						<td width="22%" valign="top" class="vncell"><?=gettext("Dead Peer Detection"); ?></td>
802
						<td width="78%" class="vtable">
803
							<input name="dpd_enable" type="checkbox" id="dpd_enable" value="yes" <?php if (isset($pconfig['dpd_enable'])) echo "checked"; ?> onClick="dpdchkbox_change()">
804
							<?=gettext("Enable DPD"); ?><br>
805
							<div id="opt_dpd">
806
								<br>
807
								<input name="dpd_delay" type="text" class="formfld unknown" id="dpd_delay" size="5" value="<?=htmlspecialchars($pconfig['dpd_delay']);?>">
808
								<?=gettext("seconds"); ?><br>
809
								<span class="vexpl">
810
									<?=gettext("Delay between requesting peer acknowledgement"); ?>.
811
								</span><br>
812
								<br>
813
								<input name="dpd_maxfail" type="text" class="formfld unknown" id="dpd_maxfail" size="5" value="<?=htmlspecialchars($pconfig['dpd_maxfail']);?>">
814
								<?=gettext("retries"); ?><br>
815
								<span class="vexpl">
816
									<?=gettext("Number of consecutive failures allowed before disconnect"); ?>.
817
								</span>
818
								<br>
819
							</div>
820
						</td>
821
					</tr>
822
					<tr>
823
						<td width="22%" valign="top">&nbsp;</td>
824
						<td width="78%">
825
							<?php if (isset($p1index) && $a_phase1[$p1index]): ?>
826
							<input name="p1index" type="hidden" value="<?=$p1index;?>">
827
							<?php endif; ?>
828
							<?php if ($pconfig['mobile']): ?>
829
							<input name="mobile" type="hidden" value="true">
830
							<?php endif; ?>
831
							<input name="ikeid" type="hidden" value="<?=htmlspecialchars($pconfig['ikeid']);?>">
832
							<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
833
						</td>
834
					</tr>
835
				</table>
836
			</div>
837
		</td>
838
	</tr>
839
</table>
840
</form>
841

    
842
<script lannguage="JavaScript">
843
<!--
844
<?php
845
	/* determine if we should init the key length */
846
	$keyset = '';
847
	if (isset($pconfig['ealgo']['keylen']))
848
		if (is_numeric($pconfig['ealgo']['keylen']))
849
			$keyset = $pconfig['ealgo']['keylen'];
850
?>
851
myidsel_change();
852
peeridsel_change();
853
methodsel_change();
854
ealgosel_change(<?=$keyset;?>);
855
dpdchkbox_change();
856
//-->
857
</script>
858
<?php include("fend.inc"); ?>
859
</body>
860
</html>
(211-211/225)