Project

General

Profile

Download (30.3 KB) Statistics
| Branch: | Tag: | Revision:
1 a93e56c5 Matthew Grooms
<?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 6b07c15a Matthew Grooms
##|+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
40 a93e56c5 Matthew Grooms
require("guiconfig.inc");
41
42
if (!is_array($config['ipsec']['phase1']))
43
	$config['ipsec']['phase1'] = array();
44
45
$a_phase1 = &$config['ipsec']['phase1'];
46
47
if($config['interfaces']['lan']) 
48
		$specialsrcdst = explode(" ", "lan");
49
50
$p1index = $_GET['p1index'];
51
if (isset($_POST['p1index']))
52
	$p1index = $_POST['p1index'];
53
54
if (isset($_GET['dup'])) {
55
	$p1index = $_GET['dup'];
56
}
57
58
if (isset($p1index) && $a_phase1[$p1index])
59
{
60 99bbd213 Matthew Grooms
	// don't copy the ikeid on dup
61
	if (!isset($_GET['dup']))
62
		$pconfig['ikeid'] = $a_phase1[$p1index]['ikeid'];
63
64 a93e56c5 Matthew Grooms
	$pconfig['disabled'] = isset($a_phase1[$p1index]['disabled']);
65
66
	if ($a_phase1[$p1index]['interface'])
67
		$pconfig['interface'] = $a_phase1[$p1index]['interface'];
68
	else
69
		$pconfig['interface'] = "wan";
70
71
	list($pconfig['remotenet'],$pconfig['remotebits']) = explode("/", $a_phase1[$p1index]['remote-subnet']);
72 3462a529 Matthew Grooms
73
	if (isset($a_phase1[$p1index]['mobile']))
74
		$pconfig['mobile'] = 'true';
75
	else
76
		$pconfig['remotegw'] = $a_phase1[$p1index]['remote-gateway'];
77
78 a93e56c5 Matthew Grooms
	$pconfig['mode'] = $a_phase1[$p1index]['mode'];
79
	$pconfig['myid_type'] = $a_phase1[$p1index]['myid_type'];
80
	$pconfig['myid_data'] = $a_phase1[$p1index]['myid_data'];
81
	$pconfig['peerid_type'] = $a_phase1[$p1index]['peerid_type'];
82
	$pconfig['peerid_data'] = $a_phase1[$p1index]['peerid_data'];
83
	$pconfig['ealgo'] = $a_phase1[$p1index]['encryption-algorithm'];
84
	$pconfig['halgo'] = $a_phase1[$p1index]['hash-algorithm'];
85
	$pconfig['dhgroup'] = $a_phase1[$p1index]['dhgroup'];
86
	$pconfig['lifetime'] = $a_phase1[$p1index]['lifetime'];
87
	$pconfig['authentication_method'] = $a_phase1[$p1index]['authentication_method'];
88 4e2af464 Matthew Grooms
89
	if (($pconfig['authentication_method'] == "pre_shared_key")||
90
		($pconfig['authentication_method'] == "xauth_psk_server")) {
91
		$pconfig['pskey'] = $a_phase1[$p1index]['pre-shared-key'];
92
	} else {
93
		$pconfig['cert'] = base64_decode($a_phase1[$p1index]['cert']);
94
		$pconfig['peercert'] = base64_decode($a_phase1[$p1index]['peercert']);
95
		$pconfig['privatekey'] = base64_decode($a_phase1[$p1index]['private-key']);
96
	}
97 a93e56c5 Matthew Grooms
98
	$pconfig['descr'] = $a_phase1[$p1index]['descr'];
99
	$pconfig['nat_traversal'] = $a_phase1[$p1index]['nat_traversal'];
100 3462a529 Matthew Grooms
101
	if ($a_phase1[$p1index]['dpd_delay'] &&	$a_phase1[$p1index]['dpd_maxfail']) {
102
		$pconfig['dpd_enable'] = true;
103
		$pconfig['dpd_delay'] = $a_phase1[$p1index]['dpd_delay'];
104
		$pconfig['dpd_maxfail'] = $a_phase1[$p1index]['dpd_maxfail'];
105
	}
106
107 a93e56c5 Matthew Grooms
	$pconfig['pinghost'] = $a_phase1[$p1index]['pinghost'];
108
}
109
else
110
{
111
	/* defaults */
112
	$pconfig['interface'] = "wan";
113
	if($config['interfaces']['lan']) 
114
		$pconfig['localnet'] = "lan";
115
	$pconfig['mode'] = "aggressive";
116
	$pconfig['myid_type'] = "myaddress";
117
	$pconfig['peerid_type'] = "peeraddress";
118
	$pconfig['authentication_method'] = "pre_shared_key";
119
	$pconfig['ealgo'] = array( name => "3des" );
120
	$pconfig['halgo'] = "sha1";
121
	$pconfig['dhgroup'] = "2";
122
	$pconfig['lifetime'] = "28800";
123
	$pconfig['nat_traversal'] = "on";
124 3462a529 Matthew Grooms
	$pconfig['dpd_enable'] = true;
125
126
	/* mobile client */
127
	if($_GET['mobile'])
128
		$pconfig['mobile']=true;
129 a93e56c5 Matthew Grooms
}
130
131
if (isset($_GET['dup']))
132
	unset($p1index);
133
134
if ($_POST) {
135
	unset($input_errors);
136
	$pconfig = $_POST;
137
138
	/* input validation */
139 3462a529 Matthew Grooms
140
	$method = $pconfig['authentication_method'];
141
	if (($method == "pre_shared_key")||($method == "xauth_psk_server")) {
142
		$reqdfields = explode(" ", "pskey");
143
		$reqdfieldsn = explode(",", "Pre-Shared Key");
144 a93e56c5 Matthew Grooms
	} else	{
145 3462a529 Matthew Grooms
		if (!strstr($pconfig['cert'], "BEGIN CERTIFICATE") || !strstr($pconfig['cert'], "END CERTIFICATE"))
146 a93e56c5 Matthew Grooms
			$input_errors[] = "This certificate does not appear to be valid.";
147 3462a529 Matthew Grooms
		if (!strstr($pconfig['privatekey'], "BEGIN RSA PRIVATE KEY") || !strstr($pconfig['privatekey'], "END RSA PRIVATE KEY"))
148 a93e56c5 Matthew Grooms
			$input_errors[] = "This key does not appear to be valid.";
149 3462a529 Matthew Grooms
		if ($pconfig['peercert']!="" && (!strstr($pconfig['peercert'], "BEGIN CERTIFICATE") || !strstr($pconfig['peercert'], "END CERTIFICATE")))
150 a93e56c5 Matthew Grooms
			$input_errors[] = "This peer certificate does not appear to be valid.";
151
	}
152 3462a529 Matthew Grooms
	if (!$pconfig['mobile']) {
153
		$reqdfields[] = "remotegw";
154
		$reqdfieldsn[] = "Remote gateway";
155
	}
156 a93e56c5 Matthew Grooms
157 3462a529 Matthew Grooms
	do_input_validation($pconfig, $reqdfields, $reqdfieldsn, &$input_errors);
158 a93e56c5 Matthew Grooms
159 3462a529 Matthew Grooms
	if (($pconfig['lifetime'] && !is_numeric($pconfig['lifetime'])))
160 a93e56c5 Matthew Grooms
		$input_errors[] = "The P1 lifetime must be an integer.";
161
162 3462a529 Matthew Grooms
	if (($pconfig['remotegw'] && !is_ipaddr($pconfig['remotegw']) && !is_domain($pconfig['remotegw']))) 
163 a93e56c5 Matthew Grooms
		$input_errors[] = "A valid remote gateway address or host name must be specified.";
164
165 3462a529 Matthew Grooms
	if (($pconfig['remotegw'] && is_ipaddr($pconfig['remotegw']) && !isset($pconfig['disabled']) )) {
166 a93e56c5 Matthew Grooms
		$t = 0;
167
		foreach ($a_phase1 as $ph1tmp) {
168
			if ($p1index <> $t) {
169
				$tremotegw = $pconfig['remotegw'];
170
				if (($ph1tmp['remote-gateway'] == $tremotegw) && !isset($ph1tmp['disabled'])) {
171
					$input_errors[] = "The remote gateway \"$tremotegw\" is already used by phase1 \"${ph1tmp['descr']}\".";
172
				}
173
			}
174
			$t++;
175
		}
176
	}
177
178
	/* My identity */
179
180 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "myaddress")
181
		$pconfig['myid_data'] = "";
182 a93e56c5 Matthew Grooms
183 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "address" and $pconfig['myid_data'] == "")
184 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter an address for 'My Identifier'");
185
186 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "keyid tag" and $pconfig['myid_data'] == "")
187 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter a keyid tag for 'My Identifier'");
188
189 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "fqdn" and $pconfig['myid_data'] == "")
190 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter a fully qualified domain name for 'My Identifier'");
191
192 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "user_fqdn" and $pconfig['myid_data'] == "")
193 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'My Identifier'");
194
195 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "dyn_dns" and $pconfig['myid_data'] == "")
196 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter a dynamic domain name for 'My Identifier'");
197
198 3462a529 Matthew Grooms
	if ((($pconfig['myid_type'] == "address") && !is_ipaddr($pconfig['myid_data'])))
199 a93e56c5 Matthew Grooms
		$input_errors[] = "A valid IP address for 'My identifier' must be specified.";
200
201 3462a529 Matthew Grooms
	if ((($pconfig['myid_type'] == "fqdn") && !is_domain($pconfig['myid_data'])))
202 a93e56c5 Matthew Grooms
		$input_errors[] = "A valid domain name for 'My identifier' must be specified.";
203
204 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "fqdn")
205
		if (is_domain($pconfig['myid_data']) == false)
206 a93e56c5 Matthew Grooms
			$input_errors[] = "A valid FQDN for 'My identifier' must be specified.";
207
208 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "user_fqdn") {
209
		$user_fqdn = explode("@",$pconfig['myid_data']);
210 a93e56c5 Matthew Grooms
		if (is_domain($user_fqdn[1]) == false)
211
			$input_errors[] = "A valid User FQDN in the form of user@my.domain.com for 'My identifier' must be specified.";
212
	}
213
214 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "dyn_dns")
215
		if (is_domain($pconfig['myid_data']) == false)
216 a93e56c5 Matthew Grooms
			$input_errors[] = "A valid Dynamic DNS address for 'My identifier' must be specified.";
217
218
	/* Peer identity */
219
220 3462a529 Matthew Grooms
	if ($pconfig['myid_type'] == "peeraddress")
221
		$pconfig['peerid_data'] = "";
222
223
	if ($pconfig['peerid_type'] == "address" and $pconfig['peerid_data'] == "")
224 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter an address for 'Peer Identifier'");
225
226 3462a529 Matthew Grooms
	if ($pconfig['peerid_type'] == "keyid tag" and $pconfig['peerid_data'] == "")
227 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter a keyid tag for 'Peer Identifier'");
228
229 3462a529 Matthew Grooms
	if ($pconfig['peerid_type'] == "fqdn" and $pconfig['peerid_data'] == "")
230 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter a fully qualified domain name for 'Peer Identifier'");
231
232 3462a529 Matthew Grooms
	if ($pconfig['peerid_type'] == "user_fqdn" and $pconfig['peerid_data'] == "")
233 a93e56c5 Matthew Grooms
		$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'Peer Identifier'");
234
235 3462a529 Matthew Grooms
	if ((($pconfig['peerid_type'] == "address") && !is_ipaddr($pconfig['peerid_data'])))
236 a93e56c5 Matthew Grooms
		$input_errors[] = "A valid IP address for 'Peer identifier' must be specified.";
237
238 3462a529 Matthew Grooms
	if ((($pconfig['peerid_type'] == "fqdn") && !is_domain($pconfig['peerid_data'])))
239 a93e56c5 Matthew Grooms
		$input_errors[] = "A valid domain name for 'Peer identifier' must be specified.";
240
241 3462a529 Matthew Grooms
	if ($pconfig['peerid_type'] == "fqdn")
242
		if (is_domain($pconfig['peerid_data']) == false)
243 a93e56c5 Matthew Grooms
			$input_errors[] = "A valid FQDN for 'Peer identifier' must be specified.";
244
245 3462a529 Matthew Grooms
	if ($pconfig['peerid_type'] == "user_fqdn") {
246
		$user_fqdn = explode("@",$pconfig['peerid_data']);
247 a93e56c5 Matthew Grooms
		if (is_domain($user_fqdn[1]) == false)
248
			$input_errors[] = "A valid User FQDN in the form of user@my.domain.com for 'Peer identifier' must be specified.";
249
	}
250
251 3462a529 Matthew Grooms
	if ($pconfig['dpd_enable']) {
252
		if (!is_numeric($pconfig['dpd_delay']))
253 a93e56c5 Matthew Grooms
			$input_errors[] = "A numeric value must be specified for DPD delay.";
254
255 3462a529 Matthew Grooms
		if (!is_numeric($pconfig['dpd_maxfail']))
256 a93e56c5 Matthew Grooms
			$input_errors[] = "A numeric value must be specified for DPD retries.";
257
	}
258
259
	/* build our encryption algorithms array */
260
	$pconfig['ealgo'] = array();
261
	$pconfig['ealgo']['name'] = $_POST['ealgo'];
262 3462a529 Matthew Grooms
	if($pconfig['ealgo_keylen'])
263 a93e56c5 Matthew Grooms
		$pconfig['ealgo']['keylen'] = $_POST['ealgo_keylen'];
264
265
	if (!$input_errors) {
266 3462a529 Matthew Grooms
		$ph1ent['ikeid'] = $pconfig['ikeid'];
267
		$ph1ent['disabled'] = $pconfig['disabled'] ? true : false;
268 a93e56c5 Matthew Grooms
		$ph1ent['interface'] = $pconfig['interface'];
269
		/* if the remote gateway changed and the interface is not WAN then remove route */
270
		/* the vpn_ipsec_configure() handles adding the route */
271 3462a529 Matthew Grooms
		if ($pconfig['interface'] <> "wan") {
272
			if($ph1ent['remote-gateway'] <> $pconfig['remotegw']) {
273 a93e56c5 Matthew Grooms
				mwexec("/sbin/route delete -host {$ph1ent['remote-gateway']}");
274
			}
275
		}
276
277 3462a529 Matthew Grooms
		if ($pconfig['mobile'])
278
			$ph1ent['mobile'] = true;
279
		else
280
			$ph1ent['remote-gateway'] = $pconfig['remotegw'];
281
282
		$ph1ent['mode'] = $pconfig['mode'];
283
284
		$ph1ent['myid_type'] = $pconfig['myid_type'];
285
		$ph1ent['myid_data'] = $pconfig['myid_data'];
286
		$ph1ent['peerid_type'] = $pconfig['peerid_type'];
287
		$ph1ent['peerid_data'] = $pconfig['peerid_data'];
288 a93e56c5 Matthew Grooms
289
		$ph1ent['encryption-algorithm'] = $pconfig['ealgo'];
290 3462a529 Matthew Grooms
		$ph1ent['hash-algorithm'] = $pconfig['halgo'];
291
		$ph1ent['dhgroup'] = $pconfig['dhgroup'];
292
		$ph1ent['lifetime'] = $pconfig['lifetime'];
293
		$ph1ent['pre-shared-key'] = $pconfig['pskey'];
294
		$ph1ent['private-key'] = base64_encode($pconfig['privatekey']);
295
		$ph1ent['cert'] = base64_encode($pconfig['cert']);
296
		$ph1ent['peercert'] = base64_encode($pconfig['peercert']);
297
		$ph1ent['authentication_method'] = $pconfig['authentication_method'];
298
299
		$ph1ent['descr'] = $pconfig['descr'];
300
		$ph1ent['nat_traversal'] = $pconfig['nat_traversal'];
301
302
		if (isset($pconfig['dpd_enable'])) {
303
			$ph1ent['dpd_delay'] = $pconfig['dpd_delay'];
304
			$ph1ent['dpd_maxfail'] = $pconfig['dpd_maxfail'];
305
		}
306
307
		$ph1ent['pinghost'] = $pconfig['pinghost'];
308 a93e56c5 Matthew Grooms
309
		/* generate unique phase1 ikeid */
310 d799787e Matthew Grooms
		if ($ph1ent['ikeid'] == 0)
311
			$ph1ent['ikeid'] = ipsec_ikeid_next();
312 a93e56c5 Matthew Grooms
313
		if (isset($p1index) && $a_phase1[$p1index])
314
			$a_phase1[$p1index] = $ph1ent;
315
		else
316
			$a_phase1[] = $ph1ent;
317
318
		write_config();
319
		touch($d_ipsecconfdirty_path);
320
321
		header("Location: vpn_ipsec.php");
322
		exit;
323
	}
324
}
325
326 3462a529 Matthew Grooms
if ($pconfig['mobile'])
327
	$pgtitle = array("VPN","IPsec","Edit Phase 1", "Mobile Client");
328
else
329
	$pgtitle = array("VPN","IPsec","Edit Phase 1");
330
331 a93e56c5 Matthew Grooms
include("head.inc");
332
333
?>
334
335
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
336
<?php include("fbegin.inc"); ?>
337
<script language="JavaScript">
338
<!--
339 3462a529 Matthew Grooms
340
function myidsel_change() {
341
	index = document.iform.myid_type.selectedIndex;
342
	value = document.iform.myid_type.options[index].value;
343
	if (value == 'myaddress')
344
			document.iform.myid_data.style.visibility = 'hidden';
345
	else
346
			document.iform.myid_data.style.visibility = 'visible';
347
}
348
349
function peeridsel_change() {
350
	index = document.iform.peerid_type.selectedIndex;
351
	value = document.iform.peerid_type.options[index].value;
352
	if (value == 'peeraddress')
353
			document.iform.peerid_data.style.visibility = 'hidden';
354
	else
355
			document.iform.peerid_data.style.visibility = 'visible';
356
}
357
358 a93e56c5 Matthew Grooms
function methodsel_change() {
359 3462a529 Matthew Grooms
	index = document.iform.authentication_method.selectedIndex;
360
	value = document.iform.authentication_method.options[index].value;
361
362
	switch (value) {
363
		case 'hybrid_rsa_server':
364
			document.iform.pskey.disabled = 1;
365
			document.iform.privatekey.disabled = 0;
366
			document.iform.cert.disabled = 0;
367
			document.iform.peercert.disabled = 1;
368
			break;
369
		case 'xauth_rsa_server':
370
		case 'rsasig':
371 a93e56c5 Matthew Grooms
			document.iform.pskey.disabled = 1;
372
			document.iform.privatekey.disabled = 0;
373
			document.iform.cert.disabled = 0;
374
			document.iform.peercert.disabled = 0;
375
			break;
376 3462a529 Matthew Grooms
		default: /* psk modes*/
377 a93e56c5 Matthew Grooms
			document.iform.pskey.disabled = 0;
378
			document.iform.privatekey.disabled = 1;
379
			document.iform.cert.disabled = 1;
380
			document.iform.peercert.disabled = 1;
381
			break;
382
	}
383
}
384
385
/* PHP generated java script for variable length keys */
386
function ealgosel_change(bits) {
387
	switch (document.iform.ealgo.selectedIndex) {
388
<?php
389
  $i = 0;
390
  foreach ($p1_ealgos as $algo => $algodata) {
391
    if (is_array($algodata['keysel'])) {
392
      echo "		case {$i}:\n";
393
      echo "			document.iform.ealgo_keylen.style.visibility = 'visible';\n";
394
      echo "			document.iform.ealgo_keylen.options.length = 0;\n";
395
//      echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( 'auto', 'auto' );\n";
396
397
      $key_hi = $algodata['keysel']['hi'];
398
      $key_lo = $algodata['keysel']['lo'];
399
      $key_step = $algodata['keysel']['step'];
400
401
      for ($keylen = $key_hi; $keylen >= $key_lo; $keylen -= $key_step)
402
        echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( '{$keylen} bits', '{$keylen}' );\n";
403
      echo "			break;\n";
404
    } else {
405
      echo "		case {$i}:\n";
406
      echo "			document.iform.ealgo_keylen.style.visibility = 'hidden';\n";
407
      echo "			document.iform.ealgo_keylen.options.length = 0;\n";
408
      echo "			break;\n";
409
    }
410
    $i++;
411
  }
412
?>
413
	}
414
415
	if( bits )
416
		document.iform.ealgo_keylen.value = bits;
417
}
418 3462a529 Matthew Grooms
419 a93e56c5 Matthew Grooms
function dpdchkbox_change() {
420
	if( document.iform.dpd_enable.checked ) {
421
			document.iform.dpd_delay.disabled = 0;
422
			document.iform.dpd_maxfail.disabled = 0;
423
	} else {
424
			document.iform.dpd_delay.disabled = 1;
425
			document.iform.dpd_maxfail.disabled = 1;
426
	}
427 3462a529 Matthew Grooms
428
	if (!document.iform.dpd_delay.value)
429
		document.iform.dpd_delay.value = "10";
430
431
	if (!document.iform.dpd_maxfail.value)
432
		document.iform.dpd_maxfail.value = "5";
433 a93e56c5 Matthew Grooms
}
434 3462a529 Matthew Grooms
435 a93e56c5 Matthew Grooms
//-->
436
</script>
437
<?php if ($input_errors) print_input_errors($input_errors); ?>
438
            <form action="vpn_ipsec_phase1.php" method="post" name="iform" id="iform">
439
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
440 0cece4a2 Scott Ullrich
				<tr>
441
					<td colspan="2" valign="top" class="listtopic">General information</td>
442
				</tr>
443 a93e56c5 Matthew Grooms
                <tr>
444
                  <td width="22%" valign="top" class="vncellreq">Disabled</td>
445
                  <td width="78%" class="vtable">
446
                    <input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
447
                    <strong>Disable this phase1 entry</strong><br>
448
                    <span class="vexpl">Set this option to disable this phase1 without
449
                      removing it from the list.
450
                    </span>
451
                  </td>
452
                </tr>
453
                <tr>
454
                  <td width="22%" valign="top" class="vncellreq">Interface</td>
455
                  <td width="78%" class="vtable">
456
                    <select name="interface" class="formselect">
457
                      <?php 
458
                        $interfaces = get_configured_interface_with_descr();
459
                        $carpips = find_number_of_needed_carp_interfaces();
460
                        for ($i=0; $i<$carpips; $i++) {
461
                          $carpip = find_interface_ip("carp" . $i);
462
                          $interfaces['carp' . $i] = "CARP{$i} ({$carpip})"; 
463
                        }
464
                        foreach ($interfaces as $iface => $ifacename):
465
                      ?>
466
                      <option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
467
                        <?=htmlspecialchars($ifacename);?>
468
                      </option>
469
                      <?php endforeach; ?>
470
                    </select> <br>
471
                    <span class="vexpl">Select the interface for the local endpoint of this phase1 entry.</span>
472
                  </td>
473
                </tr>
474 3462a529 Matthew Grooms
				<?php if (!$pconfig['mobile']): ?>
475 a93e56c5 Matthew Grooms
                <tr>
476
                  <td width="22%" valign="top" class="vncellreq">Remote gateway</td>
477
                  <td width="78%" class="vtable">
478
                    <?=$mandfldhtml;?><input name="remotegw" type="text" class="formfld unknown" id="remotegw" size="20" value="<?=$pconfig['remotegw'];?>">
479
                    <br>
480
                    Enter the public IP address or host name of the remote gateway
481
                  </td>
482
                </tr>
483 3462a529 Matthew Grooms
				<?php endif; ?>
484 a93e56c5 Matthew Grooms
                <tr>
485
                  <td width="22%" valign="top" class="vncell">Description</td>
486
                  <td width="78%" class="vtable">
487
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
488
                    <br> <span class="vexpl">You may enter a description here
489
                    for your reference (not parsed).</span>
490
                  </td>
491
                </tr>
492
                <tr>
493
                  <td colspan="2" class="list" height="12"></td>
494
                </tr>
495
                <tr>
496
                  <td colspan="2" valign="top" class="listtopic">Phase 1 proposal
497
                    (Authentication)
498
                  </td>
499
                </tr>
500
                <tr>
501
                  <td width="22%" valign="top" class="vncellreq">Negotiation mode</td>
502
                  <td width="78%" class="vtable">
503
                    <select name="mode" class="formselect">
504
                      <?php
505
                        $modes = explode(" ", "main aggressive");
506
                        foreach ($modes as $mode):
507
                      ?>
508
                      <option value="<?=$mode;?>" <?php if ($mode == $pconfig['mode']) echo "selected"; ?>>
509
                        <?=htmlspecialchars($mode);?>
510
                      </option>
511
                      <?php endforeach; ?>
512
                    </select> <br> <span class="vexpl">Aggressive is more flexible, but less secure.</span>
513
                  </td>
514
                </tr>
515
                <tr>
516
                  <td width="22%" valign="top" class="vncellreq">My identifier</td>
517
                  <td width="78%" class="vtable">
518 3462a529 Matthew Grooms
                    <select name="myid_type" class="formselect" onChange="myidsel_change()">
519
                      <?php foreach ($my_identifier_list as $id_type => $id_params): ?>
520
                        <option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['myid_type']) echo "selected"; ?>>
521
                          <?=htmlspecialchars($id_params['desc']);?>
522 a93e56c5 Matthew Grooms
                        </option>
523
                      <?php endforeach; ?>
524
                    </select>
525
                    <input name="myid_data" type="text" class="formfld unknown" id="myid_data" size="30" value="<?=$pconfig['myid_data'];?>">
526
                  </td>
527
                </tr>
528
                <tr>
529
                  <td width="22%" valign="top" class="vncellreq">Peer identifier</td>
530
                  <td width="78%" class="vtable">
531 3462a529 Matthew Grooms
                    <select name="peerid_type" class="formselect" onChange="peeridsel_change()">
532
                      <?php
533
                        foreach ($peer_identifier_list as $id_type => $id_params):
534
                          if ($pconfig['mobile'] && !$id_params['mobile'])
535
                            continue;
536
                      ?>
537
                      <option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['peerid_type']) echo "selected"; ?>>
538
                        <?=htmlspecialchars($id_params['desc']);?>
539 a93e56c5 Matthew Grooms
                      </option>
540
                      <?php endforeach; ?>
541
                    </select>
542
                    <input name="peerid_data" type="text" class="formfld unknown" id="peerid_data" size="30" value="<?=$pconfig['peerid_data'];?>">
543
                  </td>
544
                </tr>
545
                <tr>
546
                  <td width="22%" valign="top" class="vncellreq">Encryption algorithm</td>
547
                  <td width="78%" class="vtable">
548
                    <select name="ealgo" class="formselect" onChange="ealgosel_change()">
549
                      <?php
550
                        foreach ($p1_ealgos as $algo => $algodata):
551
                        $selected = '';
552
                        if ($algo == $pconfig['ealgo']['name'])
553
                          $selected = ' selected';
554
                      ?>
555
                      <option value="<?=$algo;?>"<?=$selected?>>
556
                        <?=htmlspecialchars($algodata['name']);?>
557
                      </option>
558
                    <?php endforeach; ?>
559
                    </select>
560
                    <select name="ealgo_keylen" width="30" class="formselect">
561
                    </select>
562
                  </td>
563
                </tr>
564
                <tr>
565
                  <td width="22%" valign="top" class="vncellreq">Hash algorithm</td>
566
                  <td width="78%" class="vtable">
567
                    <select name="halgo" class="formselect">
568
                      <?php foreach ($p1_halgos as $algo => $algoname): ?>
569
                      <option value="<?=$algo;?>" <?php if ($algo == $pconfig['halgo']) echo "selected"; ?>>
570
                        <?=htmlspecialchars($algoname);?>
571
                      </option>
572
                      <?php endforeach; ?>
573
                    </select>
574
                    <br>
575
                    <span class="vexpl">
576
                      Must match the setting chosen on the remote side.
577
                    </span>
578
                  </td>
579
                </tr>
580
                <tr>
581
                  <td width="22%" valign="top" class="vncellreq">DH key group</td>
582
                  <td width="78%" class="vtable">
583
                    <select name="dhgroup" class="formselect">
584
                      <?php $keygroups = explode(" ", "1 2 5"); foreach ($keygroups as $keygroup): ?>
585
                      <option value="<?=$keygroup;?>" <?php if ($keygroup == $pconfig['dhgroup']) echo "selected"; ?>>
586
                        <?=htmlspecialchars($keygroup);?>
587
                      </option>
588
                      <?php endforeach; ?>
589
                    </select>
590
                    <br>
591
                    <span class="vexpl">
592
                      <em>1 = 768 bit, 2 = 1024 bit, 5 = 1536 bit</em>
593
                      <br>
594
                      Must match the setting chosen on the remote side.
595
                    </span>
596
                  </td>
597
                </tr>
598
                <tr>
599
                  <td width="22%" valign="top" class="vncell">Lifetime</td>
600
                  <td width="78%" class="vtable">
601
                    <input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="20" value="<?=$pconfig['lifetime'];?>">
602
                    seconds
603
                  </td>
604
                </tr>
605
                <tr>
606
                  <td width="22%" valign="top" class="vncellreq">Authentication method</td>
607
                  <td width="78%" class="vtable">
608
                    <select name="authentication_method" class="formselect" onChange="methodsel_change()">
609 3462a529 Matthew Grooms
                      <?php
610
                        foreach ($p1_authentication_methods as $method_type => $method_params):
611
                          if (!$pconfig['mobile'] && $method_params['mobile'])
612
                            continue;
613
                      ?>
614
                      <option value="<?=$method_type;?>" <?php if ($method_type == $pconfig['authentication_method']) echo "selected"; ?>>
615
                        <?=htmlspecialchars($method_params['name']);?>
616 a93e56c5 Matthew Grooms
                      </option>
617
                      <?php endforeach; ?>
618
                    </select>
619
                    <br>
620
                    <span class="vexpl">Must match the setting chosen on the remote side.</span>
621
                  </td>
622
                </tr>
623
                <tr>
624
                  <td width="22%" valign="top" class="vncellreq">Pre-Shared Key</td>
625
                  <td width="78%" class="vtable">
626
                    <?=$mandfldhtml;?><input name="pskey" type="text" class="formfld unknown" id="pskey" size="40" value="<?=htmlspecialchars($pconfig['pskey']);?>">
627
                  </td>
628
                </tr>
629
                <tr>
630
                  <td width="22%" valign="top" class="vncellreq">My Certificate</td>
631
                  <td width="78%" class="vtable">
632
                    <textarea name="cert" cols="65" rows="7" id="cert" class="formpre"><?=htmlspecialchars($pconfig['cert']);?></textarea>
633
                    <br>
634
                    Paste a certificate in X.509 PEM format here.</td>
635
                </tr>
636
                <tr>
637
                  <td width="22%" valign="top" class="vncellreq">My Private Key</td>
638
                  <td width="78%" class="vtable">
639
                    <textarea name="privatekey" cols="65" rows="7" id="privatekey" class="formpre"><?=htmlspecialchars($pconfig['privatekey']);?></textarea>
640
                    <br>
641
                    Paste an RSA private key in PEM format here.
642
                  </td>
643
                </tr>
644
                <tr>
645
                  <td width="22%" valign="top" class="vncell">Peer certificate</td>
646
                  <td width="78%" class="vtable">
647
                    <textarea name="peercert" cols="65" rows="7" id="peercert" class="formpre"><?=htmlspecialchars($pconfig['peercert']);?></textarea>
648
                    <br>
649
                    Paste the peer X.509 certificate in PEM format here.<br>
650
                    Leave this blank if you want to use a CA certificate for identity validation.
651
                  </td>
652
                </tr>
653
                <tr>
654
                  <td colspan="2" class="list" height="12"></td>
655
                </tr>
656
                <tr>
657
                  <td colspan="2" valign="top" class="listtopic">Advanced Options</td>
658
                </tr>
659
                <tr>
660
                  <td width="22%" valign="top" class="vncell">NAT Traversal</td>
661
                  <td width="78%" class="vtable">
662
                    <select name="nat_traversal" class="formselect">
663
                      <option value="off" <?php if ($pconfig['nat_traversal'] == "off") echo "selected"; ?>>Disable</option>
664
                      <option value="on" <?php if ($pconfig['nat_traversal'] == "on") echo "selected"; ?>>Enable</option>
665
                      <option value="force" <?php if ($pconfig['nat_traversal'] == "force") echo "selected"; ?>>Force</option>
666
                    </select>
667
                    <br/>
668
                    <span class="vexpl">
669
                      Set this option to enable the use of NAT-T (i.e. the encapsulation of ESP in UDP packets) if needed,
670
                      which can help with clients that are behind restrictive firewalls.
671
                    </span>
672
                  </td>
673
                </tr>
674
                <tr>
675
                  <td width="22%" valign="top" class="vncell">Dead Peer Detection</td>
676
                  <td width="78%" class="vtable">
677 3462a529 Matthew Grooms
                    <input name="dpd_enable" type="checkbox" id="dpd_enable" value="yes" <?php if (isset($pconfig['dpd_enable'])) echo "checked"; ?> onClick="dpdchkbox_change()">
678 a93e56c5 Matthew Grooms
                    Enable DPD<br>
679
                    <br>
680 3462a529 Matthew Grooms
                    <input name="dpd_delay" type="text" class="formfld unknown" id="dpd_delay" size="5" value="<?=$pconfig['dpd_delay'];?>">
681 a93e56c5 Matthew Grooms
                    seconds<br>
682
                    <span class="vexpl">Delay between requesting peer acknowledgement.</span><br>
683
                    <br>
684
                    <input name="dpd_maxfail" type="text" class="formfld unknown" id="dpd_maxfail" size="5" value="<?=$pconfig['dpd_maxfail'];?>">
685
                    retries<br>
686
                    <span class="vexpl">Number consecutive failures allowed before disconnect.</span><br>
687
                  </td>
688
                </tr>
689
                <tr>
690
                  <td width="22%" valign="top" class="vncell">Automatically ping host</td>
691
                  <td width="78%" class="vtable">
692
                    <input name="pinghost" type="text" class="formfld unknown" id="pinghost" size="20" value="<?=$pconfig['pinghost'];?>">
693
                    IP address
694
                  </td>
695
                </tr>
696
                <tr>
697
                  <td width="22%" valign="top">&nbsp;</td>
698
                  <td width="78%">
699
                    <?php if (isset($p1index) && $a_phase1[$p1index]): ?>
700
                    <input name="p1index" type="hidden" value="<?=$p1index;?>">
701
                    <?php endif; ?>
702 3462a529 Matthew Grooms
					<?php if ($pconfig['mobile']): ?>
703
                    <input name="mobile" type="hidden" value="true">
704
                    <?php endif; ?>
705
                    <input name="ikeid" type="hidden" value="<?=$pconfig['ikeid'];?>">
706
                    <input name="Submit" type="submit" class="formbtn" value="Save">
707 a93e56c5 Matthew Grooms
                  </td>
708
                </tr>
709
              </table>
710
</form>
711
<script lannguage="JavaScript">
712
<!--
713
<?php
714
	/* determine if we should init the key length */
715
	$keyset = '';
716
	if (isset($pconfig['ealgo']['keylen']))
717
		if (is_numeric($pconfig['ealgo']['keylen']))
718
			$keyset = $pconfig['ealgo']['keylen'];
719
?>
720 3462a529 Matthew Grooms
myidsel_change();
721
peeridsel_change();
722 a93e56c5 Matthew Grooms
methodsel_change();
723
ealgosel_change(<?=$keyset;?>);
724
dpdchkbox_change();
725
//-->
726
</script>
727
<?php include("fend.inc"); ?>
728 3462a529 Matthew Grooms
</body>
729
</html>