vpn_ipsec.php 30.6 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1
<?php
2

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

31
require_once("guiconfig.inc");
Ad Schellevis's avatar
Ad Schellevis committed
32
require_once("filter.inc");
33
require_once("ipsec.inc");
34
require_once("services.inc");
35
require_once("pfsense-utils.inc");
36
require_once("interfaces.inc");
Ad Schellevis's avatar
Ad Schellevis committed
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 62 63 64 65 66
/*
 *  Return phase2 idinfo in text format
 */
function ipsec_idinfo_to_text(& $idinfo) {
    global $config;

    switch ($idinfo['type']) {
        case "address":
            return $idinfo['address'];
            break; /* NOTREACHED */
        case "network":
            return $idinfo['address']."/".$idinfo['netbits'];
            break; /* NOTREACHED */
        case "mobile":
            return gettext("Mobile Client");
            break; /* NOTREACHED */
        case "none":
            return gettext("None");
            break; /* NOTREACHED */
        default:
            if (!empty($config['interfaces'][$idinfo['type']])) {
                return convert_friendly_interface_to_friendly_descr($idinfo['type']);
            } else {
                return strtoupper($idinfo['type']);
            }
            break; /* NOTREACHED */
    }
}

67
if (!isset($config['ipsec']) || !is_array($config['ipsec'])) {
68
    $config['ipsec'] = array();
69
}
70
if (!isset($config['ipsec']['phase1'])) {
71
    $config['ipsec']['phase1'] = array();
72
}
73
if (!isset($config['ipsec']['phase2'])) {
74
    $config['ipsec']['phase2'] = array();
75
}
Ad Schellevis's avatar
Ad Schellevis committed
76

77
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
78 79 80
    $a_phase1 = &$config['ipsec']['phase1'];
    $a_phase2 = &$config['ipsec']['phase2'];
    if (isset($_POST['apply'])) {
81
        ipsec_configure();
82 83 84
        /* reload the filter in the background */
        filter_configure();
        $savemsg = get_std_save_message();
85
        clear_subsystem_dirty('ipsec');
86
    } elseif (isset($_POST['save'])) {
87 88
        $config['ipsec']['enable'] = !empty($_POST['enable']) ? true : false;
        write_config();
89
        ipsec_configure();
90 91
        header("Location: vpn_ipsec.php");
        exit;
92 93 94 95 96 97
    } elseif (!empty($_POST['act']) && $_POST['act'] == "delphase1" ) {
        $del_items = array();
        if (isset($_POST['id']) && isset($config['ipsec']['phase1'][$_POST['id']])){
            $del_items[] = $_POST['id'];
        } elseif (empty($_POST['id']) && isset($_POST['p1entry']) && count($_POST['p1entry'])) {
            $del_items = $_POST['p1entry'];
98 99
        }

100
        foreach ($del_items as $p1entrydel) {
101
            /* remove static route if interface is not WAN */
102 103
            if ($a_phase1[$p1entrydel]['interface'] <> "wan") {
                mwexec('/sbin/route delete -host ' . escapeshellarg($a_phase1[$p1entrydel]['remote-gateway']));
104 105
            }
            /* remove all phase2 entries that match the ikeid */
106
            $ikeid = $a_phase1[$p1entrydel]['ikeid'];
107 108 109 110 111
            foreach ($a_phase2 as $p2index => $ph2tmp) {
                if ($ph2tmp['ikeid'] == $ikeid) {
                    unset($a_phase2[$p2index]);
                }
            }
112
            unset($config['ipsec']['phase1'][$p1entrydel]);
113 114
        }

115 116 117 118 119 120 121 122 123 124 125
        if (write_config()) {
            mark_subsystem_dirty('ipsec');
        }
        header("Location: vpn_ipsec.php");
        exit;
    } elseif (!empty($_POST['act']) && $_POST['act'] == "delphase2" ) {
        if (isset($_POST['id']) && isset($config['ipsec']['phase2'][$_POST['id']])){
            unset($config['ipsec']['phase2'][$_POST['id']]);
        } elseif (empty($_POST['id']) && isset($_POST['p2entry']) && count($_POST['p2entry'])) {
            foreach ($_POST['p2entry'] as $p1entrydel) {
                unset($config['ipsec']['phase2'][$p1entrydel]);
126
            }
127
        }
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
        if (write_config()) {
            mark_subsystem_dirty('ipsec');
        }
        header("Location: vpn_ipsec.php");
        exit;
    } elseif (!empty($_POST['act']) && $_POST['act'] == "movep1" ) {
        // move phase 1 records
        if (isset($_POST['p1entry']) && count($_POST['p1entry']) > 0) {
            // if rule not set/found, move to end
            if (!isset($_POST['id']) || !isset($a_phase1[$_POST['id']])) {
                $id = count($a_phase1);
            } else {
                $id = $_POST['id'];
            }
            $a_phase1 = legacy_move_config_list_items($a_phase1, $id,  $_POST['p1entry']);
        }
        if (write_config()) {
            mark_subsystem_dirty('ipsec');
        }
        header("Location: vpn_ipsec.php");
        exit;
    } elseif (!empty($_POST['act']) && $_POST['act'] == "movep2" ) {
        // move phase 2 records
        if (isset($_POST['p2entry']) && count($_POST['p2entry']) > 0) {
            // if rule not set/found, move to end
            if (!isset($_POST['id']) || !isset($a_phase2[$_POST['id']])) {
                $id = count($a_phase2);
            } else {
                $id = $_POST['id'];
            }
            $a_phase2 = legacy_move_config_list_items($a_phase2, $id,  $_POST['p2entry']);
        }
        if (write_config()) {
            mark_subsystem_dirty('ipsec');
        }
163 164
        header("Location: vpn_ipsec.php");
        exit;
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
    } elseif (!empty($_POST['act']) && $_POST['act'] == "togglep1" && isset($a_phase1[$_POST['id']]) ) {
        // toggle phase 1 record
        if (isset($a_phase1[$_POST['id']]['disabled'])) {
            unset($a_phase1[$_POST['id']]['disabled']);
        } else {
            $a_phase1[$_POST['id']]['disabled'] = true;
        }
        if (write_config()) {
            mark_subsystem_dirty('ipsec');
        }
        header("Location: vpn_ipsec.php");
        exit;
    } elseif (!empty($_POST['act']) && $_POST['act'] == "togglep2" && isset($a_phase2[$_POST['id']]) ) {
        // toggle phase 2 record
        if (isset($a_phase2[$_POST['id']]['disabled'])) {
            unset($a_phase2[$_POST['id']]['disabled']);
        } else {
            $a_phase2[$_POST['id']]['disabled'] = true;
        }
        if (write_config()) {
            mark_subsystem_dirty('ipsec');
        }
        header("Location: vpn_ipsec.php");
        exit;
189
    }
Ad Schellevis's avatar
Ad Schellevis committed
190 191
}

192 193 194 195 196
// form data
$pconfig = $config['ipsec'];
$pconfig['enable'] = isset($config['ipsec']['enable']);
legacy_html_escape_form_data($pconfig);

197
$service_hook = 'ipsec';
Ad Schellevis's avatar
Ad Schellevis committed
198 199 200 201

include("head.inc");
?>

202
<body>
203
<script type="text/javascript">
204
$( document ).ready(function() {
205
    // link move/toggle buttons (phase 1 and phase 2)
206 207 208 209 210 211 212
    $(".act_move").click(function(event){
      event.preventDefault();
      $("#id").val($(this).data("id"));
      $("#action").val($(this).data("act"));
      $("#iform").submit();
    });

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
    // link delete phase 1 buttons
    $(".act_delete_p1").click(function(event){
      event.preventDefault();
      var id = $(this).data("id");
      if (id != 'x') {
        // delete single
        BootstrapDialog.show({
          type:BootstrapDialog.TYPE_DANGER,
          title: "<?= gettext("IPSEC");?>",
          message: "<?=gettext("Do you really want to delete this phase1 and all associated phase2 entries?"); ?>",
          buttons: [{
                    label: "<?= gettext("No");?>",
                    action: function(dialogRef) {
                        dialogRef.close();
                    }}, {
                    label: "<?= gettext("Yes");?>",
                    action: function(dialogRef) {
                      $("#id").val(id);
                      $("#action").val("delphase1");
                      $("#iform").submit()
                  }
                }]
      });
      } else {
        // delete selected
        BootstrapDialog.show({
          type:BootstrapDialog.TYPE_DANGER,
          title: "<?= gettext("IPSEC");?>",
          message: "<?=gettext("Do you really want to delete the selected phase1 entries?");?>",
          buttons: [{
                    label: "<?= gettext("No");?>",
                    action: function(dialogRef) {
                        dialogRef.close();
                    }}, {
                    label: "<?= gettext("Yes");?>",
                    action: function(dialogRef) {
                      $("#id").val("");
                      $("#action").val("delphase1");
                      $("#iform").submit()
                  }
                }]
        });
      }
    });

    // link delete phase 2 buttons
    $(".act_delete_p2").click(function(event){
      event.preventDefault();
      var id = $(this).data("id");
      if (id != 'x') {
        // delete single
        BootstrapDialog.show({
          type:BootstrapDialog.TYPE_DANGER,
          title: "<?= gettext("IPSEC");?>",
          message: "<?=gettext("Do you really want to delete this phase2 entry?"); ?>",
          buttons: [{
                    label: "<?= gettext("No");?>",
                    action: function(dialogRef) {
                        dialogRef.close();
                    }}, {
                    label: "<?= gettext("Yes");?>",
                    action: function(dialogRef) {
                      $("#id").val(id);
                      $("#action").val("delphase2");
                      $("#iform").submit()
                  }
                }]
      });
      } else {
        // delete selected
        BootstrapDialog.show({
          type:BootstrapDialog.TYPE_DANGER,
          title: "<?= gettext("IPSEC");?>",
          message: "<?=gettext("Do you really want to delete the selected phase2 entries?");?>",
          buttons: [{
                    label: "<?= gettext("No");?>",
                    action: function(dialogRef) {
                        dialogRef.close();
                    }}, {
                    label: "<?= gettext("Yes");?>",
                    action: function(dialogRef) {
                      $("#id").val("");
                      $("#action").val("delphase2");
                      $("#iform").submit()
                  }
                }]
        });
      }
    });

    // show phase 2 entries
    $(".act_show_p2").click(function(){
        $("#tdph2-"+$(this).data("id")).show();
        $("#shph2but-"+$(this).data("id")).hide();
    });
});
310 311
</script>

312 313 314 315 316 317 318 319 320
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
  <div class="container-fluid">
    <div class="row">
<?php
      if (isset($savemsg)) {
          print_info_box($savemsg);
      }
      if ($pconfig['enable'] && is_subsystem_dirty('ipsec')) {
Fabian Franz's avatar
Fabian Franz committed
321
          print_info_box_apply(gettext("The IPsec tunnel configuration has been changed.") . "<br />" . gettext("You must apply the changes in order for them to take effect."));
322 323 324 325 326
      }?>
      <section class="col-xs-12">
        <form method="post" name="iform" id="iform">
          <input type="hidden" id="id" name="id" value="" />
          <input type="hidden" id="action" name="act" value="" />
327 328 329
           <div class="tab-content content-box col-xs-12">
              <div class="table-responsive">
                <table class="table table-striped">
330
                  <thead>
331 332 333
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
334
                    <td class="hidden-xs"><?=gettext("Type"); ?></td>
335
                    <td><?=gettext("Remote Gateway"); ?></td>
336 337 338
                    <td class="hidden-xs"><?=gettext("Mode"); ?></td>
                    <td class="hidden-xs"><?=gettext("Phase 1 Proposal"); ?></td>
                    <td class="hidden-xs"><?=gettext("Authentication"); ?></td>
339
                    <td><?=gettext("Description"); ?></td>
340 341 342
                    <td>
                    </td>
                  </tr>
343 344
                  </thead>
                  <tbody>
Ad Schellevis's avatar
Ad Schellevis committed
345
<?php
346 347 348 349 350 351 352
                  $i = 0;
                  foreach ($pconfig['phase1'] as $ph1ent) :?>
                    <tr>
                      <td>
                        <input type="checkbox" name="p1entry[]" value="<?=$i;?>"/>
                      </td>
                      <td>
353 354
                        <button data-id="<?=$i; ?>" data-act="togglep1" type="submit"
                            type="submit" class="act_move btn btn-<?= isset($ph1ent['disabled'])? "default":"success"?> btn-xs"
355 356 357 358
                            title="<?=(isset($ph1ent['disabled'])) ? gettext("enable phase 1 entry") : gettext("disable phase 1 entry");?>" data-toggle="tooltip">
                          <span class="glyphicon glyphicon-play"></span>
                        </button>
                      </td>
359
                      <td class="hidden-xs">
360 361
                          <?=empty($ph1ent['protocol']) || $ph1ent['protocol'] == "inet" ? "IPv4" : "IPv6"; ?>
                          <?=empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1" ? "IKE" : "IKEv2"; ?>
362 363
                      </td>
                      <td>
Ad Schellevis's avatar
Ad Schellevis committed
364
<?php
365 366
                        if (!empty($ph1ent['interface'])) {
                            $iflabels = get_configured_interface_with_descr();
367

368 369 370 371
                            $carplist = get_configured_carp_interface_list();
                            foreach ($carplist as $cif => $carpip) {
                                $iflabels[$cif] = $carpip." (".get_vip_descr($carpip).")";
                            }
372

373 374 375 376
                            $aliaslist = get_configured_ip_aliases_list();
                            foreach ($aliaslist as $aliasip => $aliasif) {
                                $iflabels[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
                            }
377

378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
                            $grouplist = return_gateway_groups_array();
                            foreach ($grouplist as $name => $group) {
                                if ($group[0]['vip'] <> "") {
                                    $vipif = $group[0]['vip'];
                                } else {
                                    $vipif = $group[0]['int'];
                                }
                                $iflabels[$name] = "GW Group {$name}";
                            }
                            $if = $iflabels[$ph1ent['interface']];
                        } else {
                            $if = "WAN";
                        }?>
                        <?=htmlspecialchars($if);?>
                        <?=!isset($ph1ent['mobile'])?
                        $ph1ent['remote-gateway']
                        :
                        "<strong>" . gettext("Mobile Client") . "</strong>";
                        ?>
                      </td>
398
                      <td class="hidden-xs">
399 400
                        <?=htmlspecialchars($ph1ent['mode']);?>
                      </td>
401
                      <td class="hidden-xs">
402
                        <?=$p1_ealgos[$ph1ent['encryption-algorithm']['name']]['name'];?>
Ad Schellevis's avatar
Ad Schellevis committed
403
<?php
404 405 406 407
                        if (!empty($ph1ent['encryption-algorithm']['keylen'])) {
                            if ($ph1ent['encryption-algorithm']['keylen']=="auto") {
                                echo " (" . gettext("auto") . ")";
                            } else {
408
                                echo " ({$ph1ent['encryption-algorithm']['keylen']}&nbsp;" . gettext("bits") . ")";
409
                            }
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
                        }?> +

                        <?=strtoupper($ph1ent['hash-algorithm']);?> +

<?php
                          $p1_dhgroups = array(
                            1  => '1 (768&nbsp;bits)',
                            2  => '2 (1024&nbsp;bits)',
                            5  => '5 (1536&nbsp;bits)',
                            14 => '14 (2048&nbsp;bits)',
                            15 => '15 (3072&nbsp;bits)',
                            16 => '16 (4096&nbsp;bits)',
                            17 => '17 (6144&nbsp;bits)',
                            18 => '18 (8192&nbsp;bits)',
                            22 => '22 (1024(sub 160)&nbsp;bits)',
                            23 => '23 (2048(sub 224)&nbsp;bits)',
                            24 => '24 (2048(sub 256)&nbsp;bits)'
                          );
?>
                          <?=gettext("DH Group"); ?>&nbsp;<?=$p1_dhgroups[$ph1ent['dhgroup']];?>
430
                      </td>
431
                      <td class="hidden-xs">
432 433 434 435 436 437 438 439 440 441
<?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 ) );
?>
                          <?=$p1_authentication_methods[$ph1ent['authentication_method']]['name'];?>
442 443 444 445 446 447
                      </td>
                      <td>
                          <?=$ph1ent['descr'];?>&nbsp;
                      </td>
                      <td>
                        <button data-id="<?=$i; ?>" data-act="movep1" type="submit" class="act_move btn btn-default btn-xs"
448
                            title="<?=gettext("move selected entries before this");?>" data-toggle="tooltip">
449 450 451
                          <span class="glyphicon glyphicon-arrow-left"></span>
                        </button>
                        <a href="vpn_ipsec_phase1.php?p1index=<?=$i; ?>" class="btn btn-default btn-xs" alt="edit"
452
                            title="<?=gettext("edit phase1 entry"); ?>" data-toggle="tooltip">
453 454 455
                          <span class="glyphicon glyphicon-pencil"></span>
                        </a><br/>
                        <button data-id="<?=$i; ?>"
456
                            title="<?=gettext("delete phase1 entry");?>" data-toggle="tooltip"
457 458
                            type="submit"
                            class="act_delete_p1 btn btn-default btn-xs">
459
                            <span class="fa fa-trash text-muted"></span>
460 461
                        </button>
<?php                   if (!isset($ph1ent['mobile'])) :
462
?>
463
                        <a href="vpn_ipsec_phase1.php?dup=<?=$i; ?>" class="btn btn-default btn-xs" alt="add"
464
                            title="<?=gettext("clone phase1 entry"); ?>" data-toggle="tooltip">
465 466
                                        <span class="fa fa-clone text-muted"></span>
                        </a>
Ad Schellevis's avatar
Ad Schellevis committed
467
<?php
468 469 470 471 472
                        endif;?>
                      </td>
                    </tr>
                    <tr>
                      <td colspan="9">
Ad Schellevis's avatar
Ad Schellevis committed
473
<?php
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
                        $phase2count=0;
                        foreach ($pconfig['phase2'] as $ph2ent) {
                            if ($ph2ent['ikeid'] != $ph1ent['ikeid']) {
                                continue;
                            }
                            $phase2count++;
                        }?>
                        <div id="shph2but-<?=$i?>">
                          <button class="act_show_p2 btn btn-xs" type="button" data-id="<?=$i?>">
                            <i class="fa fa-plus"></i> <?php printf(gettext("Show %s Phase-2 entries"), $phase2count); ?>
                          </button>
                        </div>
                        <div id="tdph2-<?=$i?>" style="display:none">
                          <table class="table table-striped table-condensed">
                            <thead>
                              <tr>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
492
                                <td class="hidden-xs"><?=gettext("Type"); ?></td>
493 494
                                <td><?=gettext("Local Subnet"); ?></td>
                                <td><?=gettext("Remote Subnet"); ?></td>
495 496 497 498
                                <td class="hidden-xs"><?=gettext("Encryption Protocols"); ?></td>
                                <td class="hidden-xs"><?=gettext("Authenticity Protocols"); ?></td>
                                <td class="hidden-xs"><?=gettext("PFS"); ?></td>
                                <td>&nbsp;</td>
499 500 501
                              </tr>
                            </thead>
                            <tbody>
Ad Schellevis's avatar
Ad Schellevis committed
502
<?php
503 504 505 506 507 508 509 510 511 512
                            $j = 0;
                            foreach ($pconfig['phase2'] as $ph2index => $ph2ent) :
                                if ($ph2ent['ikeid'] != $ph1ent['ikeid']) {
                                    continue;
                                }?>
                              <tr>
                                <td>
                                  <input type="checkbox" name="p2entry[]" value="<?=$ph2index;?>"/>
                                </td>
                                <td>
513
                                  <button data-id="<?=$ph2index; ?>" data-act="togglep2" type="submit"
514
                                      title="<?=(isset($ph2ent['disabled'])) ? gettext("enable phase 2 entry") : gettext("disable phase 2 entry"); ?>" data-toggle="tooltip"
515
                                      class="act_move btn btn-<?= isset($ph2ent['disabled'])?"default":"success";?> btn-xs">
516 517 518
                                    <span class="glyphicon glyphicon-play"></span>
                                  </button>
                                </td>
519
                                <td class="hidden-xs">
520 521 522
                                  <?=$p2_protos[$ph2ent['protocol']];?>
                                  <?=isset($ph2ent['mode']) ? array_search($ph2ent['mode'], array("IPv4 tunnel" => "tunnel", "IPv6 tunnel" => "tunnel6", "transport" => "transport")) : ""; ?>
                                </td>
Ad Schellevis's avatar
Ad Schellevis committed
523
<?php
524 525 526 527 528 529 530
                                if (($ph2ent['mode'] == "tunnel") || ($ph2ent['mode'] == "tunnel6")) :?>
                                <td>
                                  <?=ipsec_idinfo_to_text($ph2ent['localid']); ?>
                                </td>
                                <td>
                                  <?=ipsec_idinfo_to_text($ph2ent['remoteid']); ?>
                                </td>
Ad Schellevis's avatar
Ad Schellevis committed
531
<?php
532 533 534
                                else :?>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
Ad Schellevis's avatar
Ad Schellevis committed
535
<?php
536
                                endif;?>
537
                                <td class="hidden-xs">
Ad Schellevis's avatar
Ad Schellevis committed
538
<?php
539 540 541 542 543 544 545 546 547 548 549 550 551 552
                                  foreach ($ph2ent['encryption-algorithm-option'] as $k => $ph2ea) {
                                      if ($k > 0) {
                                          echo ", ";
                                      }
                                      echo $p2_ealgos[$ph2ea['name']]['name'];
                                      if (!empty($ph2ea['keylen'])) {
                                          if ($ph2ea['keylen']=="auto") {
                                              echo " (" . gettext("auto") . ")";
                                          } else {
                                              echo " ({$ph2ea['keylen']} " . gettext("bits") . ")";
                                          }
                                      }
                                  }?>
                                </td>
553
                                <td class="hidden-xs">
554 555 556 557 558 559 560 561 562 563
<?php
                                  if (!empty($ph2ent['hash-algorithm-option']) && is_array($ph2ent['hash-algorithm-option'])) {
                                      foreach ($ph2ent['hash-algorithm-option'] as $k => $ph2ha) {
                                          if ($k) {
                                              echo ", ";
                                          }
                                          echo $p2_halgos[$ph2ha];
                                      }
                                  }?>
                                </td>
564 565
<?php
                                if (isset($ph2ent['pfsgroup'])): ?>
566
                                <td class="hidden-xs"><?=gettext("Group"); ?> <?=$p2_pfskeygroups[$ph2ent['pfsgroup']];?> </td>
567 568
<?php
                                else: ?>
569
                                <td class="hidden-xs"><?=gettext("off"); ?></td>
570 571
<?php
                                endif; ?>
572 573
                                <td>
                                    <button data-id="<?=$j; ?>" data-act="movep2"
574
                                        title="<?=gettext("move selected entries before this");?>" data-toggle="tooltip"
575 576 577 578 579
                                        type="submit"
                                        class="act_move btn btn-default btn-xs">
                                        <span class="glyphicon glyphicon-arrow-left"></span>
                                    </button>
                                    <a href="vpn_ipsec_phase2.php?p2index=<?=$ph2ent['uniqid']; ?>"
580
                                        title="<?=gettext("edit phase 2 entry"); ?>" data-toggle="tooltip"
581 582 583 584
                                        alt="edit" class="btn btn-default btn-xs">
                                      <span class="glyphicon glyphicon-pencil"></span>
                                    </a>
                                    <button data-id="<?=$ph2index; ?>"
585
                                      title="<?=gettext("delete phase 2 entry");?>" data-toggle="tooltip"
586 587
                                      type="submit"
                                      class="act_delete_p2 btn btn-default btn-xs">
588
                                      <span class="fa fa-trash text-muted"></span>
589 590
                                    </button>
                                    <a href="vpn_ipsec_phase2.php?dup=<?=$ph2ent['uniqid']; ?>"
591
                                        title="<?=gettext("clone phase 2 entry"); ?>" data-toggle="tooltip"
592 593 594 595 596 597 598 599 600
                                        alt="add" class="btn btn-default btn-xs">
                                      <span class="fa fa-clone text-muted"></span>
                                    </a>
                                </td>
                              </tr>
<?php
                              $j++;
                              endforeach;?>
                              <tr>
601 602
                                <td colspan="4" class="hidden-xs"></td>
                                <td colspan="4"></td>
603 604 605
                                <td>
<?php
                                if ($j > 0) :?>
606

607
                                  <button data-id="<?=$j+1; ?>" data-act="movep2" type="submit"
608
                                    title="<?=gettext("move selected phase 2 entries to end");?>" data-toggle="tooltip"
609 610 611
                                    class="act_move btn btn-default btn-xs">
                                    <span class="glyphicon glyphicon-arrow-down"></span>
                                  </button>
612
                                  <button data-id="x" type="submit" title="<?=gettext("delete selected phase 2 entries");?>" data-toggle="tooltip"
613
                                    class="act_delete_p2 btn btn-default btn-xs">
614
                                    <span class="fa fa-trash text-muted"></span>
615
                                  </button>
Ad Schellevis's avatar
Ad Schellevis committed
616
<?php
617 618
                                endif;?>
                                  <a href="vpn_ipsec_phase2.php?ikeid=<?=$ph1ent['ikeid']; ?><?= isset($ph1ent['mobile'])?"&amp;mobile=true":"";?>" class="btn btn-default btn-xs"
619
                                      title="<?=gettext("add phase 2 entry"); ?>" data-toggle="tooltip">
620 621 622 623 624 625 626 627 628 629 630 631 632
                                    <span alt="add" class="glyphicon glyphicon-plus"></span>
                                  </a>
                                </td>
                              </tr>
                            </tbody>
                          </table>
                        </div>
                      </td>
                    </tr>
<?php
                    $i++;
                    endforeach;?>
                    <tr>
633 634
                      <td colspan="4" class="hidden-xs"></td>
                      <td colspan="4"> </td>
635 636 637 638 639 640
                      <td>
                        <button
                        type="submit"
                        data-id="<?=$i;?>"
                        data-act="movep1"
                        title="<?=gettext("move selected phase 1 entries to end");?>"
641
                        data-toggle="tooltip"
642 643 644 645 646 647
                        class="act_move btn btn-default btn-xs">
                        <span class="glyphicon glyphicon-arrow-down"></span>
                      </button>
                        <button data-id=""
                        type="submit"
                        title="<?=gettext("delete selected phase 1 entries");?>"
648
                        data-toggle="tooltip"
649
                        class="act_delete_p1 btn btn-default btn-xs">
650
                        <span class="fa fa-trash text-muted"></span>
651
                      </button>
652
                        <a href="vpn_ipsec_phase1.php" title="<?=gettext("add new phase 1 entry");?>" data-toggle="tooltip"
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668
                            alt="add" class="btn btn-default btn-xs">
                        <span class="glyphicon glyphicon-plus"></span>
                      </a>
                      </td>
                    </tr>
                    <tr>
                      <td colspan=9>
                        <input name="enable" type="checkbox" id="enable" value="yes" <?=!empty($pconfig['enable']) ? "checked=\"checked\"":"";?>/>
                        <strong><?=gettext("Enable IPsec"); ?></strong>
                      </td>
                    </tr>
                    <tr>
                      <td colspan=9>
                        <input type="submit" name="save" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
                      </td>
                    </tr>
669 670
                </tbody>
              </table>
671
            </div>
672
          </div>
673 674
        </form>
      </section>
675
    </div>
676 677
  </div>
</section>
678
<?php include("foot.inc");