Project

General

Profile

Download (33.8 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['protocol'] = $a_phase1[$p1index]['protocol'];
84
	$pconfig['myid_type'] = $a_phase1[$p1index]['myid_type'];
85
	$pconfig['myid_data'] = $a_phase1[$p1index]['myid_data'];
86
	$pconfig['peerid_type'] = $a_phase1[$p1index]['peerid_type'];
87
	$pconfig['peerid_data'] = $a_phase1[$p1index]['peerid_data'];
88
	$pconfig['ealgo'] = $a_phase1[$p1index]['encryption-algorithm'];
89
	$pconfig['halgo'] = $a_phase1[$p1index]['hash-algorithm'];
90
	$pconfig['dhgroup'] = $a_phase1[$p1index]['dhgroup'];
91
	$pconfig['lifetime'] = $a_phase1[$p1index]['lifetime'];
92
	$pconfig['authentication_method'] = $a_phase1[$p1index]['authentication_method'];
93
	$pconfig['generate_policy'] = $a_phase1[$p1index]['generate_policy'];
94
	$pconfig['proposal_check'] = $a_phase1[$p1index]['proposal_check'];
95

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

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

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

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

    
134
if (isset($_GET['dup']))
135
	unset($p1index);
136

    
137
if ($_POST) {
138
	unset($input_errors);
139
	$pconfig = $_POST;
140

    
141
	/* input validation */
142

    
143
	$method = $pconfig['authentication_method'];
144
	// Unset ca and cert if not required to avaoid storing in config
145
	if ($method == "pre_shared_key" || method == "xauth_psk_server"){
146
		unset($pconfig['caref']);	
147
		unset($pconfig['certref']);	
148
	}
149

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

    
174
	do_input_validation($pconfig, $reqdfields, $reqdfieldsn, &$input_errors);
175

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

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

    
182
	if (($pconfig['remotegw'] && is_ipaddr($pconfig['remotegw']) && !isset($pconfig['disabled']) )) {
183
		$t = 0;
184
		foreach ($a_phase1 as $ph1tmp) {
185
			if ($p1index <> $t) {
186
				$tremotegw = $pconfig['remotegw'];
187
				if (($ph1tmp['remote-gateway'] == $tremotegw) && !isset($ph1tmp['disabled'])) {
188
					$input_errors[] = sprintf(gettext('The remote gateway "%1$s" is already used by phase1 "%2$s".'), $tremotegw, $ph1tmp['descr']);
189
				}
190
			}
191
			$t++;
192
		}
193
	}
194

    
195
	/* My identity */
196

    
197
	if ($pconfig['myid_type'] == "myaddress")
198
		$pconfig['myid_data'] = "";
199

    
200
	if ($pconfig['myid_type'] == "address" and $pconfig['myid_data'] == "")
201
		$input_errors[] = gettext("Please enter an address for 'My Identifier'");
202

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

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

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

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

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

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

    
221
	if ($pconfig['myid_type'] == "fqdn")
222
		if (is_domain($pconfig['myid_data']) == false)
223
			$input_errors[] = gettext("A valid FQDN for 'My identifier' must be specified.");
224

    
225
	if ($pconfig['myid_type'] == "user_fqdn") {
226
		$user_fqdn = explode("@",$pconfig['myid_data']);
227
		if (is_domain($user_fqdn[1]) == false)
228
			$input_errors[] = gettext("A valid User FQDN in the form of user@my.domain.com for 'My identifier' must be specified.");
229
	}
230

    
231
	if ($pconfig['myid_type'] == "dyn_dns")
232
		if (is_domain($pconfig['myid_data']) == false)
233
			$input_errors[] = gettext("A valid Dynamic DNS address for 'My identifier' must be specified.");
234

    
235
	/* Peer identity */
236

    
237
	if ($pconfig['myid_type'] == "peeraddress")
238
		$pconfig['peerid_data'] = "";
239

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

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

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

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

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

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

    
260
		if ($pconfig['peerid_type'] == "fqdn")
261
			if (is_domain($pconfig['peerid_data']) == false)
262
				$input_errors[] = gettext("A valid FQDN for 'Peer identifier' must be specified.");
263

    
264
		if ($pconfig['peerid_type'] == "user_fqdn") {
265
			$user_fqdn = explode("@",$pconfig['peerid_data']);
266
			if (is_domain($user_fqdn[1]) == false)
267
				$input_errors[] = gettext("A valid User FQDN in the form of user@my.domain.com for 'Peer identifier' must be specified.");
268
		}
269
	}
270

    
271
	if ($pconfig['dpd_enable']) {
272
		if (!is_numeric($pconfig['dpd_delay']))
273
			$input_errors[] = gettext("A numeric value must be specified for DPD delay.");
274

    
275
		if (!is_numeric($pconfig['dpd_maxfail']))
276
			$input_errors[] = gettext("A numeric value must be specified for DPD retries.");
277
	}
278

    
279
	/* build our encryption algorithms array */
280
	$pconfig['ealgo'] = array();
281
	$pconfig['ealgo']['name'] = $_POST['ealgo'];
282
	if($pconfig['ealgo_keylen'])
283
		$pconfig['ealgo']['keylen'] = $_POST['ealgo_keylen'];
284

    
285
	if (!$input_errors) {
286
		$ph1ent['ikeid'] = $pconfig['ikeid'];
287
		$ph1ent['disabled'] = $pconfig['disabled'] ? true : false;
288
		$ph1ent['interface'] = $pconfig['interface'];
289
		/* if the remote gateway changed and the interface is not WAN then remove route */
290
		/* the vpn_ipsec_configure() handles adding the route */
291
		if ($pconfig['interface'] <> "wan") {
292
			if($old_ph1ent['remote-gateway'] <> $pconfig['remotegw']) {
293
				mwexec("/sbin/route delete -host {$old_ph1ent['remote-gateway']}");
294
			}
295
		}
296

    
297
		if ($pconfig['mobile'])
298
			$ph1ent['mobile'] = true;
299
		else
300
			$ph1ent['remote-gateway'] = $pconfig['remotegw'];
301

    
302
		$ph1ent['mode'] = $pconfig['mode'];
303
		$ph1ent['protocol'] = $pconfig['protocol'];
304

    
305
		$ph1ent['myid_type'] = $pconfig['myid_type'];
306
		$ph1ent['myid_data'] = $pconfig['myid_data'];
307
		$ph1ent['peerid_type'] = $pconfig['peerid_type'];
308
		$ph1ent['peerid_data'] = $pconfig['peerid_data'];
309

    
310
		$ph1ent['encryption-algorithm'] = $pconfig['ealgo'];
311
		$ph1ent['hash-algorithm'] = $pconfig['halgo'];
312
		$ph1ent['dhgroup'] = $pconfig['dhgroup'];
313
		$ph1ent['lifetime'] = $pconfig['lifetime'];
314
		$ph1ent['pre-shared-key'] = $pconfig['pskey'];
315
		$ph1ent['private-key'] = base64_encode($pconfig['privatekey']);
316
		$ph1ent['certref'] = $pconfig['certref'];
317
		$ph1ent['caref'] = $pconfig['caref'];
318
		$ph1ent['authentication_method'] = $pconfig['authentication_method'];
319
		$ph1ent['generate_policy'] = $pconfig['generate_policy'];
320
		$ph1ent['proposal_check'] = $pconfig['proposal_check'];
321
		$ph1ent['descr'] = $pconfig['descr'];
322
		$ph1ent['nat_traversal'] = $pconfig['nat_traversal'];
323

    
324
		if (isset($pconfig['dpd_enable'])) {
325
			$ph1ent['dpd_delay'] = $pconfig['dpd_delay'];
326
			$ph1ent['dpd_maxfail'] = $pconfig['dpd_maxfail'];
327
		}
328

    
329
		/* generate unique phase1 ikeid */
330
		if ($ph1ent['ikeid'] == 0)
331
			$ph1ent['ikeid'] = ipsec_ikeid_next();
332

    
333
		if (isset($p1index) && $a_phase1[$p1index])
334
			$a_phase1[$p1index] = $ph1ent;
335
		else
336
			$a_phase1[] = $ph1ent;
337

    
338
		/* now we need to find all phase2 entries for this host */
339
		if (is_array($a_phase2) && (count($a_phase2))) {
340
			foreach ($a_phase2 as $phase2) {
341
				if($phase2['ikeid'] == $ph1ent['ikeid']) {
342
					log_error("Reload {$ph1ent['descr']} tunnel(s)");
343
					$old_ph1ent['remote-gateway'] = resolve_retry($old_ph1ent['remote-gateway']);
344
					$old_phase2 = $phase2;
345
					reload_tunnel_spd_policy ($ph1ent, $phase2, $old_ph1ent, $old_phase2);
346
				}
347
			}
348
		}
349
		write_config();
350
		mark_subsystem_dirty('ipsec');
351

    
352
		header("Location: vpn_ipsec.php");
353
		exit;
354
	}
355
}
356

    
357
if ($pconfig['mobile'])
358
	$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1"), gettext("Mobile Client"));
359
else
360
	$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1"));
361
$statusurl = "diag_ipsec.php";
362
$logurl = "diag_logs_ipsec.php";
363

    
364

    
365
include("head.inc");
366

    
367
?>
368

    
369
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
370
<?php include("fbegin.inc"); ?>
371
<script language="JavaScript">
372
<!--
373

    
374
function myidsel_change() {
375
	index = document.iform.myid_type.selectedIndex;
376
	value = document.iform.myid_type.options[index].value;
377
	if (value == 'myaddress')
378
			document.getElementById('myid_data').style.visibility = 'hidden';
379
	else
380
			document.getElementById('myid_data').style.visibility = 'visible';
381
}
382

    
383
function peeridsel_change() {
384
	index = document.iform.peerid_type.selectedIndex;
385
	value = document.iform.peerid_type.options[index].value;
386
	if (value == 'peeraddress')
387
			document.getElementById('peerid_data').style.visibility = 'hidden';
388
	else
389
			document.getElementById('peerid_data').style.visibility = 'visible';
390
}
391

    
392
function methodsel_change() {
393
	index = document.iform.authentication_method.selectedIndex;
394
	value = document.iform.authentication_method.options[index].value;
395

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

    
435
/* PHP generated java script for variable length keys */
436
function ealgosel_change(bits) {
437
	switch (document.iform.ealgo.selectedIndex) {
438
<?php
439
  $i = 0;
440
  foreach ($p1_ealgos as $algo => $algodata) {
441
    if (is_array($algodata['keysel'])) {
442
      echo "		case {$i}:\n";
443
      echo "			document.iform.ealgo_keylen.style.visibility = 'visible';\n";
444
      echo "			document.iform.ealgo_keylen.options.length = 0;\n";
445
//      echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( 'auto', 'auto' );\n";
446

    
447
      $key_hi = $algodata['keysel']['hi'];
448
      $key_lo = $algodata['keysel']['lo'];
449
      $key_step = $algodata['keysel']['step'];
450

    
451
      for ($keylen = $key_hi; $keylen >= $key_lo; $keylen -= $key_step)
452
        echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( '{$keylen} bits', '{$keylen}' );\n";
453
      echo "			break;\n";
454
    } else {
455
      echo "		case {$i}:\n";
456
      echo "			document.iform.ealgo_keylen.style.visibility = 'hidden';\n";
457
      echo "			document.iform.ealgo_keylen.options.length = 0;\n";
458
      echo "			break;\n";
459
    }
460
    $i++;
461
  }
462
?>
463
	}
464

    
465
	if( bits )
466
		document.iform.ealgo_keylen.value = bits;
467
}
468

    
469
function dpdchkbox_change() {
470
	if( document.iform.dpd_enable.checked )
471
		document.getElementById('opt_dpd').style.display = '';
472
	else
473
		document.getElementById('opt_dpd').style.display = 'none';
474

    
475
	if (!document.iform.dpd_delay.value)
476
		document.iform.dpd_delay.value = "10";
477

    
478
	if (!document.iform.dpd_maxfail.value)
479
		document.iform.dpd_maxfail.value = "5";
480
}
481

    
482
//-->
483
</script>
484

    
485
<form action="vpn_ipsec_phase1.php" method="post" name="iform" id="iform">
486

    
487
<?php
488
	if ($input_errors)
489
		print_input_errors($input_errors);
490
?>
491

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

    
561
					<?php if (!$pconfig['mobile']): ?>
562

    
563
					<tr>
564
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote gateway"); ?></td>
565
						<td width="78%" class="vtable">
566
							<?=$mandfldhtml;?><input name="remotegw" type="text" class="formfld unknown" id="remotegw" size="28" value="<?=htmlspecialchars($pconfig['remotegw']);?>">
567
							<br>
568
							<?=gettext("Enter the public IP address or host name of the remote gateway"); ?>
569
						</td>
570
					</tr>
571

    
572
					<?php endif; ?>
573

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

    
865
<script lannguage="JavaScript">
866
<!--
867
<?php
868
	/* determine if we should init the key length */
869
	$keyset = '';
870
	if (isset($pconfig['ealgo']['keylen']))
871
		if (is_numeric($pconfig['ealgo']['keylen']))
872
			$keyset = $pconfig['ealgo']['keylen'];
873
?>
874
myidsel_change();
875
peeridsel_change();
876
methodsel_change();
877
ealgosel_change(<?=$keyset;?>);
878
dpdchkbox_change();
879
//-->
880
</script>
881
<?php include("fend.inc"); ?>
882
</body>
883
</html>
(226-226/240)