vpn_ipsec.php 30.7 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 33
require_once("filter.inc");
require_once("vpn.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 81 82 83 84 85 86 87 88
    $a_phase1 = &$config['ipsec']['phase1'];
    $a_phase2 = &$config['ipsec']['phase2'];
    if (isset($_POST['apply'])) {
        $retval = vpn_ipsec_configure();
        /* reload the filter in the background */
        filter_configure();
        $savemsg = get_std_save_message();
        if ($retval >= 0) {
            if (is_subsystem_dirty('ipsec')) {
                clear_subsystem_dirty('ipsec');
            }
89
        }
90
    } elseif (isset($_POST['save'])) {
91 92 93 94 95
        $config['ipsec']['enable'] = !empty($_POST['enable']) ? true : false;
        write_config();
        vpn_ipsec_configure();
        header("Location: vpn_ipsec.php");
        exit;
96 97 98 99 100 101
    } 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'];
102 103
        }

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

119 120 121 122 123 124 125 126 127 128 129
        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]);
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 163 164 165 166
        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');
        }
167 168
        header("Location: vpn_ipsec.php");
        exit;
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
    } 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;
193
    }
Ad Schellevis's avatar
Ad Schellevis committed
194 195
}

196 197 198 199 200
// form data
$pconfig = $config['ipsec'];
$pconfig['enable'] = isset($config['ipsec']['enable']);
legacy_html_escape_form_data($pconfig);

201
$service_hook = 'ipsec';
Ad Schellevis's avatar
Ad Schellevis committed
202 203 204 205

include("head.inc");
?>

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

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
    // 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();
    });
});
314 315
</script>

316 317 318 319 320 321 322 323 324
<?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
325
          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."));
326 327 328 329 330
      }?>
      <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="" />
331 332 333
           <div class="tab-content content-box col-xs-12">
              <div class="table-responsive">
                <table class="table table-striped">
334
                  <thead>
335 336 337
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
338
                    <td class="hidden-xs"><?=gettext("Type"); ?></td>
339
                    <td><?=gettext("Remote Gateway"); ?></td>
340 341 342
                    <td class="hidden-xs"><?=gettext("Mode"); ?></td>
                    <td class="hidden-xs"><?=gettext("Phase 1 Proposal"); ?></td>
                    <td class="hidden-xs"><?=gettext("Authentication"); ?></td>
343
                    <td><?=gettext("Description"); ?></td>
344 345 346
                    <td>
                    </td>
                  </tr>
347 348
                  </thead>
                  <tbody>
Ad Schellevis's avatar
Ad Schellevis committed
349
<?php
350 351 352 353 354 355 356
                  $i = 0;
                  foreach ($pconfig['phase1'] as $ph1ent) :?>
                    <tr>
                      <td>
                        <input type="checkbox" name="p1entry[]" value="<?=$i;?>"/>
                      </td>
                      <td>
357 358
                        <button data-id="<?=$i; ?>" data-act="togglep1" type="submit"
                            type="submit" class="act_move btn btn-<?= isset($ph1ent['disabled'])? "default":"success"?> btn-xs"
359 360 361 362
                            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>
363
                      <td class="hidden-xs">
364 365
                          <?=empty($ph1ent['protocol']) || $ph1ent['protocol'] == "inet" ? "IPv4" : "IPv6"; ?>
                          <?=empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1" ? "IKE" : "IKEv2"; ?>
366 367
                      </td>
                      <td>
Ad Schellevis's avatar
Ad Schellevis committed
368
<?php
369 370
                        if (!empty($ph1ent['interface'])) {
                            $iflabels = get_configured_interface_with_descr();
371

372 373 374 375
                            $carplist = get_configured_carp_interface_list();
                            foreach ($carplist as $cif => $carpip) {
                                $iflabels[$cif] = $carpip." (".get_vip_descr($carpip).")";
                            }
376

377 378 379 380
                            $aliaslist = get_configured_ip_aliases_list();
                            foreach ($aliaslist as $aliasip => $aliasif) {
                                $iflabels[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
                            }
381

382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
                            $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>
402
                      <td class="hidden-xs">
403 404
                        <?=htmlspecialchars($ph1ent['mode']);?>
                      </td>
405
                      <td class="hidden-xs">
406
                        <?=$p1_ealgos[$ph1ent['encryption-algorithm']['name']]['name'];?>
Ad Schellevis's avatar
Ad Schellevis committed
407
<?php
408 409 410 411
                        if (!empty($ph1ent['encryption-algorithm']['keylen'])) {
                            if ($ph1ent['encryption-algorithm']['keylen']=="auto") {
                                echo " (" . gettext("auto") . ")";
                            } else {
412
                                echo " ({$ph1ent['encryption-algorithm']['keylen']}&nbsp;" . gettext("bits") . ")";
413
                            }
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
                        }?> +

                        <?=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']];?>
434
                      </td>
435
                      <td class="hidden-xs">
436 437 438 439 440 441 442 443 444 445
<?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'];?>
446 447 448 449 450 451
                      </td>
                      <td>
                          <?=$ph1ent['descr'];?>&nbsp;
                      </td>
                      <td>
                        <button data-id="<?=$i; ?>" data-act="movep1" type="submit" class="act_move btn btn-default btn-xs"
452
                            title="<?=gettext("move selected entries before this");?>" data-toggle="tooltip">
453 454 455
                          <span class="glyphicon glyphicon-arrow-left"></span>
                        </button>
                        <a href="vpn_ipsec_phase1.php?p1index=<?=$i; ?>" class="btn btn-default btn-xs" alt="edit"
456
                            title="<?=gettext("edit phase1 entry"); ?>" data-toggle="tooltip">
457 458 459
                          <span class="glyphicon glyphicon-pencil"></span>
                        </a><br/>
                        <button data-id="<?=$i; ?>"
460
                            title="<?=gettext("delete phase1 entry");?>" data-toggle="tooltip"
461 462
                            type="submit"
                            class="act_delete_p1 btn btn-default btn-xs">
463
                            <span class="fa fa-trash text-muted"></span>
464 465
                        </button>
<?php                   if (!isset($ph1ent['mobile'])) :
466
?>
467
                        <a href="vpn_ipsec_phase1.php?dup=<?=$i; ?>" class="btn btn-default btn-xs" alt="add"
468
                            title="<?=gettext("clone phase1 entry"); ?>" data-toggle="tooltip">
469 470
                                        <span class="fa fa-clone text-muted"></span>
                        </a>
Ad Schellevis's avatar
Ad Schellevis committed
471
<?php
472 473 474 475 476
                        endif;?>
                      </td>
                    </tr>
                    <tr>
                      <td colspan="9">
Ad Schellevis's avatar
Ad Schellevis committed
477
<?php
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495
                        $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>
496
                                <td class="hidden-xs"><?=gettext("Type"); ?></td>
497 498
                                <td><?=gettext("Local Subnet"); ?></td>
                                <td><?=gettext("Remote Subnet"); ?></td>
499 500 501 502
                                <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>
503 504 505
                              </tr>
                            </thead>
                            <tbody>
Ad Schellevis's avatar
Ad Schellevis committed
506
<?php
507 508 509 510 511 512 513 514 515 516
                            $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>
517
                                  <button data-id="<?=$ph2index; ?>" data-act="togglep2" type="submit"
518
                                      title="<?=(isset($ph2ent['disabled'])) ? gettext("enable phase 2 entry") : gettext("disable phase 2 entry"); ?>" data-toggle="tooltip"
519
                                      class="act_move btn btn-<?= isset($ph2ent['disabled'])?"default":"success";?> btn-xs">
520 521 522
                                    <span class="glyphicon glyphicon-play"></span>
                                  </button>
                                </td>
523
                                <td class="hidden-xs">
524 525 526
                                  <?=$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
527
<?php
528 529 530 531 532 533 534
                                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
535
<?php
536 537 538
                                else :?>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
Ad Schellevis's avatar
Ad Schellevis committed
539
<?php
540
                                endif;?>
541
                                <td class="hidden-xs">
Ad Schellevis's avatar
Ad Schellevis committed
542
<?php
543 544 545 546 547 548 549 550 551 552 553 554 555 556
                                  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>
557
                                <td class="hidden-xs">
558 559 560 561 562 563 564 565 566 567
<?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>
568 569
<?php
                                if (isset($ph2ent['pfsgroup'])): ?>
570
                                <td class="hidden-xs"><?=gettext("Group"); ?> <?=$p2_pfskeygroups[$ph2ent['pfsgroup']];?> </td>
571 572
<?php
                                else: ?>
573
                                <td class="hidden-xs"><?=gettext("off"); ?></td>
574 575
<?php
                                endif; ?>
576 577
                                <td>
                                    <button data-id="<?=$j; ?>" data-act="movep2"
578
                                        title="<?=gettext("move selected entries before this");?>" data-toggle="tooltip"
579 580 581 582 583
                                        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']; ?>"
584
                                        title="<?=gettext("edit phase 2 entry"); ?>" data-toggle="tooltip"
585 586 587 588
                                        alt="edit" class="btn btn-default btn-xs">
                                      <span class="glyphicon glyphicon-pencil"></span>
                                    </a>
                                    <button data-id="<?=$ph2index; ?>"
589
                                      title="<?=gettext("delete phase 2 entry");?>" data-toggle="tooltip"
590 591
                                      type="submit"
                                      class="act_delete_p2 btn btn-default btn-xs">
592
                                      <span class="fa fa-trash text-muted"></span>
593 594
                                    </button>
                                    <a href="vpn_ipsec_phase2.php?dup=<?=$ph2ent['uniqid']; ?>"
595
                                        title="<?=gettext("clone phase 2 entry"); ?>" data-toggle="tooltip"
596 597 598 599 600 601 602 603 604
                                        alt="add" class="btn btn-default btn-xs">
                                      <span class="fa fa-clone text-muted"></span>
                                    </a>
                                </td>
                              </tr>
<?php
                              $j++;
                              endforeach;?>
                              <tr>
605 606
                                <td colspan="4" class="hidden-xs"></td>
                                <td colspan="4"></td>
607 608 609
                                <td>
<?php
                                if ($j > 0) :?>
610

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