Project

General

Profile

Download (27.7 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
	$pconfig['remotegw'] = $a_phase1[$p1index]['remote-gateway'];
62
	$pconfig['mode'] = $a_phase1[$p1index]['mode'];
63
	$pconfig['myid_type'] = $a_phase1[$p1index]['myid_type'];
64
	$pconfig['myid_data'] = $a_phase1[$p1index]['myid_data'];
65
	$pconfig['peerid_type'] = $a_phase1[$p1index]['peerid_type'];
66
	$pconfig['peerid_data'] = $a_phase1[$p1index]['peerid_data'];
67
	$pconfig['ealgo'] = $a_phase1[$p1index]['encryption-algorithm'];
68
	$pconfig['halgo'] = $a_phase1[$p1index]['hash-algorithm'];
69
	$pconfig['dhgroup'] = $a_phase1[$p1index]['dhgroup'];
70
	$pconfig['lifetime'] = $a_phase1[$p1index]['lifetime'];
71
	$pconfig['authentication_method'] = $a_phase1[$p1index]['authentication_method'];
72
	$pconfig['pskey'] = $a_phase1[$p1index]['pre-shared-key'];
73
	$pconfig['cert'] = base64_decode($a_phase1[$p1index]['cert']);
74
	$pconfig['peercert'] = base64_decode($a_phase1[$p1index]['peercert']);
75
	$pconfig['privatekey'] = base64_decode($a_phase1[$p1index]['private-key']);
76

    
77
	$pconfig['descr'] = $a_phase1[$p1index]['descr'];
78
	$pconfig['nat_traversal'] = $a_phase1[$p1index]['nat_traversal'];
79
	$pconfig['dpd_enable'] = $a_phase1[$p1index]['dpd_enable'];
80
	$pconfig['dpd_delay'] = $a_phase1[$p1index]['dpd_delay'];
81
	$pconfig['dpd_maxfail'] = $a_phase1[$p1index]['dpd_maxfail'];
82
	$pconfig['pinghost'] = $a_phase1[$p1index]['pinghost'];
83
}
84
else
85
{
86
	/* defaults */
87
	$pconfig['interface'] = "wan";
88
	if($config['interfaces']['lan']) 
89
		$pconfig['localnet'] = "lan";
90
	$pconfig['mode'] = "aggressive";
91
	$pconfig['myid_type'] = "myaddress";
92
	$pconfig['peerid_type'] = "peeraddress";
93
	$pconfig['authentication_method'] = "pre_shared_key";
94
	$pconfig['ealgo'] = array( name => "3des" );
95
	$pconfig['halgo'] = "sha1";
96
	$pconfig['dhgroup'] = "2";
97
	$pconfig['lifetime'] = "28800";
98
	$pconfig['nat_traversal'] = "on";
99
	$pconfig['dpd_enable'] = 1;
100
	$pconfig['dpd_delay'] = 10;
101
	$pconfig['dpd_maxfail'] = 5;
102
}
103

    
104
if (isset($_GET['dup']))
105
	unset($p1index);
106

    
107
if ($_POST) {
108
	unset($input_errors);
109
	$pconfig = $_POST;
110

    
111
	/* input validation */
112
	if ($_POST['authentication_method'] == "pre_shared_key") {
113
		$reqdfields = explode(" ", "remotegw pskey");
114
		$reqdfieldsn = explode(",", "Remote gateway,Pre-Shared Key");
115
	} else	{
116
		$reqdfields = explode(" ", "remotegw");
117
		$reqdfieldsn = explode(",", "Remote gateway");
118
		if (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE"))
119
			$input_errors[] = "This certificate does not appear to be valid.";
120
		if (!strstr($_POST['privatekey'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['privatekey'], "END RSA PRIVATE KEY"))
121
			$input_errors[] = "This key does not appear to be valid.";
122
		if ($_POST['peercert']!="" && (!strstr($_POST['peercert'], "BEGIN CERTIFICATE") || !strstr($_POST['peercert'], "END CERTIFICATE")))
123
			$input_errors[] = "This peer certificate does not appear to be valid.";
124
	}
125

    
126
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
127

    
128
	if (($_POST['lifetime'] && !is_numeric($_POST['lifetime'])))
129
		$input_errors[] = "The P1 lifetime must be an integer.";
130

    
131
	if (($_POST['remotegw'] && !is_ipaddr($_POST['remotegw']) && !is_domain($_POST['remotegw']))) 
132
		$input_errors[] = "A valid remote gateway address or host name must be specified.";
133

    
134
	if (($_POST['remotegw'] && is_ipaddr($_POST['remotegw']) && !isset($_POST['disabled']) )) {
135
		$t = 0;
136
		foreach ($a_phase1 as $ph1tmp) {
137
			if ($p1index <> $t) {
138
				$tremotegw = $pconfig['remotegw'];
139
				if (($ph1tmp['remote-gateway'] == $tremotegw) && !isset($ph1tmp['disabled'])) {
140
					$input_errors[] = "The remote gateway \"$tremotegw\" is already used by phase1 \"${ph1tmp['descr']}\".";
141
				}
142
			}
143
			$t++;
144
		}
145
	}
146

    
147
	/* My identity */
148

    
149
	if ($_POST['myid_type'] == "myaddress")
150
		$_POST['myid_data'] = "";
151

    
152
	if ($_POST['myid_type'] == "address" and $_POST['myid_data'] == "")
153
		$input_errors[] = gettext("Please enter an address for 'My Identifier'");
154

    
155
	if ($_POST['myid_type'] == "keyid tag" and $_POST['myid_data'] == "")
156
		$input_errors[] = gettext("Please enter a keyid tag for 'My Identifier'");
157

    
158
	if ($_POST['myid_type'] == "fqdn" and $_POST['myid_data'] == "")
159
		$input_errors[] = gettext("Please enter a fully qualified domain name for 'My Identifier'");
160

    
161
	if ($_POST['myid_type'] == "user_fqdn" and $_POST['myid_data'] == "")
162
		$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'My Identifier'");
163

    
164
	if ($_POST['myid_type'] == "dyn_dns" and $_POST['myid_data'] == "")
165
		$input_errors[] = gettext("Please enter a dynamic domain name for 'My Identifier'");
166

    
167
	if ((($_POST['myid_type'] == "address") && !is_ipaddr($_POST['myid_data'])))
168
		$input_errors[] = "A valid IP address for 'My identifier' must be specified.";
169

    
170
	if ((($_POST['myid_type'] == "fqdn") && !is_domain($_POST['myid_data'])))
171
		$input_errors[] = "A valid domain name for 'My identifier' must be specified.";
172

    
173
	if ($_POST['myid_type'] == "fqdn")
174
		if (is_domain($_POST['myid_data']) == false)
175
			$input_errors[] = "A valid FQDN for 'My identifier' must be specified.";
176

    
177
	if ($_POST['myid_type'] == "user_fqdn") {
178
		$user_fqdn = explode("@",$_POST['myid_data']);
179
		if (is_domain($user_fqdn[1]) == false)
180
			$input_errors[] = "A valid User FQDN in the form of user@my.domain.com for 'My identifier' must be specified.";
181
	}
182

    
183
	if ($_POST['myid_type'] == "dyn_dns")
184
		if (is_domain($_POST['myid_data']) == false)
185
			$input_errors[] = "A valid Dynamic DNS address for 'My identifier' must be specified.";
186

    
187
	/* Peer identity */
188

    
189
	if ($_POST['peerid_type'] == "address" and $_POST['peerid_data'] == "")
190
		$input_errors[] = gettext("Please enter an address for 'Peer Identifier'");
191

    
192
	if ($_POST['peerid_type'] == "keyid tag" and $_POST['peerid_data'] == "")
193
		$input_errors[] = gettext("Please enter a keyid tag for 'Peer Identifier'");
194

    
195
	if ($_POST['peerid_type'] == "fqdn" and $_POST['peerid_data'] == "")
196
		$input_errors[] = gettext("Please enter a fully qualified domain name for 'Peer Identifier'");
197

    
198
	if ($_POST['peerid_type'] == "user_fqdn" and $_POST['peerid_data'] == "")
199
		$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'Peer Identifier'");
200

    
201
	if ((($_POST['peerid_type'] == "address") && !is_ipaddr($_POST['peerid_data'])))
202
		$input_errors[] = "A valid IP address for 'Peer identifier' must be specified.";
203

    
204
	if ((($_POST['peerid_type'] == "fqdn") && !is_domain($_POST['peerid_data'])))
205
		$input_errors[] = "A valid domain name for 'Peer identifier' must be specified.";
206

    
207
	if ($_POST['peerid_type'] == "fqdn")
208
		if (is_domain($_POST['peerid_data']) == false)
209
			$input_errors[] = "A valid FQDN for 'Peer identifier' must be specified.";
210

    
211
	if ($_POST['peerid_type'] == "user_fqdn") {
212
		$user_fqdn = explode("@",$_POST['peerid_data']);
213
		if (is_domain($user_fqdn[1]) == false)
214
			$input_errors[] = "A valid User FQDN in the form of user@my.domain.com for 'Peer identifier' must be specified.";
215
	}
216

    
217
	if ($_POST['dpd_enable']) {
218
		if (!is_numeric($_POST['dpd_delay']))
219
			$input_errors[] = "A numeric value must be specified for DPD delay.";
220

    
221
		if (!is_numeric($_POST['dpd_maxfail']))
222
			$input_errors[] = "A numeric value must be specified for DPD retries.";
223
	}
224

    
225
	/* build our encryption algorithms array */
226
	$pconfig['ealgo'] = array();
227
	$pconfig['ealgo']['name'] = $_POST['ealgo'];
228
        if($_POST['ealgo_keylen'])
229
		$pconfig['ealgo']['keylen'] = $_POST['ealgo_keylen'];
230

    
231
	if (!$input_errors) {
232
		$ph1ent['ikeid'] = $_POST['ikeid'];
233
		$ph1ent['disabled'] = $_POST['disabled'] ? true : false;
234
		$ph1ent['interface'] = $pconfig['interface'];
235
		/* if the remote gateway changed and the interface is not WAN then remove route */
236
		/* the vpn_ipsec_configure() handles adding the route */
237
		if ($_POST['interface'] <> "wan") {
238
			if($ph1ent['remote-gateway'] <> $_POST['remotegw']) {
239
				mwexec("/sbin/route delete -host {$ph1ent['remote-gateway']}");
240
			}
241
		}
242
		$ph1ent['remote-gateway'] = $_POST['remotegw'];
243
		$ph1ent['mode'] = $_POST['mode'];
244

    
245
		$ph1ent['myid_type'] = $_POST['myid_type'];
246
		$ph1ent['myid_data'] = $_POST['myid_data'];
247
		$ph1ent['peerid_type'] = $_POST['peerid_type'];
248
		$ph1ent['peerid_data'] = $_POST['peerid_data'];
249

    
250
		$ph1ent['encryption-algorithm'] = $pconfig['ealgo'];
251
		$ph1ent['hash-algorithm'] = $_POST['halgo'];
252
		$ph1ent['dhgroup'] = $_POST['dhgroup'];
253
		$ph1ent['lifetime'] = $_POST['lifetime'];
254
		$ph1ent['pre-shared-key'] = $_POST['pskey'];
255
		$ph1ent['private-key'] = base64_encode($_POST['privatekey']);
256
		$ph1ent['cert'] = base64_encode($_POST['cert']);
257
		$ph1ent['peercert'] = base64_encode($_POST['peercert']);
258
		$ph1ent['authentication_method'] = $_POST['authentication_method'];
259

    
260
		$ph1ent['descr'] = $_POST['descr'];
261
		$ph1ent['nat_traversal'] = $_POST['nat_traversal'];
262
		$ph1ent['dpd_enable'] = $_POST['dpd_enable'];
263
		$ph1ent['dpd_delay'] = $_POST['dpd_delay'];
264
		$ph1ent['dpd_maxfail'] = $_POST['dpd_maxfail'];
265
		$ph1ent['pinghost'] = $_POST['pinghost'];
266

    
267
		/* generate unique phase1 ikeid */
268
		if ($ph1ent['ikeid'] == 0) {
269
			while (true) {
270
				$ph1ent['ikeid']++;
271
				foreach ($a_phase1 as $ph1tmp)
272
					if( $ph1ent['ikeid'] == $ph1tmp['ikeid'] )
273
						break;
274

    
275
				if( $ph1ent['ikeid'] != $ph1tmp['ikeid'] )
276
					break;
277
			}
278
		}
279

    
280
		if (isset($p1index) && $a_phase1[$p1index])
281
			$a_phase1[$p1index] = $ph1ent;
282
		else
283
			$a_phase1[] = $ph1ent;
284

    
285
		write_config();
286
		touch($d_ipsecconfdirty_path);
287

    
288
		header("Location: vpn_ipsec.php");
289
		exit;
290
	}
291
}
292

    
293
$pgtitle = array("VPN","IPsec","Edit Phase 1");
294
include("head.inc");
295

    
296
?>
297

    
298
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
299
<?php include("fbegin.inc"); ?>
300
<script language="JavaScript">
301
<!--
302
function methodsel_change() {
303
	switch (document.iform.authentication_method.selectedIndex) {
304
		case 1:	/* rsa */
305
			document.iform.pskey.disabled = 1;
306
			document.iform.privatekey.disabled = 0;
307
			document.iform.cert.disabled = 0;
308
			document.iform.peercert.disabled = 0;
309
			break;
310
		default: /* pre-shared */
311
			document.iform.pskey.disabled = 0;
312
			document.iform.privatekey.disabled = 1;
313
			document.iform.cert.disabled = 1;
314
			document.iform.peercert.disabled = 1;
315
			break;
316
	}
317
}
318

    
319
/* PHP generated java script for variable length keys */
320
function ealgosel_change(bits) {
321
	switch (document.iform.ealgo.selectedIndex) {
322
<?php
323
  $i = 0;
324
  foreach ($p1_ealgos as $algo => $algodata) {
325
    if (is_array($algodata['keysel'])) {
326
      echo "		case {$i}:\n";
327
      echo "			document.iform.ealgo_keylen.style.visibility = 'visible';\n";
328
      echo "			document.iform.ealgo_keylen.options.length = 0;\n";
329
//      echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( 'auto', 'auto' );\n";
330

    
331
      $key_hi = $algodata['keysel']['hi'];
332
      $key_lo = $algodata['keysel']['lo'];
333
      $key_step = $algodata['keysel']['step'];
334

    
335
      for ($keylen = $key_hi; $keylen >= $key_lo; $keylen -= $key_step)
336
        echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( '{$keylen} bits', '{$keylen}' );\n";
337
      echo "			break;\n";
338
    } else {
339
      echo "		case {$i}:\n";
340
      echo "			document.iform.ealgo_keylen.style.visibility = 'hidden';\n";
341
      echo "			document.iform.ealgo_keylen.options.length = 0;\n";
342
      echo "			break;\n";
343
    }
344
    $i++;
345
  }
346
?>
347
	}
348

    
349
	if( bits )
350
		document.iform.ealgo_keylen.value = bits;
351
}
352
function dpdchkbox_change() {
353
	if( document.iform.dpd_enable.checked ) {
354
			document.iform.dpd_delay.disabled = 0;
355
			document.iform.dpd_maxfail.disabled = 0;
356
	} else {
357
			document.iform.dpd_delay.disabled = 1;
358
			document.iform.dpd_maxfail.disabled = 1;
359
	}
360
}
361
//-->
362
</script>
363
<?php if ($input_errors) print_input_errors($input_errors); ?>
364
            <form action="vpn_ipsec_phase1.php" method="post" name="iform" id="iform">
365
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
366
                <tr>
367
                  <td width="22%" valign="top" class="vncellreq">Disabled</td>
368
                  <td width="78%" class="vtable">
369
                    <input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
370
                    <strong>Disable this phase1 entry</strong><br>
371
                    <span class="vexpl">Set this option to disable this phase1 without
372
                      removing it from the list.
373
                    </span>
374
                  </td>
375
                </tr>
376
                <tr>
377
                  <td width="22%" valign="top" class="vncellreq">Interface</td>
378
                  <td width="78%" class="vtable">
379
                    <select name="interface" class="formselect">
380
                      <?php 
381
                        $interfaces = get_configured_interface_with_descr();
382
                        $carpips = find_number_of_needed_carp_interfaces();
383
                        for ($i=0; $i<$carpips; $i++) {
384
                          $carpip = find_interface_ip("carp" . $i);
385
                          $interfaces['carp' . $i] = "CARP{$i} ({$carpip})"; 
386
                        }
387
                        foreach ($interfaces as $iface => $ifacename):
388
                      ?>
389
                      <option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
390
                        <?=htmlspecialchars($ifacename);?>
391
                      </option>
392
                      <?php endforeach; ?>
393
                    </select> <br>
394
                    <span class="vexpl">Select the interface for the local endpoint of this phase1 entry.</span>
395
                  </td>
396
                </tr>
397
                <tr>
398
                  <td width="22%" valign="top" class="vncellreq">Remote gateway</td>
399
                  <td width="78%" class="vtable">
400
                    <?=$mandfldhtml;?><input name="remotegw" type="text" class="formfld unknown" id="remotegw" size="20" value="<?=$pconfig['remotegw'];?>">
401
                    <br>
402
                    Enter the public IP address or host name of the remote gateway
403
                  </td>
404
                </tr>
405
                <tr>
406
                  <td width="22%" valign="top" class="vncell">Description</td>
407
                  <td width="78%" class="vtable">
408
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
409
                    <br> <span class="vexpl">You may enter a description here
410
                    for your reference (not parsed).</span>
411
                  </td>
412
                </tr>
413
                <tr>
414
                  <td colspan="2" class="list" height="12"></td>
415
                </tr>
416
                <tr>
417
                  <td colspan="2" valign="top" class="listtopic">Phase 1 proposal
418
                    (Authentication)
419
                  </td>
420
                </tr>
421
                <tr>
422
                  <td width="22%" valign="top" class="vncellreq">Negotiation mode</td>
423
                  <td width="78%" class="vtable">
424
                    <select name="mode" class="formselect">
425
                      <?php
426
                        $modes = explode(" ", "main aggressive");
427
                        foreach ($modes as $mode):
428
                      ?>
429
                      <option value="<?=$mode;?>" <?php if ($mode == $pconfig['mode']) echo "selected"; ?>>
430
                        <?=htmlspecialchars($mode);?>
431
                      </option>
432
                      <?php endforeach; ?>
433
                    </select> <br> <span class="vexpl">Aggressive is more flexible, but less secure.</span>
434
                  </td>
435
                </tr>
436
                <tr>
437
                  <td width="22%" valign="top" class="vncellreq">My identifier</td>
438
                  <td width="78%" class="vtable">
439
                    <select name="myid_type" class="formselect">
440
                      <?php foreach ($my_identifier_list as $mode => $modename): ?>
441
                        <option value="<?=$mode;?>" <?php if ($mode == $pconfig['myid_type']) echo "selected"; ?>>
442
                          <?=htmlspecialchars($modename);?>
443
                        </option>
444
                      <?php endforeach; ?>
445
                    </select>
446
                    <input name="myid_data" type="text" class="formfld unknown" id="myid_data" size="30" value="<?=$pconfig['myid_data'];?>">
447
                  </td>
448
                </tr>
449
                <tr>
450
                  <td width="22%" valign="top" class="vncellreq">Peer identifier</td>
451
                  <td width="78%" class="vtable">
452
                    <select name="peerid_type" class="formselect">
453
                      <?php foreach ($peer_identifier_list as $mode => $modename): ?>
454
                      <option value="<?=$mode;?>" <?php if ($mode == $pconfig['peerid_type']) echo "selected"; ?>>
455
                        <?=htmlspecialchars($modename);?>
456
                      </option>
457
                      <?php endforeach; ?>
458
                    </select>
459
                    <input name="peerid_data" type="text" class="formfld unknown" id="peerid_data" size="30" value="<?=$pconfig['peerid_data'];?>">
460
                  </td>
461
                </tr>
462
                <tr>
463
                  <td width="22%" valign="top" class="vncellreq">Encryption algorithm</td>
464
                  <td width="78%" class="vtable">
465
                    <select name="ealgo" class="formselect" onChange="ealgosel_change()">
466
                      <?php
467
                        foreach ($p1_ealgos as $algo => $algodata):
468
                        $selected = '';
469
                        if ($algo == $pconfig['ealgo']['name'])
470
                          $selected = ' selected';
471
                      ?>
472
                      <option value="<?=$algo;?>"<?=$selected?>>
473
                        <?=htmlspecialchars($algodata['name']);?>
474
                      </option>
475
                    <?php endforeach; ?>
476
                    </select>
477
                    <select name="ealgo_keylen" width="30" class="formselect">
478
                    </select>
479
                  </td>
480
                </tr>
481
                <tr>
482
                  <td width="22%" valign="top" class="vncellreq">Hash algorithm</td>
483
                  <td width="78%" class="vtable">
484
                    <select name="halgo" class="formselect">
485
                      <?php foreach ($p1_halgos as $algo => $algoname): ?>
486
                      <option value="<?=$algo;?>" <?php if ($algo == $pconfig['halgo']) echo "selected"; ?>>
487
                        <?=htmlspecialchars($algoname);?>
488
                      </option>
489
                      <?php endforeach; ?>
490
                    </select>
491
                    <br>
492
                    <span class="vexpl">
493
                      Must match the setting chosen on the remote side.
494
                    </span>
495
                  </td>
496
                </tr>
497
                <tr>
498
                  <td width="22%" valign="top" class="vncellreq">DH key group</td>
499
                  <td width="78%" class="vtable">
500
                    <select name="dhgroup" class="formselect">
501
                      <?php $keygroups = explode(" ", "1 2 5"); foreach ($keygroups as $keygroup): ?>
502
                      <option value="<?=$keygroup;?>" <?php if ($keygroup == $pconfig['dhgroup']) echo "selected"; ?>>
503
                        <?=htmlspecialchars($keygroup);?>
504
                      </option>
505
                      <?php endforeach; ?>
506
                    </select>
507
                    <br>
508
                    <span class="vexpl">
509
                      <em>1 = 768 bit, 2 = 1024 bit, 5 = 1536 bit</em>
510
                      <br>
511
                      Must match the setting chosen on the remote side.
512
                    </span>
513
                  </td>
514
                </tr>
515
                <tr>
516
                  <td width="22%" valign="top" class="vncell">Lifetime</td>
517
                  <td width="78%" class="vtable">
518
                    <input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="20" value="<?=$pconfig['lifetime'];?>">
519
                    seconds
520
                  </td>
521
                </tr>
522
                <tr>
523
                  <td width="22%" valign="top" class="vncellreq">Authentication method</td>
524
                  <td width="78%" class="vtable">
525
                    <select name="authentication_method" class="formselect" onChange="methodsel_change()">
526
                      <?php foreach ($p1_authentication_methods as $method => $methodname): ?>
527
                      <option value="<?=$method;?>" <?php if ($method == $pconfig['authentication_method']) echo "selected"; ?>>
528
                        <?=htmlspecialchars($methodname);?>
529
                      </option>
530
                      <?php endforeach; ?>
531
                    </select>
532
                    <br>
533
                    <span class="vexpl">Must match the setting chosen on the remote side.</span>
534
                  </td>
535
                </tr>
536
                <tr>
537
                  <td width="22%" valign="top" class="vncellreq">Pre-Shared Key</td>
538
                  <td width="78%" class="vtable">
539
                    <?=$mandfldhtml;?><input name="pskey" type="text" class="formfld unknown" id="pskey" size="40" value="<?=htmlspecialchars($pconfig['pskey']);?>">
540
                  </td>
541
                </tr>
542
                <tr>
543
                  <td width="22%" valign="top" class="vncellreq">My Certificate</td>
544
                  <td width="78%" class="vtable">
545
                    <textarea name="cert" cols="65" rows="7" id="cert" class="formpre"><?=htmlspecialchars($pconfig['cert']);?></textarea>
546
                    <br>
547
                    Paste a certificate in X.509 PEM format here.</td>
548
                </tr>
549
                <tr>
550
                  <td width="22%" valign="top" class="vncellreq">My Private Key</td>
551
                  <td width="78%" class="vtable">
552
                    <textarea name="privatekey" cols="65" rows="7" id="privatekey" class="formpre"><?=htmlspecialchars($pconfig['privatekey']);?></textarea>
553
                    <br>
554
                    Paste an RSA private key in PEM format here.
555
                  </td>
556
                </tr>
557
                <tr>
558
                  <td width="22%" valign="top" class="vncell">Peer certificate</td>
559
                  <td width="78%" class="vtable">
560
                    <textarea name="peercert" cols="65" rows="7" id="peercert" class="formpre"><?=htmlspecialchars($pconfig['peercert']);?></textarea>
561
                    <br>
562
                    Paste the peer X.509 certificate in PEM format here.<br>
563
                    Leave this blank if you want to use a CA certificate for identity validation.
564
                  </td>
565
                </tr>
566
                <tr>
567
                  <td colspan="2" class="list" height="12"></td>
568
                </tr>
569
                <tr>
570
                  <td colspan="2" valign="top" class="listtopic">Advanced Options</td>
571
                </tr>
572
                <tr>
573
                  <td width="22%" valign="top" class="vncell">NAT Traversal</td>
574
                  <td width="78%" class="vtable">
575
                    <select name="nat_traversal" class="formselect">
576
                      <option value="off" <?php if ($pconfig['nat_traversal'] == "off") echo "selected"; ?>>Disable</option>
577
                      <option value="on" <?php if ($pconfig['nat_traversal'] == "on") echo "selected"; ?>>Enable</option>
578
                      <option value="force" <?php if ($pconfig['nat_traversal'] == "force") echo "selected"; ?>>Force</option>
579
                    </select>
580
                    <br/>
581
                    <span class="vexpl">
582
                      Set this option to enable the use of NAT-T (i.e. the encapsulation of ESP in UDP packets) if needed,
583
                      which can help with clients that are behind restrictive firewalls.
584
                    </span>
585
                  </td>
586
                </tr>
587
                <tr>
588
                  <td width="22%" valign="top" class="vncell">Dead Peer Detection</td>
589
                  <td width="78%" class="vtable">
590
                    <input name="dpd_enable" type="checkbox" id="dpd_enable" value="yes" <?php if ($pconfig['dpd_enable']) echo "checked"; ?> onClick="dpdchkbox_change()">
591
                    Enable DPD<br>
592
                    <br>
593
	            <input name="dpd_delay" type="text" class="formfld unknown" id="dpd_delay" size="5" value="<?=$pconfig['dpd_delay'];?>">
594
                    seconds<br>
595
                    <span class="vexpl">Delay between requesting peer acknowledgement.</span><br>
596
                    <br>
597
                    <input name="dpd_maxfail" type="text" class="formfld unknown" id="dpd_maxfail" size="5" value="<?=$pconfig['dpd_maxfail'];?>">
598
                    retries<br>
599
                    <span class="vexpl">Number consecutive failures allowed before disconnect.</span><br>
600
                  </td>
601
                </tr>
602
                <tr>
603
                  <td width="22%" valign="top" class="vncell">Automatically ping host</td>
604
                  <td width="78%" class="vtable">
605
                    <input name="pinghost" type="text" class="formfld unknown" id="pinghost" size="20" value="<?=$pconfig['pinghost'];?>">
606
                    IP address
607
                  </td>
608
                </tr>
609
                <tr>
610
                  <td width="22%" valign="top">&nbsp;</td>
611
                  <td width="78%">
612
                    <input name="Submit" type="submit" class="formbtn" value="Save">
613
                    <input name="ikeid" type="hidden" value="<?=$pconfig['ikeid'];?>">
614
                    <?php if (isset($p1index) && $a_phase1[$p1index]): ?>
615
                    <input name="p1index" type="hidden" value="<?=$p1index;?>">
616
                    <?php endif; ?>
617
                  </td>
618
                </tr>
619
              </table>
620
</form>
621
<script lannguage="JavaScript">
622
<!--
623
<?php
624
	/* determine if we should init the key length */
625
	$keyset = '';
626
	if (isset($pconfig['ealgo']['keylen']))
627
		if (is_numeric($pconfig['ealgo']['keylen']))
628
			$keyset = $pconfig['ealgo']['keylen'];
629
?>
630
methodsel_change();
631
ealgosel_change(<?=$keyset;?>);
632
dpdchkbox_change();
633
//-->
634
</script>
635
<?php include("fend.inc"); ?>
(175-175/197)