vpn_ipsec_phase1.php 42.1 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1
<?php
2

Ad Schellevis's avatar
Ad Schellevis committed
3
/*
4
	Copyright (C) 2014-2015 Deciso B.V.
Ad Schellevis's avatar
Ad Schellevis committed
5 6
	Copyright (C) 2008 Shrew Soft Inc
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
7
	Copyright (C) 2014 Ermal Luçi
Ad Schellevis's avatar
Ad Schellevis committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
	All rights reserved.

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions are met:

	1. Redistributions of source code must retain the above copyright notice,
	   this list of conditions and the following disclaimer.

	2. Redistributions in binary form must reproduce the above copyright
	   notice, this list of conditions and the following disclaimer in the
	   documentation and/or other materials provided with the distribution.

	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
*/
31
require_once("guiconfig.inc");
Ad Schellevis's avatar
Ad Schellevis committed
32
require_once("vpn.inc");
33
require_once("services.inc");
34
require_once("pfsense-utils.inc");
35
require_once("interfaces.inc");
Ad Schellevis's avatar
Ad Schellevis committed
36

37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

/*
 * ikeid management functions
 */

function ipsec_ikeid_used($ikeid) {
	global $config;

	foreach ($config['ipsec']['phase1'] as $ph1ent)
		if( $ikeid == $ph1ent['ikeid'] )
			return true;

	return false;
}

function ipsec_ikeid_next() {

	$ikeid = 1;
	while(ipsec_ikeid_used($ikeid))
		$ikeid++;

	return $ikeid;
}


62
if (!is_array($config['ipsec'])) {
63
		$config['ipsec'] = array();
64
}
65

66
if (!is_array($config['ipsec']['phase1'])) {
67
    $config['ipsec']['phase1'] = array();
68
}
Ad Schellevis's avatar
Ad Schellevis committed
69

70
if (!is_array($config['ipsec']['phase2'])) {
71
    $config['ipsec']['phase2'] = array();
72
}
Ad Schellevis's avatar
Ad Schellevis committed
73

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
	// fetch data
	if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
	    $p1index = $_GET['dup'];
	} elseif (isset($_GET['p1index']) && is_numericint($_GET['p1index'])) {
	    $p1index = $_GET['p1index'];
	}
	$pconfig = array();

	// generice defaults
	$pconfig['interface'] = "wan";
	$pconfig['iketype'] = "ikev1";
	$phase1_fields = "mode,protocol,myid_type,myid_data,peerid_type,peerid_data
	,encryption-algorithm,halgo,dhgroup,lifetime,authentication_method,descr,nat_traversal
	,interface,iketype,dpd_delay,dpd_maxfail,remote-gateway,pre-shared-key,certref
	,caref,reauth_enable,rekey_enable";
90
	if (isset($p1index) && isset($config['ipsec']['phase1'][$p1index])) {
91 92 93
			// 1-on-1 copy
			foreach (explode(",", $phase1_fields) as $fieldname) {
				$fieldname = trim($fieldname);
94 95
				if(isset($config['ipsec']['phase1'][$p1index][$fieldname])) {
					$pconfig[$fieldname] = $config['ipsec']['phase1'][$p1index][$fieldname];
96 97 98 99 100 101 102 103 104
				} elseif (!isset($pconfig[$fieldname])) {
					// initialize element
					$pconfig[$fieldname] = null;
				}
			}

			// attributes with some kind of logic behind them...
	    if (!isset($_GET['dup']) || !is_numericint($_GET['dup'])) {
					// don't copy the ikeid on dup
105
	        $pconfig['ikeid'] = $config['ipsec']['phase1'][$p1index]['ikeid'];
106
	    }
107
	    $pconfig['disabled'] = isset($config['ipsec']['phase1'][$p1index]['disabled']);
108 109 110

			$pconfig['remotebits'] = null;
			$pconfig['remotenet'] = null ;
111
			if (isset($a_phase1[$p1index]['remote-subnet']) && strpos($config['ipsec']['phase1'][$p1index]['remote-subnet'],'/') !== false) {
112
		list($pconfig['remotenet'],$pconfig['remotebits']) = explode("/", $config['ipsec']['phase1'][$p1index]['remote-subnet']);
113 114
			} elseif (isset($config['ipsec']['phase1'][$p1index]['remote-subnet'])) {
				$pconfig['remotenet'] = $config['ipsec']['phase1'][$p1index]['remote-subnet'];
115 116
			}

117
	    if (isset($config['ipsec']['phase1'][$p1index]['mobile'])) {
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
	        $pconfig['mobile'] = true;
	    }
	} else {
	    /* defaults new */
	    if (isset($config['interfaces']['lan'])) {
	        $pconfig['localnet'] = "lan";
	    }
	    $pconfig['mode'] = "aggressive";
	    $pconfig['protocol'] = "inet";
	    $pconfig['myid_type'] = "myaddress";
	    $pconfig['peerid_type'] = "peeraddress";
	    $pconfig['authentication_method'] = "pre_shared_key";
	    $pconfig['encryption-algorithm'] = array("name" => "3des") ;
	    $pconfig['halgo'] = "sha1";
	    $pconfig['dhgroup'] = "2";
	    $pconfig['lifetime'] = "28800";
	    $pconfig['nat_traversal'] = "on";
	    $pconfig['iketype'] = "ikev1";

	    /* mobile client */
	    if (isset($_GET['mobile'])) {
	        $pconfig['mobile']=true;
	    }
			// init empty
			foreach (explode(",", $phase1_fields) as $fieldname) {
				$fieldname = trim($fieldname);
				if (!isset($pconfig[$fieldname])) {
					$pconfig[$fieldname] = null;
				}
			}
148

149
	}
150

151
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
152
	$a_phase1 = &$config['ipsec']['phase1'];
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
	if (isset($_POST['p1index']) && is_numericint($_POST['p1index'])) {
	    $p1index = $_POST['p1index'];
	}
	$input_errors = array();
	$pconfig = $_POST;
	$old_ph1ent = $a_phase1[$p1index];

	// Preperations to kill some settings which aren't left empty by the field.
	// Unset ca and cert if not required to avoid storing in config
	if ($pconfig['authentication_method'] == "pre_shared_key" || $pconfig['authentication_method'] == "xauth_psk_server") {
			unset($pconfig['caref']);
			unset($pconfig['certref']);
	}
	// unset dpd on post
	if (!isset($pconfig['dpd_enable'])) {
		unset($pconfig['dpd_delay']);
		unset($pconfig['dpd_maxfail']);
	}
171

172 173 174 175 176 177 178 179
	/* My identity */
	if ($pconfig['myid_type'] == "myaddress") {
			$pconfig['myid_data'] = "";
	}
	/* Peer identity */
	if ($pconfig['myid_type'] == "peeraddress") {
			$pconfig['peerid_data'] = "";
	}
180

181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
	/* input validation */
	$method = $pconfig['authentication_method'];

	// Only require PSK here for normal PSK tunnels (not mobile) or xauth.
	// For RSA methods, require the CA/Cert.
	switch ($method) {
			case "eap-tls":
					if ($pconfig['iketype'] != 'ikev2') {
							$input_errors[] = gettext("EAP-TLS can only be used with IKEv2 type VPNs.");
					}
					break;
			case "pre_shared_key":
					// If this is a mobile PSK tunnel the user PSKs go on
					//    the PSK tab, not here, so skip the check.
					if ($pconfig['mobile']) {
							break;
					}
			case "xauth_psk_server":
					$reqdfields = explode(" ", "pre-shared-key");
					$reqdfieldsn = array(gettext("Pre-Shared Key"));
					break;
			case "hybrid_rsa_server":
			case "xauth_rsa_server":
			case "rsasig":
					$reqdfields = explode(" ", "caref certref");
					$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
					break;
	}
	if (empty($pconfig['mobile'])) {
			$reqdfields[] = "remote-gateway";
			$reqdfieldsn[] = gettext("Remote gateway");
	}
213

214
	do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
215

216 217 218
	if ((!empty($pconfig['lifetime']) && !is_numeric($pconfig['lifetime']))) {
			$input_errors[] = gettext("The P1 lifetime must be an integer.");
	}
219

220 221 222 223 224 225 226 227
	if (!empty($pconfig['remote-gateway'])) {
			if (!is_ipaddr($pconfig['remote-gateway']) && !is_domain($pconfig['remote-gateway'])) {
					$input_errors[] = gettext("A valid remote gateway address or host name must be specified.");
			} elseif (is_ipaddrv4($pconfig['remote-gateway']) && ($pconfig['protocol'] != "inet"))
					$input_errors[] = gettext("A valid remote gateway IPv4 address must be specified or you need to change protocol to IPv6");
			elseif (is_ipaddrv6($pconfig['remote-gateway']) && ($pconfig['protocol'] != "inet6"))
					$input_errors[] = gettext("A valid remote gateway IPv6 address must be specified or you need to change protocol to IPv4");
	}
228

229 230 231 232 233 234 235 236 237 238 239
	if ((!empty($pconfig['remote-gateway']) && is_ipaddr($pconfig['remote-gateway']) && !isset($pconfig['disabled']) )) {
			$t = 0;
			foreach ($a_phase1 as $ph1tmp) {
					if ($p1index <> $t) {
							if (isset($ph1tmp['remote-gateway']) && $ph1tmp['remote-gateway'] == $pconfig['remote-gateway'] && !isset($ph1tmp['disabled'])) {
									$input_errors[] = sprintf(gettext('The remote gateway "%1$s" is already used by phase1 "%2$s".'), $pconfig['remote-gateway'], $ph1tmp['descr']);
							}
					}
					$t++;
			}
	}
240

241 242
	if (count($config['ipsec']['phase2'])) {
			foreach ($config['ipsec']['phase2'] as $phase2) {
243 244 245 246 247 248 249 250 251 252 253 254
					if ($phase2['ikeid'] == $pconfig['ikeid']) {
							if (($pconfig['protocol'] == "inet") && ($phase2['mode'] == "tunnel6")) {
									$input_errors[] = gettext("There is a Phase 2 using IPv6, you cannot use IPv4.");
									break;
							}
							if (($pconfig['protocol'] == "inet6") && ($phase2['mode'] == "tunnel")) {
									$input_errors[] = gettext("There is a Phase 2 using IPv4, you cannot use IPv6.");
									break;
							}
					}
			}
	}
255

256 257 258
	if ($pconfig['myid_type'] == "address" and $pconfig['myid_data'] == "") {
			$input_errors[] = gettext("Please enter an address for 'My Identifier'");
	}
259

260 261 262
	if ($pconfig['myid_type'] == "keyid tag" and $pconfig['myid_data'] == "") {
			$input_errors[] = gettext("Please enter a keyid tag for 'My Identifier'");
	}
263

264 265 266
	if ($pconfig['myid_type'] == "fqdn" and $pconfig['myid_data'] == "") {
			$input_errors[] = gettext("Please enter a fully qualified domain name for 'My Identifier'");
	}
267

268 269 270
	if ($pconfig['myid_type'] == "user_fqdn" and $pconfig['myid_data'] == "") {
			$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'My Identifier'");
	}
271

272 273 274
	if ($pconfig['myid_type'] == "dyn_dns" and $pconfig['myid_data'] == "") {
			$input_errors[] = gettext("Please enter a dynamic domain name for 'My Identifier'");
	}
275

276 277 278
	if ((($pconfig['myid_type'] == "address") && !is_ipaddr($pconfig['myid_data']))) {
			$input_errors[] = gettext("A valid IP address for 'My identifier' must be specified.");
	}
279

280 281 282
	if ((($pconfig['myid_type'] == "fqdn") && !is_domain($pconfig['myid_data']))) {
			$input_errors[] = gettext("A valid domain name for 'My identifier' must be specified.");
	}
283

284 285 286 287 288
	if ($pconfig['myid_type'] == "fqdn") {
			if (is_domain($pconfig['myid_data']) == false) {
					$input_errors[] = gettext("A valid FQDN for 'My identifier' must be specified.");
			}
	}
289

290 291 292 293 294 295
	if ($pconfig['myid_type'] == "user_fqdn") {
			$user_fqdn = explode("@", $pconfig['myid_data']);
			if (is_domain($user_fqdn[1]) == false) {
					$input_errors[] = gettext("A valid User FQDN in the form of user@my.domain.com for 'My identifier' must be specified.");
			}
	}
296

297 298 299 300 301
	if ($pconfig['myid_type'] == "dyn_dns") {
			if (is_domain($pconfig['myid_data']) == false) {
					$input_errors[] = gettext("A valid Dynamic DNS address for 'My identifier' must be specified.");
			}
	}
302

303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
	// Only enforce peer ID if we are not dealing with a pure-psk mobile config.
	if (!(($pconfig['authentication_method'] == "pre_shared_key") && !empty($pconfig['mobile']))) {
			if ($pconfig['peerid_type'] == "address" and $pconfig['peerid_data'] == "") {
					$input_errors[] = gettext("Please enter an address for 'Peer Identifier'");
			}
			if ($pconfig['peerid_type'] == "keyid tag" and $pconfig['peerid_data'] == "") {
					$input_errors[] = gettext("Please enter a keyid tag for 'Peer Identifier'");
			}
			if ($pconfig['peerid_type'] == "fqdn" and $pconfig['peerid_data'] == "") {
					$input_errors[] = gettext("Please enter a fully qualified domain name for 'Peer Identifier'");
			}
			if ($pconfig['peerid_type'] == "user_fqdn" and $pconfig['peerid_data'] == "") {
					$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'Peer Identifier'");
			}
			if ((($pconfig['peerid_type'] == "address") && !is_ipaddr($pconfig['peerid_data']))) {
					$input_errors[] = gettext("A valid IP address for 'Peer identifier' must be specified.");
			}
			if ((($pconfig['peerid_type'] == "fqdn") && !is_domain($pconfig['peerid_data']))) {
					$input_errors[] = gettext("A valid domain name for 'Peer identifier' must be specified.");
			}
			if ($pconfig['peerid_type'] == "fqdn") {
					if (is_domain($pconfig['peerid_data']) == false) {
							$input_errors[] = gettext("A valid FQDN for 'Peer identifier' must be specified.");
					}
			}
			if ($pconfig['peerid_type'] == "user_fqdn") {
					$user_fqdn = explode("@", $pconfig['peerid_data']);
					if (is_domain($user_fqdn[1]) == false) {
							$input_errors[] = gettext("A valid User FQDN in the form of user@my.domain.com for 'Peer identifier' must be specified.");
					}
			}
	}
335

336 337 338 339 340 341 342 343
	if (!empty($pconfig['dpd_enable'])) {
			if (!is_numeric($pconfig['dpd_delay'])) {
					$input_errors[] = gettext("A numeric value must be specified for DPD delay.");
			}
			if (!is_numeric($pconfig['dpd_maxfail'])) {
					$input_errors[] = gettext("A numeric value must be specified for DPD retries.");
			}
	}
344

345 346 347
	if (!empty($pconfig['iketype']) && $pconfig['iketype'] != "ikev1" && $pconfig['iketype'] != "ikev2") {
			$input_errors[] = gettext("Valid arguments for IKE type is v1 or v2");
	}
348

349 350 351 352 353 354 355 356
	/* build our encryption algorithms array */
	if (!isset($pconfig['encryption-algorithm']) || !is_array($pconfig['encryption-algorithm'])) {
		$pconfig['encryption-algorithm'] = array();
	}
	$pconfig['encryption-algorithm']['name'] = $_POST['encryption-algorithm'];
	if ($pconfig['ealgo_keylen']) {
			$pconfig['ealgo']['keylen'] = $_POST['ealgo_keylen'];
	}
357

358 359 360 361 362 363 364 365
	if (count($input_errors) == 0) {
			$copy_fields = "ikeid,iketype,interface,mode,protocol,myid_type,myid_data
			,peerid_type,peerid_data,encryption-algorithm,hash-algorithm,dhgroup
			,lifetime,pre-shared-key,certref,caref,authentication_method,descr
			,nat_traversal";

			foreach (explode(",",$copy_fields) as $fieldname) {
				$fieldname = trim($fieldname);
366
				if(!empty($pconfig[$fieldname])) {
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394
					$ph1ent[$fieldname] = $pconfig[$fieldname];
				}
			}

			$ph1ent['disabled'] = !empty($pconfig['disabled']) ? true : false;
			$ph1ent['private-key'] =isset($pconfig['privatekey']) ? base64_encode($pconfig['privatekey']) : null;
			if (!empty($pconfig['mobile'])) {
					$ph1ent['mobile'] = true;
			} else {
					$ph1ent['remote-gateway'] = $pconfig['remote-gateway'];
			}
			if (isset($pconfig['reauth_enable'])) {
					$ph1ent['reauth_enable'] = true;
			}
			if (isset($pconfig['rekey_enable'])) {
					$ph1ent['rekey_enable'] = true;
			}

			if (isset($pconfig['dpd_enable'])) {
					$ph1ent['dpd_delay'] = $pconfig['dpd_delay'];
					$ph1ent['dpd_maxfail'] = $pconfig['dpd_maxfail'];
			}

			/* generate unique phase1 ikeid */
			if ($ph1ent['ikeid'] == 0) {
					$ph1ent['ikeid'] = ipsec_ikeid_next();
			}

395
			if (isset($p1index) && isset($a_phase1[$p1index])) {
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
					$a_phase1[$p1index] = $ph1ent;
			} else {
					$a_phase1[] = $ph1ent;
			}

			/* if the remote gateway changed and the interface is not WAN then remove route */
			/* the vpn_ipsec_configure() handles adding the route */
			if ($pconfig['interface'] <> "wan") {
					if ($old_ph1ent['remote-gateway'] <> $pconfig['remote-gateway']) {
							mwexec("/sbin/route delete -host {$old_ph1ent['remote-gateway']}");
					}
			}

			write_config();
			mark_subsystem_dirty('ipsec');

			header("Location: vpn_ipsec.php");
			exit;
	}
Ad Schellevis's avatar
Ad Schellevis committed
415 416
}

417
if (!empty($pconfig['mobile'])) {
418 419 420 421
    $pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1"), gettext("Mobile Client"));
} else {
    $pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1"));
}
Ad Schellevis's avatar
Ad Schellevis committed
422 423
$shortcut_section = "ipsec";

424
legacy_html_escape_form_data($pconfig);
Ad Schellevis's avatar
Ad Schellevis committed
425 426 427 428 429

include("head.inc");

?>

Ad Schellevis's avatar
Ad Schellevis committed
430
<body>
Ad Schellevis's avatar
Ad Schellevis committed
431 432 433 434
<?php include("fbegin.inc"); ?>
<script type="text/javascript">
//<![CDATA[

435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
<?php
    /* determine if we should init the key length */
    $keyset = '';
		if (isset($pconfig['ealgo']['keylen'])) {
		    if (is_numeric($pconfig['ealgo']['keylen'])) {
		        $keyset = $pconfig['ealgo']['keylen'];
		    }
		}
?>
$( document ).ready(function() {
	// old js code..
	myidsel_change();
	peeridsel_change();
	methodsel_change();
	ealgosel_change(<?=$keyset;?>);
	dpdchkbox_change();
});


Ad Schellevis's avatar
Ad Schellevis committed
454
function myidsel_change() {
455 456 457 458 459 460 461
	if ($("#myid_type").val() == 'myaddress') {
		$("#myid_data").removeClass('show');
		$("#myid_data").addClass('hidden');
	} else {
		$("#myid_data").removeClass('hidden');
		$("#myid_data").addClass('show');
	}
Ad Schellevis's avatar
Ad Schellevis committed
462 463 464
}

function peeridsel_change() {
465 466 467 468 469 470 471
	if ($("#peerid_type").val() == 'peeraddress') {
		$("#peerid_data").removeClass('show');
		$("#peerid_data").addClass('hidden');
	} else {
		$("#peerid_data").removeClass('hidden');
		$("#peerid_data").addClass('show');
	}
Ad Schellevis's avatar
Ad Schellevis committed
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
}

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

	switch (value) {
	case 'eap-tls':
		document.getElementById('opt_psk').style.display = 'none';
		document.getElementById('opt_peerid').style.display = '';
		document.getElementById('opt_cert').style.display = '';
		document.getElementById('opt_ca').style.display = '';
		document.getElementById('opt_cert').disabled = false;
		document.getElementById('opt_ca').disabled = false;
		break;
	case 'hybrid_rsa_server':
		document.getElementById('opt_psk').style.display = 'none';
		document.getElementById('opt_peerid').style.display = '';
		document.getElementById('opt_cert').style.display = '';
		document.getElementById('opt_ca').style.display = '';
		document.getElementById('opt_cert').disabled = false;
		document.getElementById('opt_ca').disabled = false;
		break;
	case 'xauth_rsa_server':
	case 'rsasig':
		document.getElementById('opt_psk').style.display = 'none';
		document.getElementById('opt_peerid').style.display = '';
		document.getElementById('opt_cert').style.display = '';
		document.getElementById('opt_ca').style.display = '';
		document.getElementById('opt_cert').disabled = false;
		document.getElementById('opt_ca').disabled = false;
		break;
504
<?php if (!empty($pconfig['mobile'])) {
505
?>
Ad Schellevis's avatar
Ad Schellevis committed
506 507 508 509 510 511 512 513
	case 'pre_shared_key':
		document.getElementById('opt_psk').style.display = 'none';
		document.getElementById('opt_peerid').style.display = 'none';
		document.getElementById('opt_cert').style.display = 'none';
		document.getElementById('opt_ca').style.display = 'none';
		document.getElementById('opt_cert').disabled = true;
		document.getElementById('opt_ca').disabled = true;
		break;
514 515
<?php
} ?>
Ad Schellevis's avatar
Ad Schellevis committed
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
	default: /* psk modes*/
		document.getElementById('opt_psk').style.display = '';
		document.getElementById('opt_peerid').style.display = '';
		document.getElementById('opt_cert').style.display = 'none';
		document.getElementById('opt_ca').style.display = 'none';
		document.getElementById('opt_cert').disabled = true;
		document.getElementById('opt_ca').disabled = true;
		break;
	}
}

/* PHP generated java script for variable length keys */
function ealgosel_change(bits) {
	switch (document.iform.ealgo.selectedIndex) {
<?php
$i = 0;
foreach ($p1_ealgos as $algo => $algodata) {
533
    if (isset($algodata['keysel']) && is_array($algodata['keysel'])) {
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553
        echo "		case {$i}:\n";
        echo "			document.iform.ealgo_keylen.style.visibility = 'visible';\n";
        echo "			document.iform.ealgo_keylen.options.length = 0;\n";
    //      echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( 'auto', 'auto' );\n";

        $key_hi = $algodata['keysel']['hi'];
        $key_lo = $algodata['keysel']['lo'];
        $key_step = $algodata['keysel']['step'];

        for ($keylen = $key_hi; $keylen >= $key_lo; $keylen -= $key_step) {
            echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( '{$keylen} bits', '{$keylen}' );\n";
        }
        echo "			break;\n";
    } else {
        echo "		case {$i}:\n";
        echo "			document.iform.ealgo_keylen.style.visibility = 'hidden';\n";
        echo "			document.iform.ealgo_keylen.options.length = 0;\n";
        echo "			break;\n";
    }
    $i++;
Ad Schellevis's avatar
Ad Schellevis committed
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
}
?>
	}

	if( bits )
		document.iform.ealgo_keylen.value = bits;
}

function dpdchkbox_change() {
	if( document.iform.dpd_enable.checked )
		document.getElementById('opt_dpd').style.display = '';
	else
		document.getElementById('opt_dpd').style.display = 'none';

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

	if (!document.iform.dpd_maxfail.value)
		document.iform.dpd_maxfail.value = "5";
}

//]]>
</script>

578 579 580 581 582 583 584 585
<section class="page-content-main">
	<div class="container-fluid">
		<div class="row">
<?php
    if (isset($input_errors) && count($input_errors) > 0) {
        print_input_errors($input_errors);
    }
?>
586

587 588
			<section class="col-xs-12">
<?php
589 590 591 592 593 594
                        $tab_array = array();
                        $tab_array[0] = array(gettext("Tunnels"), true, "vpn_ipsec.php");
                        $tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
                        $tab_array[2] = array(gettext("Pre-Shared Keys"), false, "vpn_ipsec_keys.php");
                        $tab_array[3] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
                        display_top_tabs($tab_array);
595
?>
596

597 598 599 600 601 602 603 604 605 606 607
				<div class="tab-content content-box col-xs-12">
					<form action="vpn_ipsec_phase1.php" method="post" name="iform" id="iform">
						<div class="table-responsive">
							<table class="table table-striped">
									<tr>
										<td width="22%"><b><?=gettext("General information"); ?></b></td>
										<td width="78%" align="right">
											<small><?=gettext("full help"); ?> </small>
											<i class="fa fa-toggle-off text-danger"  style="cursor: pointer;" id="show_all_help_opnvpn_server" type="button"></i></a>
										</td>
									</tr>
Ad Schellevis's avatar
Ad Schellevis committed
608
									<tr>
609 610 611 612 613
										<td width="22%" valign="top"><a id="help_for_disabled" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Disabled"); ?></td>
										<td>
											<input name="disabled" type="checkbox" id="disabled" value="yes" <?=!empty($pconfig['disabled'])?"checked=\"checked\"":"";?> />
											<div class="hidden" for="help_for_disabled">
												<strong><?=gettext("Disable this phase1 entry"); ?></strong><br />
Ad Schellevis's avatar
Ad Schellevis committed
614
												<?=gettext("Set this option to disable this phase1 without " .
615
                                                "removing it from the list"); ?>.
616
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
617 618 619
										</td>
									</tr>
									<tr>
620 621 622
										<td><a id="help_for_iketype" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Key Exchange version"); ?></td>
										<td>

Ad Schellevis's avatar
Ad Schellevis committed
623
											<select name="iketype" class="formselect">
624 625 626 627 628 629 630
<?php
                      $keyexchange = array("ikev1" => "V1", "ikev2" => "V2");
                      foreach ($keyexchange as $kidx => $name) :
                        ?>
                        <option value="<?=$kidx;?>" <?= $kidx == $pconfig['iketype'] ? "selected=\"selected\"" : "";?> >
                            <?=$name;?>
                        </option>
631
<?php								endforeach;
632 633 634 635 636
?>
											</select>
											<div class="hidden" for="help_for_iketype">
												<?=gettext("Select the KeyExchange Protocol version to be used. Usually known as IKEv1 or IKEv2."); ?>.
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
637 638 639
										</td>
									</tr>
									<tr>
640 641
										<td><a id="help_for_protocol" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Internet Protocol"); ?></td>
										<td>
Ad Schellevis's avatar
Ad Schellevis committed
642 643
											<select name="protocol" class="formselect">
											<?php
644 645 646 647 648 649
                      $protocols = array("inet" => "IPv4", "inet6" => "IPv6");
                      foreach ($protocols as $protocol => $name) :
                      ?>
												<option value="<?=$protocol;?>"  <?=$protocol == $pconfig['protocol'] ? "selected=\"selected\"" : "";?> >
														<?=$name?>
                        </option>
650
<?php								endforeach;
651 652 653 654 655
?>
											</select>
											<div class="hidden" for="help_for_protocol">
												<?=gettext("Select the Internet Protocol family from this dropdown"); ?>.
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
656 657 658
										</td>
									</tr>
									<tr>
659 660
										<td ><a id="help_for_interface" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Interface"); ?></td>
										<td>
Ad Schellevis's avatar
Ad Schellevis committed
661
											<select name="interface" class="formselect">
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689
<?php
											$interfaces = get_configured_interface_with_descr();
			                $carplist = get_configured_carp_interface_list();
                      foreach ($carplist as $cif => $carpip) {
                          $interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")";
                      }

                      $aliaslist = get_configured_ip_aliases_list();
                      foreach ($aliaslist as $aliasip => $aliasif) {
                          $interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
                      }

                      $grouplist = return_gateway_groups_array();
                      foreach ($grouplist as $name => $group) {
                          if ($group[0]['vip'] <> "") {
                              $vipif = $group[0]['vip'];
                          } else {
                              $vipif = $group[0]['int'];
                          }
                          $interfaces[$name] = "GW Group {$name}";
                      }


                      foreach ($interfaces as $iface => $ifacename) :
?>
												<option value="<?=$iface;?>" <?= $iface == $pconfig['interface'] ? "selected=\"selected\"" : "" ?> >
														<?=htmlspecialchars($ifacename);?>
                        </option>
690
<?php									endforeach;
691
?>
Ad Schellevis's avatar
Ad Schellevis committed
692
											</select>
693 694 695
											<div class="hidden" for="help_for_interface">
												<?=gettext("Select the interface for the local endpoint of this phase1 entry"); ?>.
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
696 697
										</td>
									</tr>
698
									<?php if (empty($pconfig['mobile'])) :
699
?>
700

Ad Schellevis's avatar
Ad Schellevis committed
701
									<tr>
702 703 704 705 706 707
										<td ><a id="help_for_remotegw" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Remote gateway"); ?></td>
										<td>
											<input name="remote-gateway" type="text" class="formfld unknown" id="remotegw" size="28" value="<?=$pconfig['remote-gateway'];?>" />
											<div class="hidden" for="help_for_remotegw">
												<?=gettext("Enter the public IP address or host name of the remote gateway"); ?>
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
708 709
										</td>
									</tr>
710
<?php						endif;
711
?>
Ad Schellevis's avatar
Ad Schellevis committed
712
									<tr>
713 714 715 716
										<td><a id="help_for_remotegw" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description"); ?></td>
										<td>
											<input name="descr" type="text" id="descr" size="40" value="<?=$pconfig['descr'];?>" />
											<div class="hidden" for="help_for_remotegw">
Ad Schellevis's avatar
Ad Schellevis committed
717
												<?=gettext("You may enter a description here " .
718
                                                "for your reference (not parsed)"); ?>.
719
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
720 721 722
										</td>
									</tr>
									<tr>
723 724 725 726
										<td colspan="2">&nbsp;</td>
									</tr>
									<tr>
										<td colspan="2"><b><?=gettext("Phase 1 proposal (Authentication)"); ?></b></td>
Ad Schellevis's avatar
Ad Schellevis committed
727 728
									</tr>
									<tr>
729 730
										<td><a id="help_for_authmethod" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Authentication method"); ?></td>
										<td>
Ad Schellevis's avatar
Ad Schellevis committed
731
											<select name="authentication_method" class="formselect" onchange="methodsel_change()">
732 733 734 735 736 737 738 739 740 741 742 743 744 745
<?php
											$p1_authentication_methods = array(
												'hybrid_rsa_server' => array( 'name' => 'Hybrid RSA + Xauth', 'mobile' => true ),
												'xauth_rsa_server' => array( 'name' => 'Mutual RSA + Xauth', 'mobile' => true ),
												'xauth_psk_server' => array( 'name' => 'Mutual PSK + Xauth', 'mobile' => true ),
												'eap-tls' => array( 'name' => 'EAP-TLS', 'mobile' => true),
												'rsasig' => array( 'name' => 'Mutual RSA', 'mobile' => false ),
												'pre_shared_key' => array( 'name' => 'Mutual PSK', 'mobile' => false ) );
                      foreach ($p1_authentication_methods as $method_type => $method_params) :
                          if (empty($pconfig['mobile']) && $method_params['mobile']) {
                              continue;
                          }
	                      ?>
													<option value="<?=$method_type;?>" <?= $method_type == $pconfig['authentication_method'] ? "selected=\"selected\"" : "";?> >
746
				<?=$method_params['name'];?>
747
                          </option>
748
<?php								endforeach;
749
?>
Ad Schellevis's avatar
Ad Schellevis committed
750
											</select>
751
											<div class="hidden" for="help_for_authmethod">
Ad Schellevis's avatar
Ad Schellevis committed
752
												<?=gettext("Must match the setting chosen on the remote side"); ?>.
753
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
754 755 756
										</td>
									</tr>
									<tr>
757 758
										<td><a id="help_for_mode" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Negotiation mode"); ?></td>
										<td>
Ad Schellevis's avatar
Ad Schellevis committed
759 760
											<select name="mode" class="formselect">
											<?php
761 762 763
                      $modes = array("main" => "Main", "aggressive" => "Aggressive");
                      foreach ($modes as $mode => $mdescr) :
?>
764
			<option value="<?=$mode;?>" <?= $mode == $pconfig['mode'] ? "selected=\"selected\"" : "" ;?> >
765 766
                            <?=$mdescr;?>
												</option>
767
<?php								endforeach;
768 769 770 771 772
?>
											</select>
											<div class="hidden" for="help_for_mode">
												<?=gettext("Aggressive is more flexible, but less secure"); ?>.
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
773 774 775
										</td>
									</tr>
									<tr>
776 777 778 779 780 781 782 783 784 785 786 787 788
										<td ><i class="fa fa-info-circle text-muted"></i> <?=gettext("My identifier"); ?></td>
										<td>
											<select name="myid_type" id="myid_type" class="formselect" onchange="myidsel_change()">
<?php
											$my_identifier_list = array(
												'myaddress' => array( 'desc' => gettext('My IP address'), 'mobile' => true ),
												'address' => array( 'desc' => gettext('IP address'), 'mobile' => true ),
												'fqdn' => array( 'desc' => gettext('Distinguished name'), 'mobile' => true ),
												'user_fqdn' => array( 'desc' => gettext('User distinguished name'), 'mobile' => true ),
												'asn1dn' => array( 'desc' => gettext('ASN.1 distinguished Name'), 'mobile' => true ),
												'keyid tag' => array( 'desc' => gettext('KeyID tag'), 'mobile' => true ),
												'dyn_dns' => array( 'desc' => gettext('Dynamic DNS'), 'mobile' => true ));
											foreach ($my_identifier_list as $id_type => $id_params) :
789 790 791 792
?>
												<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['myid_type']) {
                                                    echo "selected=\"selected\"";
} ?>>
793
													<?=$id_params['desc'];?>
Ad Schellevis's avatar
Ad Schellevis committed
794
												</option>
795 796
											<?php
endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
797
											</select>
798 799 800
											<div id="myid_data">
												<input name="myid_data" type="text" size="30" value="<?=$pconfig['myid_data'];?>" />
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
801 802 803
										</td>
									</tr>
									<tr id="opt_peerid">
804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820
										<td ><i class="fa fa-info-circle text-muted"></i> <?=gettext("Peer identifier"); ?></td>
										<td>
											<select name="peerid_type" id="peerid_type" class="formselect" onchange="peeridsel_change()">
<?php
											$peer_identifier_list = array(
												'peeraddress' => array( 'desc' => gettext('Peer IP address'), 'mobile' => false ),
												'address' => array( 'desc' => gettext('IP address'), 'mobile' => false ),
												'fqdn' => array( 'desc' => gettext('Distinguished name'), 'mobile' => true ),
												'user_fqdn' => array( 'desc' => gettext('User distinguished name'), 'mobile' => true ),
												'asn1dn' => array( 'desc' => gettext('ASN.1 distinguished Name'), 'mobile' => true ),
												'keyid tag' => array( 'desc' =>gettext('KeyID tag'), 'mobile' => true ));
											foreach ($peer_identifier_list as $id_type => $id_params) :
												if (!empty($pconfig['mobile']) && !$id_params['mobile']) {
													continue;
												}
?>
												<option value="<?=$id_type;?>" <?= $id_type == $pconfig['peerid_type'] ? "selected=\"selected\"" : "";?> >
821
				<?=$id_params['desc'];?>
822
												</option>
823
<?php								endforeach;
824
?>
Ad Schellevis's avatar
Ad Schellevis committed
825
											</select>
826 827
											<input name="peerid_data" type="text" id="peerid_data" size="30" value="<?=$pconfig['peerid_data'];?>" />
<?php if (!empty($pconfig['mobile'])) {
828
?>
829
											<small><?=gettext("NOTE: This is known as the \"group\" setting on some VPN client implementations"); ?>.</small>
830 831
										<?php
} ?>
Ad Schellevis's avatar
Ad Schellevis committed
832 833 834
										</td>
									</tr>
									<tr id="opt_psk">
835 836 837 838 839
										<td ><a id="help_for_psk" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Pre-Shared Key"); ?></td>
										<td>
											<input name="pre-shared-key" type="text" class="formfld unknown" id="pskey" size="40"
														 value="<?= $pconfig['authentication_method'] == "pre_shared_key" || $pconfig['authentication_method'] == "xauth_psk_server" ? $pconfig['pre-shared-key'] : "";?>" />
											<div class="hidden" for="help_for_psk">
Ad Schellevis's avatar
Ad Schellevis committed
840
												<?=gettext("Input your Pre-Shared Key string"); ?>.
841
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
842 843 844
										</td>
									</tr>
									<tr id="opt_cert">
845 846
										<td ><a id="help_for_certref" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("My Certificate"); ?></td>
										<td>
Ad Schellevis's avatar
Ad Schellevis committed
847
											<select name="certref" class="formselect">
848 849 850 851 852 853 854
<?php
                      if (isset($config['cert'])) :
                        foreach ($config['cert'] as $cert) :
?>
												<option value="<?=$cert['refid'];?>" <?= isset($pconfig['certref']) && $pconfig['certref'] == $cert['refid'] ? "selected=\"selected\"" : ""?>>
													<?=$cert['descr'];?>
												</option>
855
<?php								endforeach;
856 857
                      endif;
?>
Ad Schellevis's avatar
Ad Schellevis committed
858
											</select>
859
											<div class="hidden" for="help_for_certref">
Ad Schellevis's avatar
Ad Schellevis committed
860
												<?=gettext("Select a certificate previously configured in the Certificate Manager"); ?>.
861
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
862 863 864
										</td>
									</tr>
									<tr id="opt_ca">
865 866
										<td><a id="help_for_caref" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("My Certificate Authority"); ?></td>
										<td>
Ad Schellevis's avatar
Ad Schellevis committed
867 868
											<select name="caref" class="formselect">
											<?php
869
										$config__ca = isset($config['ca']) ? $config['ca'] : array();
870 871 872 873 874 875 876 877 878
                        foreach ($config__ca as $ca) :
                            $selected = "";
                            if ($pconfig['caref'] == $ca['refid']) {
                                $selected = "selected=\"selected\"";
                            }
                        ?>
													<option value="<?=$ca['refid'];?>" <?= isset($pconfig['caref']) && $pconfig['caref'] == $ca['refid'] ? "selected=\"selected\"":"";?>>
														<?=htmlspecialchars($ca['descr']);?>
													</option>
879
<?php								endforeach;
880
?>
Ad Schellevis's avatar
Ad Schellevis committed
881
											</select>
882
											<div class="hidden" for="help_for_caref">
Ad Schellevis's avatar
Ad Schellevis committed
883
												<?=gettext("Select a certificate authority previously configured in the Certificate Manager"); ?>.
884
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
885 886 887
										</td>
									</tr>
									<tr>
888 889 890 891 892 893 894 895 896 897 898 899 900 901 902
										<td colspan="2"><b><?=gettext("Phase 1 proposal (Algorithms)"); ?></b></td>
                  </tr>
									<tr>
										<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Encryption algorithm"); ?></td>
										<td>
											<select name="encryption-algorithm" id="ealgo" class="formselect" onchange="ealgosel_change()">
<?php
                      foreach ($p1_ealgos as $algo => $algodata) :
                      ?>
	                      <option value="<?=$algo;?>" <?= $algo == $pconfig['encryption-algorithm']['name'] ? "selected=\"selected\"" : "" ;?>>
	                          <?=$algodata['name'];?>
	                      </option>
<?php
                      endforeach;
?>
Ad Schellevis's avatar
Ad Schellevis committed
903 904 905 906 907 908
											</select>
											<select name="ealgo_keylen" width="30" class="formselect">
											</select>
										</td>
									</tr>
									<tr>
909 910
										<td><a id="help_for_halgo" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Hash algorithm"); ?></td>
										<td>
Ad Schellevis's avatar
Ad Schellevis committed
911
											<select name="halgo" class="formselect">
912 913 914 915 916 917 918 919 920 921
											<?php
											$p1_halgos = array(
												'md5' => 'MD5',
												'sha1' => 'SHA1',
												'sha256' => 'SHA256',
												'sha384' => 'SHA384',
												'sha512' => 'SHA512',
												'aesxcbc' => 'AES-XCBC'
											);
											foreach ($p1_halgos as $algo => $algoname) :
922
?>
923 924
												<option value="<?=$algo;?>" <?= $algo == $pconfig['halgo'] ? "selected=\"selected\"" : "";?>>
													<?=$algoname;?>
Ad Schellevis's avatar
Ad Schellevis committed
925
												</option>
926
<?php								endforeach;
927
?>
Ad Schellevis's avatar
Ad Schellevis committed
928
											</select>
929
											<div class="hidden" for="help_for_halgo">
Ad Schellevis's avatar
Ad Schellevis committed
930
												<?=gettext("Must match the setting chosen on the remote side"); ?>.
931
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
932 933 934
										</td>
									</tr>
									<tr>
935 936
										<td><a id="help_for_dhgroup" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("DH key group"); ?></td>
										<td>
Ad Schellevis's avatar
Ad Schellevis committed
937
											<select name="dhgroup" class="formselect">
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952
<?php
											$p1_dhgroups = array(
												1  => '1 (768 bit)',
												2  => '2 (1024 bit)',
												5  => '5 (1536 bit)',
												14 => '14 (2048 bit)',
												15 => '15 (3072 bit)',
												16 => '16 (4096 bit)',
												17 => '17 (6144 bit)',
												18 => '18 (8192 bit)',
												22 => '22 (1024(sub 160) bit)',
												23 => '23 (2048(sub 224) bit)',
												24 => '24 (2048(sub 256) bit)'
											);
											foreach ($p1_dhgroups as $keygroup => $keygroupname) :
953
?>
954 955
												<option value="<?=$keygroup;?>" <?= $keygroup == $pconfig['dhgroup'] ? "selected=\"selected\"" : "";?>>
													<?=$keygroupname;?>
Ad Schellevis's avatar
Ad Schellevis committed
956
												</option>
957
<?php								endforeach;
958
?>
Ad Schellevis's avatar
Ad Schellevis committed
959
											</select>
960
											<div class="hidden" for="help_for_dhgroup">
Ad Schellevis's avatar
Ad Schellevis committed
961
												<?=gettext("Must match the setting chosen on the remote side"); ?>.
962
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
963 964 965
										</td>
									</tr>
									<tr>
966 967 968 969 970 971
										<td><a id="help_for_lifetime" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a>  <?=gettext("Lifetime"); ?></td>
										<td>
											<input name="lifetime" type="text" id="lifetime" size="20" value="<?=$pconfig['lifetime'];?>" />
											<div class="hidden" for="help_for_lifetime">
												<?=gettext("seconds"); ?>
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
972 973
										</td>
									</tr>
974
                  <tr>
975
										<td colspan="2"><b><?=gettext("Advanced Options"); ?></b></td>
976
                  </tr>
Ad Schellevis's avatar
Ad Schellevis committed
977
									<tr>
978 979 980 981 982 983
										<td><a id="help_for_rekey_enable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a>  <?=gettext("Enable Rekey");?></td>
										<td>
											<input name="rekey_enable" type="checkbox" id="rekey_enable" value="yes" <?=isset($pconfig['rekey_enable']) ? "checked=\"checked\"" : ""; ?> />
											<div class="hidden" for="help_for_rekey_enable">
												<?=gettext("Whether a connection should be renegotiated when it is about to expire."); ?>
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
984 985 986
										</td>
									</tr>
									<tr>
987 988 989 990 991 992
										<td><a id="help_for_reauth_enable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a>  <?=gettext("Enable Reauth");?></td>
										<td>
											<input name="reauth_enable" type="checkbox" id="reauth_enable" value="yes" <?= isset($pconfig['reauth_enable']) ? "checked=\"checked\"" : "";?> />
											<div class="hidden" for="help_for_reauth_enable">
												<?=gettext("Whether rekeying of an IKE_SA should also reauthenticate the peer. In IKEv1, reauthentication is always done."); ?>
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
993 994 995
										</td>
									</tr>
									<tr>
996 997
										<td><a id="help_for_nat_traversal" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a>  <?=gettext("NAT Traversal"); ?></td>
										<td>
Ad Schellevis's avatar
Ad Schellevis committed
998
											<select name="nat_traversal" class="formselect">
999 1000 1001 1002 1003 1004 1005 1006 1007
												<option value="off" <?= isset($pconfig['nat_traversal']) && $pconfig['nat_traversal'] == "off" ? "selected=\"selected\"" :"" ;?> >
													<?=gettext("Disable"); ?>
												</option>
												<option value="on" <?= isset($pconfig['nat_traversal']) && $pconfig['nat_traversal'] == "on" ? "selected=\"selected\"" :"" ;?> >
													<?=gettext("Enable"); ?>
												</option>
												<option value="force" <?= isset($pconfig['nat_traversal']) && $pconfig['nat_traversal'] == "force" ? "selected=\"selected\"" :"" ;?> >
													<?=gettext("Force"); ?>
												</option>
Ad Schellevis's avatar
Ad Schellevis committed
1008
											</select>
1009 1010 1011 1012
											<div class="hidden" for="help_for_nat_traversal">
													<?=gettext("Set this option to enable the use of NAT-T (i.e. the encapsulation of ESP in UDP packets) if needed, " .
	                                                "which can help with clients that are behind restrictive firewalls"); ?>.
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
1013 1014 1015
										</td>
									</tr>
									<tr>
1016 1017 1018 1019 1020 1021
										<td><a id="help_for_dpd_enable" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a>  <?=gettext("Dead Peer Detection"); ?></td>
										<td>
											<input name="dpd_enable" type="checkbox" id="dpd_enable" value="yes" <?=!empty($pconfig['dpd_delay']) && !empty($pconfig['dpd_maxfail'])?"checked=\"checked\"":"";?> onclick="dpdchkbox_change()" />
											<div class="hidden" for="help_for_dpd_enable">
												<?=gettext("Enable DPD"); ?>
											</div>
Ad Schellevis's avatar
Ad Schellevis committed
1022 1023
											<div id="opt_dpd">
												<br />
1024 1025 1026
												<input name="dpd_delay" type="text" class="formfld unknown" id="dpd_delay" size="5" value="<?=$pconfig['dpd_delay'];?>" />
												<?=gettext("seconds"); ?>
												<div class="hidden" for="help_for_dpd_enable">
Ad Schellevis's avatar
Ad Schellevis committed
1027
													<?=gettext("Delay between requesting peer acknowledgement"); ?>.
1028
												</div>
Ad Schellevis's avatar
Ad Schellevis committed
1029
												<br />
1030 1031 1032
												<input name="dpd_maxfail" type="text" class="formfld unknown" id="dpd_maxfail" size="5" value="<?=$pconfig['dpd_maxfail'];?>" />
												<?=gettext("retries"); ?>
												<div class="hidden" for="help_for_dpd_enable">
Ad Schellevis's avatar
Ad Schellevis committed
1033
													<?=gettext("Number of consecutive failures allowed before disconnect"); ?>.
1034
												</div>
Ad Schellevis's avatar
Ad Schellevis committed
1035 1036 1037 1038
											</div>
										</td>
									</tr>
									<tr>
1039 1040
										<td>&nbsp;</td>
										<td>
1041
											<?php if (isset($p1index) && isset($config['ipsec']['phase1'][$p1index]) && !isset($_GET['dup'])) :
1042
?>
1043
											<input name="p1index" type="hidden" value="<?=$p1index;?>" />
1044 1045
											<?php
endif; ?>
1046
											<?php if (!empty($pconfig['mobile'])) :
1047
?>
Ad Schellevis's avatar
Ad Schellevis committed
1048
											<input name="mobile" type="hidden" value="true" />
1049 1050
											<?php
endif; ?>
1051
											<input name="ikeid" type="hidden" value="<?=$pconfig['ikeid'];?>" />
Ad Schellevis's avatar
Ad Schellevis committed
1052 1053 1054
											<input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
										</td>
									</tr>
1055 1056 1057 1058 1059 1060
                </tbody>
							</table>
						</div>
					</form>
				</div>
			</section>
Ad Schellevis's avatar
Ad Schellevis committed
1061
		</div>
1062 1063
	</div>
</section>
Ad Schellevis's avatar
Ad Schellevis committed
1064

1065
<?php include("foot.inc");