Project

General

Profile

Download (30 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
require("guiconfig.inc");
33

    
34
if (!is_array($config['ipsec']['phase1']))
35
	$config['ipsec']['phase1'] = array();
36

    
37
$a_phase1 = &$config['ipsec']['phase1'];
38

    
39
if($config['interfaces']['lan']) 
40
		$specialsrcdst = explode(" ", "lan");
41

    
42
$p1index = $_GET['p1index'];
43
if (isset($_POST['p1index']))
44
	$p1index = $_POST['p1index'];
45

    
46
if (isset($_GET['dup'])) {
47
	$p1index = $_GET['dup'];
48
}
49

    
50
if (isset($p1index) && $a_phase1[$p1index])
51
{
52
	$pconfig['ikeid'] = $a_phase1[$p1index]['ikeid'];
53
	$pconfig['disabled'] = isset($a_phase1[$p1index]['disabled']);
54

    
55
	if ($a_phase1[$p1index]['interface'])
56
		$pconfig['interface'] = $a_phase1[$p1index]['interface'];
57
	else
58
		$pconfig['interface'] = "wan";
59

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

    
62
	if (isset($a_phase1[$p1index]['mobile']))
63
		$pconfig['mobile'] = 'true';
64
	else
65
		$pconfig['remotegw'] = $a_phase1[$p1index]['remote-gateway'];
66

    
67
	$pconfig['mode'] = $a_phase1[$p1index]['mode'];
68
	$pconfig['myid_type'] = $a_phase1[$p1index]['myid_type'];
69
	$pconfig['myid_data'] = $a_phase1[$p1index]['myid_data'];
70
	$pconfig['peerid_type'] = $a_phase1[$p1index]['peerid_type'];
71
	$pconfig['peerid_data'] = $a_phase1[$p1index]['peerid_data'];
72
	$pconfig['ealgo'] = $a_phase1[$p1index]['encryption-algorithm'];
73
	$pconfig['halgo'] = $a_phase1[$p1index]['hash-algorithm'];
74
	$pconfig['dhgroup'] = $a_phase1[$p1index]['dhgroup'];
75
	$pconfig['lifetime'] = $a_phase1[$p1index]['lifetime'];
76
	$pconfig['authentication_method'] = $a_phase1[$p1index]['authentication_method'];
77
	$pconfig['pskey'] = $a_phase1[$p1index]['pre-shared-key'];
78
	$pconfig['cert'] = base64_decode($a_phase1[$p1index]['cert']);
79
	$pconfig['peercert'] = base64_decode($a_phase1[$p1index]['peercert']);
80
	$pconfig['privatekey'] = base64_decode($a_phase1[$p1index]['private-key']);
81

    
82
	$pconfig['descr'] = $a_phase1[$p1index]['descr'];
83
	$pconfig['nat_traversal'] = $a_phase1[$p1index]['nat_traversal'];
84

    
85
	if ($a_phase1[$p1index]['dpd_delay'] &&	$a_phase1[$p1index]['dpd_maxfail']) {
86
		$pconfig['dpd_enable'] = true;
87
		$pconfig['dpd_delay'] = $a_phase1[$p1index]['dpd_delay'];
88
		$pconfig['dpd_maxfail'] = $a_phase1[$p1index]['dpd_maxfail'];
89
	}
90

    
91
	$pconfig['pinghost'] = $a_phase1[$p1index]['pinghost'];
92
}
93
else
94
{
95
	/* defaults */
96
	$pconfig['interface'] = "wan";
97
	if($config['interfaces']['lan']) 
98
		$pconfig['localnet'] = "lan";
99
	$pconfig['mode'] = "aggressive";
100
	$pconfig['myid_type'] = "myaddress";
101
	$pconfig['peerid_type'] = "peeraddress";
102
	$pconfig['authentication_method'] = "pre_shared_key";
103
	$pconfig['ealgo'] = array( name => "3des" );
104
	$pconfig['halgo'] = "sha1";
105
	$pconfig['dhgroup'] = "2";
106
	$pconfig['lifetime'] = "28800";
107
	$pconfig['nat_traversal'] = "on";
108
	$pconfig['dpd_enable'] = true;
109

    
110
	/* mobile client */
111
	if($_GET['mobile'])
112
		$pconfig['mobile']=true;
113
}
114

    
115
if (isset($_GET['dup']))
116
	unset($p1index);
117

    
118
if ($_POST) {
119
	unset($input_errors);
120
	$pconfig = $_POST;
121

    
122
	/* input validation */
123

    
124
	$method = $pconfig['authentication_method'];
125
	if (($method == "pre_shared_key")||($method == "xauth_psk_server")) {
126
		$reqdfields = explode(" ", "pskey");
127
		$reqdfieldsn = explode(",", "Pre-Shared Key");
128
	} else	{
129
		if (!strstr($pconfig['cert'], "BEGIN CERTIFICATE") || !strstr($pconfig['cert'], "END CERTIFICATE"))
130
			$input_errors[] = "This certificate does not appear to be valid.";
131
		if (!strstr($pconfig['privatekey'], "BEGIN RSA PRIVATE KEY") || !strstr($pconfig['privatekey'], "END RSA PRIVATE KEY"))
132
			$input_errors[] = "This key does not appear to be valid.";
133
		if ($pconfig['peercert']!="" && (!strstr($pconfig['peercert'], "BEGIN CERTIFICATE") || !strstr($pconfig['peercert'], "END CERTIFICATE")))
134
			$input_errors[] = "This peer certificate does not appear to be valid.";
135
	}
136
	if (!$pconfig['mobile']) {
137
		$reqdfields[] = "remotegw";
138
		$reqdfieldsn[] = "Remote gateway";
139
	}
140

    
141
	do_input_validation($pconfig, $reqdfields, $reqdfieldsn, &$input_errors);
142

    
143
	if (($pconfig['lifetime'] && !is_numeric($pconfig['lifetime'])))
144
		$input_errors[] = "The P1 lifetime must be an integer.";
145

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

    
149
	if (($pconfig['remotegw'] && is_ipaddr($pconfig['remotegw']) && !isset($pconfig['disabled']) )) {
150
		$t = 0;
151
		foreach ($a_phase1 as $ph1tmp) {
152
			if ($p1index <> $t) {
153
				$tremotegw = $pconfig['remotegw'];
154
				if (($ph1tmp['remote-gateway'] == $tremotegw) && !isset($ph1tmp['disabled'])) {
155
					$input_errors[] = "The remote gateway \"$tremotegw\" is already used by phase1 \"${ph1tmp['descr']}\".";
156
				}
157
			}
158
			$t++;
159
		}
160
	}
161

    
162
	/* My identity */
163

    
164
	if ($pconfig['myid_type'] == "myaddress")
165
		$pconfig['myid_data'] = "";
166

    
167
	if ($pconfig['myid_type'] == "address" and $pconfig['myid_data'] == "")
168
		$input_errors[] = gettext("Please enter an address for 'My Identifier'");
169

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

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

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

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

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

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

    
188
	if ($pconfig['myid_type'] == "fqdn")
189
		if (is_domain($pconfig['myid_data']) == false)
190
			$input_errors[] = "A valid FQDN for 'My identifier' must be specified.";
191

    
192
	if ($pconfig['myid_type'] == "user_fqdn") {
193
		$user_fqdn = explode("@",$pconfig['myid_data']);
194
		if (is_domain($user_fqdn[1]) == false)
195
			$input_errors[] = "A valid User FQDN in the form of user@my.domain.com for 'My identifier' must be specified.";
196
	}
197

    
198
	if ($pconfig['myid_type'] == "dyn_dns")
199
		if (is_domain($pconfig['myid_data']) == false)
200
			$input_errors[] = "A valid Dynamic DNS address for 'My identifier' must be specified.";
201

    
202
	/* Peer identity */
203

    
204
	if ($pconfig['myid_type'] == "peeraddress")
205
		$pconfig['peerid_data'] = "";
206

    
207
	if ($pconfig['peerid_type'] == "address" and $pconfig['peerid_data'] == "")
208
		$input_errors[] = gettext("Please enter an address for 'Peer Identifier'");
209

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

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

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

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

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

    
225
	if ($pconfig['peerid_type'] == "fqdn")
226
		if (is_domain($pconfig['peerid_data']) == false)
227
			$input_errors[] = "A valid FQDN for 'Peer identifier' must be specified.";
228

    
229
	if ($pconfig['peerid_type'] == "user_fqdn") {
230
		$user_fqdn = explode("@",$pconfig['peerid_data']);
231
		if (is_domain($user_fqdn[1]) == false)
232
			$input_errors[] = "A valid User FQDN in the form of user@my.domain.com for 'Peer identifier' must be specified.";
233
	}
234

    
235
	if ($pconfig['dpd_enable']) {
236
		if (!is_numeric($pconfig['dpd_delay']))
237
			$input_errors[] = "A numeric value must be specified for DPD delay.";
238

    
239
		if (!is_numeric($pconfig['dpd_maxfail']))
240
			$input_errors[] = "A numeric value must be specified for DPD retries.";
241
	}
242

    
243
	/* build our encryption algorithms array */
244
	$pconfig['ealgo'] = array();
245
	$pconfig['ealgo']['name'] = $_POST['ealgo'];
246
	if($pconfig['ealgo_keylen'])
247
		$pconfig['ealgo']['keylen'] = $_POST['ealgo_keylen'];
248

    
249
	if (!$input_errors) {
250
		$ph1ent['ikeid'] = $pconfig['ikeid'];
251
		$ph1ent['disabled'] = $pconfig['disabled'] ? true : false;
252
		$ph1ent['interface'] = $pconfig['interface'];
253
		/* if the remote gateway changed and the interface is not WAN then remove route */
254
		/* the vpn_ipsec_configure() handles adding the route */
255
		if ($pconfig['interface'] <> "wan") {
256
			if($ph1ent['remote-gateway'] <> $pconfig['remotegw']) {
257
				mwexec("/sbin/route delete -host {$ph1ent['remote-gateway']}");
258
			}
259
		}
260

    
261
		if ($pconfig['mobile'])
262
			$ph1ent['mobile'] = true;
263
		else
264
			$ph1ent['remote-gateway'] = $pconfig['remotegw'];
265

    
266
		$ph1ent['mode'] = $pconfig['mode'];
267

    
268
		$ph1ent['myid_type'] = $pconfig['myid_type'];
269
		$ph1ent['myid_data'] = $pconfig['myid_data'];
270
		$ph1ent['peerid_type'] = $pconfig['peerid_type'];
271
		$ph1ent['peerid_data'] = $pconfig['peerid_data'];
272

    
273
		$ph1ent['encryption-algorithm'] = $pconfig['ealgo'];
274
		$ph1ent['hash-algorithm'] = $pconfig['halgo'];
275
		$ph1ent['dhgroup'] = $pconfig['dhgroup'];
276
		$ph1ent['lifetime'] = $pconfig['lifetime'];
277
		$ph1ent['pre-shared-key'] = $pconfig['pskey'];
278
		$ph1ent['private-key'] = base64_encode($pconfig['privatekey']);
279
		$ph1ent['cert'] = base64_encode($pconfig['cert']);
280
		$ph1ent['peercert'] = base64_encode($pconfig['peercert']);
281
		$ph1ent['authentication_method'] = $pconfig['authentication_method'];
282

    
283
		$ph1ent['descr'] = $pconfig['descr'];
284
		$ph1ent['nat_traversal'] = $pconfig['nat_traversal'];
285

    
286
		if (isset($pconfig['dpd_enable'])) {
287
			$ph1ent['dpd_delay'] = $pconfig['dpd_delay'];
288
			$ph1ent['dpd_maxfail'] = $pconfig['dpd_maxfail'];
289
		}
290

    
291
		$ph1ent['pinghost'] = $pconfig['pinghost'];
292

    
293
		/* generate unique phase1 ikeid */
294
		if ($ph1ent['ikeid'] == 0) {
295
			while (true) {
296
				$ph1ent['ikeid']++;
297
				foreach ($a_phase1 as $ph1tmp)
298
					if( $ph1ent['ikeid'] == $ph1tmp['ikeid'] )
299
						break;
300

    
301
				if( $ph1ent['ikeid'] != $ph1tmp['ikeid'] )
302
					break;
303
			}
304
		}
305

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

    
311
		write_config();
312
		touch($d_ipsecconfdirty_path);
313

    
314
		header("Location: vpn_ipsec.php");
315
		exit;
316
	}
317
}
318

    
319
if ($pconfig['mobile'])
320
	$pgtitle = array("VPN","IPsec","Edit Phase 1", "Mobile Client");
321
else
322
	$pgtitle = array("VPN","IPsec","Edit Phase 1");
323

    
324
include("head.inc");
325

    
326
?>
327

    
328
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
329
<?php include("fbegin.inc"); ?>
330
<script language="JavaScript">
331
<!--
332

    
333
function myidsel_change() {
334
	index = document.iform.myid_type.selectedIndex;
335
	value = document.iform.myid_type.options[index].value;
336
	if (value == 'myaddress')
337
			document.iform.myid_data.style.visibility = 'hidden';
338
	else
339
			document.iform.myid_data.style.visibility = 'visible';
340
}
341

    
342
function peeridsel_change() {
343
	index = document.iform.peerid_type.selectedIndex;
344
	value = document.iform.peerid_type.options[index].value;
345
	if (value == 'peeraddress')
346
			document.iform.peerid_data.style.visibility = 'hidden';
347
	else
348
			document.iform.peerid_data.style.visibility = 'visible';
349
}
350

    
351
function methodsel_change() {
352
	index = document.iform.authentication_method.selectedIndex;
353
	value = document.iform.authentication_method.options[index].value;
354

    
355
	switch (value) {
356
		case 'hybrid_rsa_server':
357
			document.iform.pskey.disabled = 1;
358
			document.iform.privatekey.disabled = 0;
359
			document.iform.cert.disabled = 0;
360
			document.iform.peercert.disabled = 1;
361
			break;
362
		case 'xauth_rsa_server':
363
		case 'rsasig':
364
			document.iform.pskey.disabled = 1;
365
			document.iform.privatekey.disabled = 0;
366
			document.iform.cert.disabled = 0;
367
			document.iform.peercert.disabled = 0;
368
			break;
369
		default: /* psk modes*/
370
			document.iform.pskey.disabled = 0;
371
			document.iform.privatekey.disabled = 1;
372
			document.iform.cert.disabled = 1;
373
			document.iform.peercert.disabled = 1;
374
			break;
375
	}
376
}
377

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

    
390
      $key_hi = $algodata['keysel']['hi'];
391
      $key_lo = $algodata['keysel']['lo'];
392
      $key_step = $algodata['keysel']['step'];
393

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

    
408
	if( bits )
409
		document.iform.ealgo_keylen.value = bits;
410
}
411

    
412
function dpdchkbox_change() {
413
	if( document.iform.dpd_enable.checked ) {
414
			document.iform.dpd_delay.disabled = 0;
415
			document.iform.dpd_maxfail.disabled = 0;
416
	} else {
417
			document.iform.dpd_delay.disabled = 1;
418
			document.iform.dpd_maxfail.disabled = 1;
419
	}
420

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

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

    
428
//-->
429
</script>
430
<?php if ($input_errors) print_input_errors($input_errors); ?>
431
            <form action="vpn_ipsec_phase1.php" method="post" name="iform" id="iform">
432
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
433
                <tr>
434
                  <td width="22%" valign="top" class="vncellreq">Disabled</td>
435
                  <td width="78%" class="vtable">
436
                    <input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
437
                    <strong>Disable this phase1 entry</strong><br>
438
                    <span class="vexpl">Set this option to disable this phase1 without
439
                      removing it from the list.
440
                    </span>
441
                  </td>
442
                </tr>
443
                <tr>
444
                  <td width="22%" valign="top" class="vncellreq">Interface</td>
445
                  <td width="78%" class="vtable">
446
                    <select name="interface" class="formselect">
447
                      <?php 
448
                        $interfaces = get_configured_interface_with_descr();
449
                        $carpips = find_number_of_needed_carp_interfaces();
450
                        for ($i=0; $i<$carpips; $i++) {
451
                          $carpip = find_interface_ip("carp" . $i);
452
                          $interfaces['carp' . $i] = "CARP{$i} ({$carpip})"; 
453
                        }
454
                        foreach ($interfaces as $iface => $ifacename):
455
                      ?>
456
                      <option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
457
                        <?=htmlspecialchars($ifacename);?>
458
                      </option>
459
                      <?php endforeach; ?>
460
                    </select> <br>
461
                    <span class="vexpl">Select the interface for the local endpoint of this phase1 entry.</span>
462
                  </td>
463
                </tr>
464
				<?php if (!$pconfig['mobile']): ?>
465
                <tr>
466
                  <td width="22%" valign="top" class="vncellreq">Remote gateway</td>
467
                  <td width="78%" class="vtable">
468
                    <?=$mandfldhtml;?><input name="remotegw" type="text" class="formfld unknown" id="remotegw" size="20" value="<?=$pconfig['remotegw'];?>">
469
                    <br>
470
                    Enter the public IP address or host name of the remote gateway
471
                  </td>
472
                </tr>
473
				<?php endif; ?>
474
                <tr>
475
                  <td width="22%" valign="top" class="vncell">Description</td>
476
                  <td width="78%" class="vtable">
477
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
478
                    <br> <span class="vexpl">You may enter a description here
479
                    for your reference (not parsed).</span>
480
                  </td>
481
                </tr>
482
                <tr>
483
                  <td colspan="2" class="list" height="12"></td>
484
                </tr>
485
                <tr>
486
                  <td colspan="2" valign="top" class="listtopic">Phase 1 proposal
487
                    (Authentication)
488
                  </td>
489
                </tr>
490
                <tr>
491
                  <td width="22%" valign="top" class="vncellreq">Negotiation mode</td>
492
                  <td width="78%" class="vtable">
493
                    <select name="mode" class="formselect">
494
                      <?php
495
                        $modes = explode(" ", "main aggressive");
496
                        foreach ($modes as $mode):
497
                      ?>
498
                      <option value="<?=$mode;?>" <?php if ($mode == $pconfig['mode']) echo "selected"; ?>>
499
                        <?=htmlspecialchars($mode);?>
500
                      </option>
501
                      <?php endforeach; ?>
502
                    </select> <br> <span class="vexpl">Aggressive is more flexible, but less secure.</span>
503
                  </td>
504
                </tr>
505
                <tr>
506
                  <td width="22%" valign="top" class="vncellreq">My identifier</td>
507
                  <td width="78%" class="vtable">
508
                    <select name="myid_type" class="formselect" onChange="myidsel_change()">
509
                      <?php foreach ($my_identifier_list as $id_type => $id_params): ?>
510
                        <option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['myid_type']) echo "selected"; ?>>
511
                          <?=htmlspecialchars($id_params['desc']);?>
512
                        </option>
513
                      <?php endforeach; ?>
514
                    </select>
515
                    <input name="myid_data" type="text" class="formfld unknown" id="myid_data" size="30" value="<?=$pconfig['myid_data'];?>">
516
                  </td>
517
                </tr>
518
                <tr>
519
                  <td width="22%" valign="top" class="vncellreq">Peer identifier</td>
520
                  <td width="78%" class="vtable">
521
                    <select name="peerid_type" class="formselect" onChange="peeridsel_change()">
522
                      <?php
523
                        foreach ($peer_identifier_list as $id_type => $id_params):
524
                          if ($pconfig['mobile'] && !$id_params['mobile'])
525
                            continue;
526
                      ?>
527
                      <option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['peerid_type']) echo "selected"; ?>>
528
                        <?=htmlspecialchars($id_params['desc']);?>
529
                      </option>
530
                      <?php endforeach; ?>
531
                    </select>
532
                    <input name="peerid_data" type="text" class="formfld unknown" id="peerid_data" size="30" value="<?=$pconfig['peerid_data'];?>">
533
                  </td>
534
                </tr>
535
                <tr>
536
                  <td width="22%" valign="top" class="vncellreq">Encryption algorithm</td>
537
                  <td width="78%" class="vtable">
538
                    <select name="ealgo" class="formselect" onChange="ealgosel_change()">
539
                      <?php
540
                        foreach ($p1_ealgos as $algo => $algodata):
541
                        $selected = '';
542
                        if ($algo == $pconfig['ealgo']['name'])
543
                          $selected = ' selected';
544
                      ?>
545
                      <option value="<?=$algo;?>"<?=$selected?>>
546
                        <?=htmlspecialchars($algodata['name']);?>
547
                      </option>
548
                    <?php endforeach; ?>
549
                    </select>
550
                    <select name="ealgo_keylen" width="30" class="formselect">
551
                    </select>
552
                  </td>
553
                </tr>
554
                <tr>
555
                  <td width="22%" valign="top" class="vncellreq">Hash algorithm</td>
556
                  <td width="78%" class="vtable">
557
                    <select name="halgo" class="formselect">
558
                      <?php foreach ($p1_halgos as $algo => $algoname): ?>
559
                      <option value="<?=$algo;?>" <?php if ($algo == $pconfig['halgo']) echo "selected"; ?>>
560
                        <?=htmlspecialchars($algoname);?>
561
                      </option>
562
                      <?php endforeach; ?>
563
                    </select>
564
                    <br>
565
                    <span class="vexpl">
566
                      Must match the setting chosen on the remote side.
567
                    </span>
568
                  </td>
569
                </tr>
570
                <tr>
571
                  <td width="22%" valign="top" class="vncellreq">DH key group</td>
572
                  <td width="78%" class="vtable">
573
                    <select name="dhgroup" class="formselect">
574
                      <?php $keygroups = explode(" ", "1 2 5"); foreach ($keygroups as $keygroup): ?>
575
                      <option value="<?=$keygroup;?>" <?php if ($keygroup == $pconfig['dhgroup']) echo "selected"; ?>>
576
                        <?=htmlspecialchars($keygroup);?>
577
                      </option>
578
                      <?php endforeach; ?>
579
                    </select>
580
                    <br>
581
                    <span class="vexpl">
582
                      <em>1 = 768 bit, 2 = 1024 bit, 5 = 1536 bit</em>
583
                      <br>
584
                      Must match the setting chosen on the remote side.
585
                    </span>
586
                  </td>
587
                </tr>
588
                <tr>
589
                  <td width="22%" valign="top" class="vncell">Lifetime</td>
590
                  <td width="78%" class="vtable">
591
                    <input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="20" value="<?=$pconfig['lifetime'];?>">
592
                    seconds
593
                  </td>
594
                </tr>
595
                <tr>
596
                  <td width="22%" valign="top" class="vncellreq">Authentication method</td>
597
                  <td width="78%" class="vtable">
598
                    <select name="authentication_method" class="formselect" onChange="methodsel_change()">
599
                      <?php
600
                        foreach ($p1_authentication_methods as $method_type => $method_params):
601
                          if (!$pconfig['mobile'] && $method_params['mobile'])
602
                            continue;
603
                      ?>
604
                      <option value="<?=$method_type;?>" <?php if ($method_type == $pconfig['authentication_method']) echo "selected"; ?>>
605
                        <?=htmlspecialchars($method_params['name']);?>
606
                      </option>
607
                      <?php endforeach; ?>
608
                    </select>
609
                    <br>
610
                    <span class="vexpl">Must match the setting chosen on the remote side.</span>
611
                  </td>
612
                </tr>
613
                <tr>
614
                  <td width="22%" valign="top" class="vncellreq">Pre-Shared Key</td>
615
                  <td width="78%" class="vtable">
616
                    <?=$mandfldhtml;?><input name="pskey" type="text" class="formfld unknown" id="pskey" size="40" value="<?=htmlspecialchars($pconfig['pskey']);?>">
617
                  </td>
618
                </tr>
619
                <tr>
620
                  <td width="22%" valign="top" class="vncellreq">My Certificate</td>
621
                  <td width="78%" class="vtable">
622
                    <textarea name="cert" cols="65" rows="7" id="cert" class="formpre"><?=htmlspecialchars($pconfig['cert']);?></textarea>
623
                    <br>
624
                    Paste a certificate in X.509 PEM format here.</td>
625
                </tr>
626
                <tr>
627
                  <td width="22%" valign="top" class="vncellreq">My Private Key</td>
628
                  <td width="78%" class="vtable">
629
                    <textarea name="privatekey" cols="65" rows="7" id="privatekey" class="formpre"><?=htmlspecialchars($pconfig['privatekey']);?></textarea>
630
                    <br>
631
                    Paste an RSA private key in PEM format here.
632
                  </td>
633
                </tr>
634
                <tr>
635
                  <td width="22%" valign="top" class="vncell">Peer certificate</td>
636
                  <td width="78%" class="vtable">
637
                    <textarea name="peercert" cols="65" rows="7" id="peercert" class="formpre"><?=htmlspecialchars($pconfig['peercert']);?></textarea>
638
                    <br>
639
                    Paste the peer X.509 certificate in PEM format here.<br>
640
                    Leave this blank if you want to use a CA certificate for identity validation.
641
                  </td>
642
                </tr>
643
                <tr>
644
                  <td colspan="2" class="list" height="12"></td>
645
                </tr>
646
                <tr>
647
                  <td colspan="2" valign="top" class="listtopic">Advanced Options</td>
648
                </tr>
649
                <tr>
650
                  <td width="22%" valign="top" class="vncell">NAT Traversal</td>
651
                  <td width="78%" class="vtable">
652
                    <select name="nat_traversal" class="formselect">
653
                      <option value="off" <?php if ($pconfig['nat_traversal'] == "off") echo "selected"; ?>>Disable</option>
654
                      <option value="on" <?php if ($pconfig['nat_traversal'] == "on") echo "selected"; ?>>Enable</option>
655
                      <option value="force" <?php if ($pconfig['nat_traversal'] == "force") echo "selected"; ?>>Force</option>
656
                    </select>
657
                    <br/>
658
                    <span class="vexpl">
659
                      Set this option to enable the use of NAT-T (i.e. the encapsulation of ESP in UDP packets) if needed,
660
                      which can help with clients that are behind restrictive firewalls.
661
                    </span>
662
                  </td>
663
                </tr>
664
                <tr>
665
                  <td width="22%" valign="top" class="vncell">Dead Peer Detection</td>
666
                  <td width="78%" class="vtable">
667
                    <input name="dpd_enable" type="checkbox" id="dpd_enable" value="yes" <?php if (isset($pconfig['dpd_enable'])) echo "checked"; ?> onClick="dpdchkbox_change()">
668
                    Enable DPD<br>
669
                    <br>
670
                    <input name="dpd_delay" type="text" class="formfld unknown" id="dpd_delay" size="5" value="<?=$pconfig['dpd_delay'];?>">
671
                    seconds<br>
672
                    <span class="vexpl">Delay between requesting peer acknowledgement.</span><br>
673
                    <br>
674
                    <input name="dpd_maxfail" type="text" class="formfld unknown" id="dpd_maxfail" size="5" value="<?=$pconfig['dpd_maxfail'];?>">
675
                    retries<br>
676
                    <span class="vexpl">Number consecutive failures allowed before disconnect.</span><br>
677
                  </td>
678
                </tr>
679
                <tr>
680
                  <td width="22%" valign="top" class="vncell">Automatically ping host</td>
681
                  <td width="78%" class="vtable">
682
                    <input name="pinghost" type="text" class="formfld unknown" id="pinghost" size="20" value="<?=$pconfig['pinghost'];?>">
683
                    IP address
684
                  </td>
685
                </tr>
686
                <tr>
687
                  <td width="22%" valign="top">&nbsp;</td>
688
                  <td width="78%">
689
                    <?php if (isset($p1index) && $a_phase1[$p1index]): ?>
690
                    <input name="p1index" type="hidden" value="<?=$p1index;?>">
691
                    <?php endif; ?>
692
					<?php if ($pconfig['mobile']): ?>
693
                    <input name="mobile" type="hidden" value="true">
694
                    <?php endif; ?>
695
                    <input name="ikeid" type="hidden" value="<?=$pconfig['ikeid'];?>">
696
                    <input name="Submit" type="submit" class="formbtn" value="Save">
697
                  </td>
698
                </tr>
699
              </table>
700
</form>
701
<script lannguage="JavaScript">
702
<!--
703
<?php
704
	/* determine if we should init the key length */
705
	$keyset = '';
706
	if (isset($pconfig['ealgo']['keylen']))
707
		if (is_numeric($pconfig['ealgo']['keylen']))
708
			$keyset = $pconfig['ealgo']['keylen'];
709
?>
710
myidsel_change();
711
peeridsel_change();
712
methodsel_change();
713
ealgosel_change(<?=$keyset;?>);
714
dpdchkbox_change();
715
//-->
716
</script>
717
<?php include("fend.inc"); ?>
718
</body>
719
</html>
(178-178/200)