vpn_ipsec_phase1.php 44.3 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 31
	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.
*/

32 33
require_once("functions.inc");
require_once("guiconfig.inc");
Ad Schellevis's avatar
Ad Schellevis committed
34 35 36
require_once("ipsec.inc");
require_once("vpn.inc");

37 38 39
if (!is_array($config['ipsec'])) {
        $config['ipsec'] = array();
}
40

41
if (!is_array($config['ipsec']['phase1'])) {
42
    $config['ipsec']['phase1'] = array();
43
}
Ad Schellevis's avatar
Ad Schellevis committed
44

45
if (!is_array($config['ipsec']['phase2'])) {
46
    $config['ipsec']['phase2'] = array();
47
}
Ad Schellevis's avatar
Ad Schellevis committed
48 49 50 51

$a_phase1 = &$config['ipsec']['phase1'];
$a_phase2 = &$config['ipsec']['phase2'];

52 53 54 55 56 57
if (is_numericint($_GET['p1index'])) {
    $p1index = $_GET['p1index'];
}
if (isset($_POST['p1index']) && is_numericint($_POST['p1index'])) {
    $p1index = $_POST['p1index'];
}
Ad Schellevis's avatar
Ad Schellevis committed
58

59 60 61
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
    $p1index = $_GET['dup'];
}
Ad Schellevis's avatar
Ad Schellevis committed
62 63

if (isset($p1index) && $a_phase1[$p1index]) {
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
    // don't copy the ikeid on dup
    if (!isset($_GET['dup']) || !is_numericint($_GET['dup'])) {
        $pconfig['ikeid'] = $a_phase1[$p1index]['ikeid'];
    }

    $old_ph1ent = $a_phase1[$p1index];

    $pconfig['disabled'] = isset($a_phase1[$p1index]['disabled']);

    if ($a_phase1[$p1index]['interface']) {
        $pconfig['interface'] = $a_phase1[$p1index]['interface'];
    } else {
        $pconfig['interface'] = "wan";
    }

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

    if (isset($a_phase1[$p1index]['mobile'])) {
        $pconfig['mobile'] = 'true';
    } else {
        $pconfig['remotegw'] = $a_phase1[$p1index]['remote-gateway'];
    }

    if (empty($a_phase1[$p1index]['iketype'])) {
        $pconfig['iketype'] = "ikev1";
    } else {
        $pconfig['iketype'] = $a_phase1[$p1index]['iketype'];
    }
    $pconfig['mode'] = $a_phase1[$p1index]['mode'];
    $pconfig['protocol'] = $a_phase1[$p1index]['protocol'];
    $pconfig['myid_type'] = $a_phase1[$p1index]['myid_type'];
    $pconfig['myid_data'] = $a_phase1[$p1index]['myid_data'];
    $pconfig['peerid_type'] = $a_phase1[$p1index]['peerid_type'];
    $pconfig['peerid_data'] = $a_phase1[$p1index]['peerid_data'];
    $pconfig['ealgo'] = $a_phase1[$p1index]['encryption-algorithm'];
    $pconfig['halgo'] = $a_phase1[$p1index]['hash-algorithm'];
    $pconfig['dhgroup'] = $a_phase1[$p1index]['dhgroup'];
    $pconfig['lifetime'] = $a_phase1[$p1index]['lifetime'];
    $pconfig['authentication_method'] = $a_phase1[$p1index]['authentication_method'];

    if (($pconfig['authentication_method'] == "pre_shared_key") ||
        ($pconfig['authentication_method'] == "xauth_psk_server")) {
        $pconfig['pskey'] = $a_phase1[$p1index]['pre-shared-key'];
    } else {
        $pconfig['certref'] = $a_phase1[$p1index]['certref'];
        $pconfig['caref'] = $a_phase1[$p1index]['caref'];
    }

    $pconfig['descr'] = $a_phase1[$p1index]['descr'];
    $pconfig['nat_traversal'] = $a_phase1[$p1index]['nat_traversal'];

    if (!isset($a_phase1[$p1index]['reauth_enable'])) {
        $pconfig['reauth_enable'] = true;
    }
    if (!isset($a_phase1[$p1index]['rekey_enable'])) {
        $pconfig['rekey_enable'] = true;
    }

    if ($a_phase1[$p1index]['dpd_delay'] &&     $a_phase1[$p1index]['dpd_maxfail']) {
        $pconfig['dpd_enable'] = true;
        $pconfig['dpd_delay'] = $a_phase1[$p1index]['dpd_delay'];
        $pconfig['dpd_maxfail'] = $a_phase1[$p1index]['dpd_maxfail'];
    }
Ad Schellevis's avatar
Ad Schellevis committed
127
} else {
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
    /* defaults */
    $pconfig['interface'] = "wan";
    if ($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['ealgo'] = array( name => "3des" );
    $pconfig['halgo'] = "sha1";
    $pconfig['dhgroup'] = "2";
    $pconfig['lifetime'] = "28800";
    $pconfig['nat_traversal'] = "on";
    $pconfig['dpd_enable'] = true;
    $pconfig['iketype'] = "ikev1";

    /* mobile client */
    if ($_GET['mobile']) {
        $pconfig['mobile']=true;
    }
Ad Schellevis's avatar
Ad Schellevis committed
150 151
}

152 153 154
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
    unset($p1index);
}
Ad Schellevis's avatar
Ad Schellevis committed
155 156

if ($_POST) {
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 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 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 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 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
    unset($input_errors);
    $pconfig = $_POST;

    /* input validation */

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

    // 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(" ", "pskey");
            $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 (!$pconfig['mobile']) {
        $reqdfields[] = "remotegw";
        $reqdfieldsn[] = gettext("Remote gateway");
    }

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

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

    if ($pconfig['remotegw']) {
        if (!is_ipaddr($pconfig['remotegw']) && !is_domain($pconfig['remotegw'])) {
            $input_errors[] = gettext("A valid remote gateway address or host name must be specified.");
        } elseif (is_ipaddrv4($pconfig['remotegw']) && ($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['remotegw']) && ($pconfig['protocol'] != "inet6"))
            $input_errors[] = gettext("A valid remote gateway IPv6 address must be specified or you need to change protocol to IPv4");
    }

    if (($pconfig['remotegw'] && is_ipaddr($pconfig['remotegw']) && !isset($pconfig['disabled']) )) {
        $t = 0;
        foreach ($a_phase1 as $ph1tmp) {
            if ($p1index <> $t) {
                $tremotegw = $pconfig['remotegw'];
                if (($ph1tmp['remote-gateway'] == $tremotegw) && !isset($ph1tmp['disabled'])) {
                    $input_errors[] = sprintf(gettext('The remote gateway "%1$s" is already used by phase1 "%2$s".'), $tremotegw, $ph1tmp['descr']);
                }
            }
            $t++;
        }
    }

    if (is_array($a_phase2) && (count($a_phase2))) {
        foreach ($a_phase2 as $phase2) {
            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;
                }
            }
        }
    }

    /* My identity */

    if ($pconfig['myid_type'] == "myaddress") {
        $pconfig['myid_data'] = "";
    }

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

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

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

    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'");
    }

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

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

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

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

    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.");
        }
    }

    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.");
        }
    }

    /* Peer identity */

    if ($pconfig['myid_type'] == "peeraddress") {
        $pconfig['peerid_data'] = "";
    }

    // Only enforce peer ID if we are not dealing with a pure-psk mobile config.
    if (!(($pconfig['authentication_method'] == "pre_shared_key") && ($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.");
            }
        }
    }

    if ($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.");
        }
    }

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

    /* build our encryption algorithms array */
    $pconfig['ealgo'] = array();
    $pconfig['ealgo']['name'] = $_POST['ealgo'];
    if ($pconfig['ealgo_keylen']) {
        $pconfig['ealgo']['keylen'] = $_POST['ealgo_keylen'];
    }

    if (!$input_errors) {
        $ph1ent['ikeid'] = $pconfig['ikeid'];
        $ph1ent['iketype'] = $pconfig['iketype'];
        $ph1ent['disabled'] = $pconfig['disabled'] ? true : false;
        $ph1ent['interface'] = $pconfig['interface'];
        /* 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['remotegw']) {
                mwexec("/sbin/route delete -host {$old_ph1ent['remote-gateway']}");
            }
        }

        if ($pconfig['mobile']) {
            $ph1ent['mobile'] = true;
        } else {
            $ph1ent['remote-gateway'] = $pconfig['remotegw'];
        }

        $ph1ent['mode'] = $pconfig['mode'];
        $ph1ent['protocol'] = $pconfig['protocol'];

        $ph1ent['myid_type'] = $pconfig['myid_type'];
        $ph1ent['myid_data'] = $pconfig['myid_data'];
        $ph1ent['peerid_type'] = $pconfig['peerid_type'];
        $ph1ent['peerid_data'] = $pconfig['peerid_data'];

        $ph1ent['encryption-algorithm'] = $pconfig['ealgo'];
        $ph1ent['hash-algorithm'] = $pconfig['halgo'];
        $ph1ent['dhgroup'] = $pconfig['dhgroup'];
        $ph1ent['lifetime'] = $pconfig['lifetime'];
        $ph1ent['pre-shared-key'] = $pconfig['pskey'];
        $ph1ent['private-key'] = base64_encode($pconfig['privatekey']);
        $ph1ent['certref'] = $pconfig['certref'];
        $ph1ent['caref'] = $pconfig['caref'];
        $ph1ent['authentication_method'] = $pconfig['authentication_method'];
        $ph1ent['descr'] = $pconfig['descr'];
        $ph1ent['nat_traversal'] = $pconfig['nat_traversal'];

        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();
        }

        if (isset($p1index) && $a_phase1[$p1index]) {
            $a_phase1[$p1index] = $ph1ent;
        } else {
            $a_phase1[] = $ph1ent;
        }

        write_config();
        mark_subsystem_dirty('ipsec');

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

432 433 434 435 436
if ($pconfig['mobile']) {
    $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
437 438 439 440 441 442 443
$shortcut_section = "ipsec";


include("head.inc");

?>

Ad Schellevis's avatar
Ad Schellevis committed
444
<body>
Ad Schellevis's avatar
Ad Schellevis committed
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 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
<?php include("fbegin.inc"); ?>
<script type="text/javascript">
//<![CDATA[

function myidsel_change() {
	index = document.iform.myid_type.selectedIndex;
	value = document.iform.myid_type.options[index].value;
	if (value == 'myaddress')
			document.getElementById('myid_data').style.visibility = 'hidden';
	else
			document.getElementById('myid_data').style.visibility = 'visible';
}

function peeridsel_change() {
	index = document.iform.peerid_type.selectedIndex;
	value = document.iform.peerid_type.options[index].value;
	if (value == 'peeraddress')
			document.getElementById('peerid_data').style.visibility = 'hidden';
	else
			document.getElementById('peerid_data').style.visibility = 'visible';
}

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;
497 498
<?php if ($pconfig['mobile']) {
?>
Ad Schellevis's avatar
Ad Schellevis committed
499 500 501 502 503 504 505 506
	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;
507 508
<?php
} ?>
Ad Schellevis's avatar
Ad Schellevis committed
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525
	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) {
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
    if (is_array($algodata['keysel'])) {
        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
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570
}
?>
	}

	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>

Ad Schellevis's avatar
Ad Schellevis committed
571
	<section class="page-content-main">
572
		<div class="container-fluid">
Ad Schellevis's avatar
Ad Schellevis committed
573 574
			<div class="row">
				<?php
575 576 577 578
                if ($input_errors) {
                    print_input_errors($input_errors);
                }
                ?>
579

Ad Schellevis's avatar
Ad Schellevis committed
580
			    <section class="col-xs-12">
581 582

				<?php
583 584 585 586 587 588 589
                        $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);
                    ?>
590 591 592

					<div class="tab-content content-box col-xs-12">

Ad Schellevis's avatar
Ad Schellevis committed
593 594 595
							 <form action="vpn_ipsec_phase1.php" method="post" name="iform" id="iform">

							 <div class="table-responsive">
596 597
								<table class="table table-striped table-sort">

Ad Schellevis's avatar
Ad Schellevis committed
598 599
                                    <thead>
                                        <tr>
600
							<th colspan="2" class="listtopic"><?=gettext("General information"); ?></th>
Ad Schellevis's avatar
Ad Schellevis committed
601 602
                                        </tr>
                                    </thead>
603

Ad Schellevis's avatar
Ad Schellevis committed
604
                                    <tbody>
605

Ad Schellevis's avatar
Ad Schellevis committed
606 607 608
									<tr>
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
										<td width="78%" class="vtable">
609 610 611
											<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) {
                                                echo "checked=\"checked\"";
} ?> />
Ad Schellevis's avatar
Ad Schellevis committed
612 613 614
											<strong><?=gettext("Disable this phase1 entry"); ?></strong><br />
											<span class="vexpl">
												<?=gettext("Set this option to disable this phase1 without " .
615
                                                "removing it from the list"); ?>.
Ad Schellevis's avatar
Ad Schellevis committed
616 617 618 619 620 621 622 623
											</span>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Key Exchange version"); ?></td>
										<td width="78%" class="vtable">
											<select name="iketype" class="formselect">
											<?php
624 625 626 627 628 629 630 631 632 633
                                                $keyexchange = array("ikev1" => "V1", "ikev2" => "V2");
                                            foreach ($keyexchange as $kidx => $name) :
                                            ?>
                                            <option value="<?=$kidx;?>" <?php if ($kidx == $pconfig['iketype']) {
                                                echo "selected=\"selected\"";
} ?>>
                                                <?=htmlspecialchars($name);?>
                                            </option>
											<?php
                                            endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
634 635 636 637 638 639 640 641
											</select> <br /> <span class="vexpl"><?=gettext("Select the KeyExchange Protocol version to be used. Usually known as IKEv1 or IKEv2."); ?>.</span>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Internet Protocol"); ?></td>
										<td width="78%" class="vtable">
											<select name="protocol" class="formselect">
											<?php
642 643 644 645 646 647 648 649 650 651
                                                $protocols = array("inet" => "IPv4", "inet6" => "IPv6");
                                            foreach ($protocols as $protocol => $name) :
                                            ?>
                                            <option value="<?=$protocol;?>" <?php if ($protocol == $pconfig['protocol']) {
                                                echo "selected=\"selected\"";
} ?>>
                                                <?=htmlspecialchars($name);?>
                                            </option>
											<?php
                                            endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
652 653 654 655 656 657 658 659
											</select> <br /> <span class="vexpl"><?=gettext("Select the Internet Protocol family from this dropdown"); ?>.</span>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
										<td width="78%" class="vtable">
											<select name="interface" class="formselect">
											<?php
660 661 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 690 691
                                                $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;?>" <?php if ($iface == $pconfig['interface']) {
                                                echo "selected=\"selected\"";
} ?>>
                                                <?=htmlspecialchars($ifacename);?>
                                            </option>
											<?php
                                            endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
692 693 694 695 696
											</select>
											<br />
											<span class="vexpl"><?=gettext("Select the interface for the local endpoint of this phase1 entry"); ?>.</span>
										</td>
									</tr>
697

698 699
									<?php if (!$pconfig['mobile']) :
?>
700

Ad Schellevis's avatar
Ad Schellevis committed
701 702 703
									<tr>
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote gateway"); ?></td>
										<td width="78%" class="vtable">
704 705
											<?=$mandfldhtml;
?><input name="remotegw" type="text" class="formfld unknown" id="remotegw" size="28" value="<?=htmlspecialchars($pconfig['remotegw']);?>" />
Ad Schellevis's avatar
Ad Schellevis committed
706 707 708 709
											<br />
											<?=gettext("Enter the public IP address or host name of the remote gateway"); ?>
										</td>
									</tr>
710

711 712
									<?php
endif; ?>
713

Ad Schellevis's avatar
Ad Schellevis committed
714 715 716 717 718 719 720
									<tr>
										<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
										<td width="78%" class="vtable">
											<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
											<br />
											<span class="vexpl">
												<?=gettext("You may enter a description here " .
721
                                                "for your reference (not parsed)"); ?>.
Ad Schellevis's avatar
Ad Schellevis committed
722 723 724 725 726 727
											</span>
										</td>
									</tr>
									<tr>
										<td colspan="2" class="list" height="12"></td>
									</tr>
Ad Schellevis's avatar
Ad Schellevis committed
728
                                    </tbody>
729 730 731 732
								</table>

								<table class="table table-striped table-sort">

Ad Schellevis's avatar
Ad Schellevis committed
733 734
                                    <thead>
                                        <tr>
735
							<th colspan="2" class="listtopic"><?=gettext("Phase 1 proposal (Authentication)"); ?></th>
Ad Schellevis's avatar
Ad Schellevis committed
736 737
                                        </tr>
                                    </thead>
738

Ad Schellevis's avatar
Ad Schellevis committed
739
                                    <tbody>
740

Ad Schellevis's avatar
Ad Schellevis committed
741 742 743 744 745
									<tr>
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication method"); ?></td>
										<td width="78%" class="vtable">
											<select name="authentication_method" class="formselect" onchange="methodsel_change()">
											<?php
746 747 748 749 750 751 752 753 754 755 756 757
                                            foreach ($p1_authentication_methods as $method_type => $method_params) :
                                                if (!$pconfig['mobile'] && $method_params['mobile']) {
                                                    continue;
                                                }
                                            ?>
                                            <option value="<?=$method_type;?>" <?php if ($method_type == $pconfig['authentication_method']) {
                                                echo "selected=\"selected\"";
} ?>>
                                                <?=htmlspecialchars($method_params['name']);?>
                                            </option>
											<?php
                                            endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
758 759 760 761 762 763 764 765 766 767 768 769
											</select>
											<br />
											<span class="vexpl">
												<?=gettext("Must match the setting chosen on the remote side"); ?>.
											</span>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Negotiation mode"); ?></td>
										<td width="78%" class="vtable">
											<select name="mode" class="formselect">
											<?php
770 771 772 773 774 775 776 777 778 779
                                                $modes = array("main" => "Main", "aggressive" => "Aggressive");
                                            foreach ($modes as $mode => $mdescr) :
                                            ?>
                                            <option value="<?=$mode;?>" <?php if ($mode == $pconfig['mode']) {
                                                echo "selected=\"selected\"";
} ?>>
                                                <?=htmlspecialchars($mdescr);?>
                                            </option>
											<?php
                                            endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
780 781 782 783 784 785 786
											</select> <br /> <span class="vexpl"><?=gettext("Aggressive is more flexible, but less secure"); ?>.</span>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncellreq"><?=gettext("My identifier"); ?></td>
										<td width="78%" class="vtable">
											<select name="myid_type" class="formselect" onchange="myidsel_change()">
787 788 789 790 791
											<?php foreach ($my_identifier_list as $id_type => $id_params) :
?>
												<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['myid_type']) {
                                                    echo "selected=\"selected\"";
} ?>>
Ad Schellevis's avatar
Ad Schellevis committed
792 793
													<?=htmlspecialchars($id_params['desc']);?>
												</option>
794 795
											<?php
endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
796 797 798 799 800 801 802 803 804
											</select>
											<input name="myid_data" type="text" class="formfld unknown" id="myid_data" size="30" value="<?=htmlspecialchars($pconfig['myid_data']);?>" />
										</td>
									</tr>
									<tr id="opt_peerid">
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer identifier"); ?></td>
										<td width="78%" class="vtable">
											<select name="peerid_type" class="formselect" onchange="peeridsel_change()">
											<?php
805 806 807 808 809 810 811 812 813
                                            foreach ($peer_identifier_list as $id_type => $id_params) :
                                                if ($pconfig['mobile'] && !$id_params['mobile']) {
                                                    continue;
                                                }
                                            ?>
											<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['peerid_type']) {
                                                echo "selected=\"selected\"";
} ?>>
                                            <?=htmlspecialchars($id_params['desc']);?>
Ad Schellevis's avatar
Ad Schellevis committed
814
											</option>
815 816
											<?php
                                            endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
817 818
											</select>
											<input name="peerid_data" type="text" class="formfld unknown" id="peerid_data" size="30" value="<?=htmlspecialchars($pconfig['peerid_data']);?>" />
819 820
										<?php if ($pconfig['mobile']) {
?>
Ad Schellevis's avatar
Ad Schellevis committed
821
											<br /><br /><?=gettext("NOTE: This is known as the \"group\" setting on some VPN client implementations"); ?>.
822 823
										<?php
} ?>
Ad Schellevis's avatar
Ad Schellevis committed
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841
										</td>
									</tr>
									<tr id="opt_psk">
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Pre-Shared Key"); ?></td>
										<td width="78%" class="vtable">
											<?=$mandfldhtml;?>
											<input name="pskey" type="text" class="formfld unknown" id="pskey" size="40" value="<?=htmlspecialchars($pconfig['pskey']);?>" />
											<span class="vexpl">
											<br />
												<?=gettext("Input your Pre-Shared Key string"); ?>.
											</span>
										</td>
									</tr>
									<tr id="opt_cert">
										<td width="22%" valign="top" class="vncellreq"><?=gettext("My Certificate"); ?></td>
										<td width="78%" class="vtable">
											<select name="certref" class="formselect">
											<?php
842 843 844 845 846 847 848 849 850 851 852 853 854 855
                                            if (isset($config['cert'])) :
                                                foreach ($config['cert'] as $cert) :
                                                    $selected = "";
                                                    if ($pconfig['certref'] == $cert['refid']) {
                                                        $selected = "selected=\"selected\"";
                                                    }
                                            ?>
												<option value="<?=$cert['refid'];
?>" <?=$selected;
?>><?=$cert['descr'];?></option>
											<?php
                                                endforeach;

                                            endif; ?>
Ad Schellevis's avatar
Ad Schellevis committed
856 857 858 859 860 861 862 863 864 865 866 867
											</select>
											<br />
											<span class="vexpl">
												<?=gettext("Select a certificate previously configured in the Certificate Manager"); ?>.
											</span>
										</td>
									</tr>
									<tr id="opt_ca">
										<td width="22%" valign="top" class="vncellreq"><?=gettext("My Certificate Authority"); ?></td>
										<td width="78%" class="vtable">
											<select name="caref" class="formselect">
											<?php
868 869 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'];
?>" <?=$selected;
?>><?=$ca['descr'];?></option>
											<?php
                                            endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
879 880 881 882 883 884 885
											</select>
											<br />
											<span class="vexpl">
												<?=gettext("Select a certificate authority previously configured in the Certificate Manager"); ?>.
											</span>
										</td>
									</tr>
Ad Schellevis's avatar
Ad Schellevis committed
886
									</tbody>
887 888 889 890
								</table>

								<table class="table table-striped table-sort">

Ad Schellevis's avatar
Ad Schellevis committed
891 892
                                    <thead>
                                        <tr>
893
							<th colspan="2" class="listtopic"><?=gettext("Phase 1 proposal (Algorithms)"); ?></th>
Ad Schellevis's avatar
Ad Schellevis committed
894 895
                                        </tr>
                                    </thead>
896

Ad Schellevis's avatar
Ad Schellevis committed
897
                                    <tbody>
898

Ad Schellevis's avatar
Ad Schellevis committed
899 900 901 902 903
									<tr>
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Encryption algorithm"); ?></td>
										<td width="78%" class="vtable">
											<select name="ealgo" class="formselect" onchange="ealgosel_change()">
											<?php
904 905 906 907 908 909 910 911 912 913 914
                                            foreach ($p1_ealgos as $algo => $algodata) :
                                                $selected = "";
                                                if ($algo == $pconfig['ealgo']['name']) {
                                                    $selected = " selected=\"selected\"";
                                                }
                                            ?>
                                            <option value="<?=$algo;?>"<?=$selected?>>
                                                <?=htmlspecialchars($algodata['name']);?>
                                            </option>
											<?php
                                            endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
915 916 917 918 919 920 921 922 923
											</select>
											<select name="ealgo_keylen" width="30" class="formselect">
											</select>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Hash algorithm"); ?></td>
										<td width="78%" class="vtable">
											<select name="halgo" class="formselect">
924 925 926 927 928
											<?php foreach ($p1_halgos as $algo => $algoname) :
?>
												<option value="<?=$algo;?>" <?php if ($algo == $pconfig['halgo']) {
                                                    echo "selected=\"selected\"";
} ?>>
Ad Schellevis's avatar
Ad Schellevis committed
929 930
													<?=htmlspecialchars($algoname);?>
												</option>
931 932
											<?php
endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
933 934 935 936 937 938 939 940 941 942 943
											</select>
											<br />
											<span class="vexpl">
												<?=gettext("Must match the setting chosen on the remote side"); ?>.
											</span>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncellreq"><?=gettext("DH key group"); ?></td>
										<td width="78%" class="vtable">
											<select name="dhgroup" class="formselect">
944 945 946 947 948
											<?php foreach ($p1_dhgroups as $keygroup => $keygroupname) :
?>
												<option value="<?=$keygroup;?>" <?php if ($keygroup == $pconfig['dhgroup']) {
                                                    echo "selected=\"selected\"";
} ?>>
Ad Schellevis's avatar
Ad Schellevis committed
949 950
													<?=htmlspecialchars($keygroupname);?>
												</option>
951 952
											<?php
endforeach; ?>
Ad Schellevis's avatar
Ad Schellevis committed
953 954 955 956 957 958 959 960 961 962 963 964 965 966
											</select>
											<br />
											<span class="vexpl">
												<?=gettext("Must match the setting chosen on the remote side"); ?>.
											</span>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncell"><?=gettext("Lifetime"); ?></td>
										<td width="78%" class="vtable">
											<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="20" value="<?=htmlspecialchars($pconfig['lifetime']);?>" />
											<?=gettext("seconds"); ?>
										</td>
									</tr>
Ad Schellevis's avatar
Ad Schellevis committed
967
									</tbody>
968 969 970 971
								</table>

								<table class="table table-striped table-sort">

Ad Schellevis's avatar
Ad Schellevis committed
972 973
                                    <thead>
                                        <tr>
974
							<th colspan="2" class="listtopic"><?=gettext("Advanced Options"); ?></th>
Ad Schellevis's avatar
Ad Schellevis committed
975 976
                                        </tr>
                                    </thead>
977 978

								<tbody>
Ad Schellevis's avatar
Ad Schellevis committed
979 980 981
									<tr>
										<td width="22%" valign="top" class="vncell"><?=gettext("Disable Rekey");?></td>
										<td width="78%" class="vtable">
982 983 984
											<input name="rekey_enable" type="checkbox" id="rekey_enable" value="yes" <?php if (isset($pconfig['rekey_enable'])) {
                                                echo "checked=\"checked\"";
} ?> />
Ad Schellevis's avatar
Ad Schellevis committed
985 986 987 988 989 990
											<?=gettext("Whether a connection should be renegotiated when it is about to expire."); ?><br />
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncell"><?=gettext("Disable Reauth");?></td>
										<td width="78%" class="vtable">
991 992 993
											<input name="reauth_enable" type="checkbox" id="reauth_enable" value="yes" <?php if (isset($pconfig['reauth_enable'])) {
                                                echo "checked=\"checked\"";
} ?> />
Ad Schellevis's avatar
Ad Schellevis committed
994 995 996 997 998 999 1000
											<?=gettext("Whether rekeying of an IKE_SA should also reauthenticate the peer. In IKEv1, reauthentication is always done."); ?><br />
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncell"><?=gettext("NAT Traversal"); ?></td>
										<td width="78%" class="vtable">
											<select name="nat_traversal" class="formselect">
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012
												<option value="off" <?php if ($pconfig['nat_traversal'] == "off") {
                                                    echo "selected=\"selected\"";

} ?>><?=gettext("Disable"); ?></option>
												<option value="on" <?php if ($pconfig['nat_traversal'] == "on") {
                                                    echo "selected=\"selected\"";

} ?>><?=gettext("Enable"); ?></option>
												<option value="force" <?php if ($pconfig['nat_traversal'] == "force") {
                                                    echo "selected=\"selected\"";

} ?>><?=gettext("Force"); ?></option>
Ad Schellevis's avatar
Ad Schellevis committed
1013 1014 1015 1016
											</select>
											<br />
											<span class="vexpl">
												<?=gettext("Set this option to enable the use of NAT-T (i.e. the encapsulation of ESP in UDP packets) if needed, " .
1017
                                                "which can help with clients that are behind restrictive firewalls"); ?>.
Ad Schellevis's avatar
Ad Schellevis committed
1018 1019 1020 1021 1022 1023
											</span>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top" class="vncell"><?=gettext("Dead Peer Detection"); ?></td>
										<td width="78%" class="vtable">
1024 1025 1026
											<input name="dpd_enable" type="checkbox" id="dpd_enable" value="yes" <?php if (isset($pconfig['dpd_enable'])) {
                                                echo "checked=\"checked\"";
} ?> onclick="dpdchkbox_change()" />
Ad Schellevis's avatar
Ad Schellevis committed
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
											<?=gettext("Enable DPD"); ?><br />
											<div id="opt_dpd">
												<br />
												<input name="dpd_delay" type="text" class="formfld unknown" id="dpd_delay" size="5" value="<?=htmlspecialchars($pconfig['dpd_delay']);?>" />
												<?=gettext("seconds"); ?><br />
												<span class="vexpl">
													<?=gettext("Delay between requesting peer acknowledgement"); ?>.
												</span><br />
												<br />
												<input name="dpd_maxfail" type="text" class="formfld unknown" id="dpd_maxfail" size="5" value="<?=htmlspecialchars($pconfig['dpd_maxfail']);?>" />
												<?=gettext("retries"); ?><br />
												<span class="vexpl">
													<?=gettext("Number of consecutive failures allowed before disconnect"); ?>.
												</span>
												<br />
											</div>
										</td>
									</tr>
									<tr>
										<td width="22%" valign="top">&nbsp;</td>
										<td width="78%">
1048 1049
											<?php if (isset($p1index) && $a_phase1[$p1index]) :
?>
Ad Schellevis's avatar
Ad Schellevis committed
1050
											<input name="p1index" type="hidden" value="<?=htmlspecialchars($p1index);?>" />
1051 1052 1053 1054
											<?php
endif; ?>
											<?php if ($pconfig['mobile']) :
?>
Ad Schellevis's avatar
Ad Schellevis committed
1055
											<input name="mobile" type="hidden" value="true" />
1056 1057
											<?php
endif; ?>
Ad Schellevis's avatar
Ad Schellevis committed
1058 1059 1060 1061
											<input name="ikeid" type="hidden" value="<?=htmlspecialchars($pconfig['ikeid']);?>" />
											<input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
										</td>
									</tr>
Ad Schellevis's avatar
Ad Schellevis committed
1062
                                    </tbody>
Ad Schellevis's avatar
Ad Schellevis committed
1063
								</table>
Ad Schellevis's avatar
Ad Schellevis committed
1064
							</div>
Ad Schellevis's avatar
Ad Schellevis committed
1065
							 </form>
1066

Ad Schellevis's avatar
Ad Schellevis committed
1067 1068
					</div>
			    </section>
Ad Schellevis's avatar
Ad Schellevis committed
1069
			</div>
Ad Schellevis's avatar
Ad Schellevis committed
1070 1071
		</div>
	</section>
1072

Ad Schellevis's avatar
Ad Schellevis committed
1073 1074 1075 1076

<script type="text/javascript">
//<![CDATA[
<?php
1077 1078 1079 1080 1081 1082 1083
    /* determine if we should init the key length */
    $keyset = '';
if (isset($pconfig['ealgo']['keylen'])) {
    if (is_numeric($pconfig['ealgo']['keylen'])) {
        $keyset = $pconfig['ealgo']['keylen'];
    }
}
Ad Schellevis's avatar
Ad Schellevis committed
1084 1085 1086 1087 1088 1089 1090 1091
?>
myidsel_change();
peeridsel_change();
methodsel_change();
ealgosel_change(<?=$keyset;?>);
dpdchkbox_change();
//]]>
</script>
1092
<?php include("foot.inc");