Commit 5dcae9cf authored by Ad Schellevis's avatar Ad Schellevis

(legacy, ipsec) fix ipsec diag page, connect to vici, drop smp support, add...

(legacy, ipsec) fix ipsec diag page, connect to vici, drop smp support, add privilege separation using configd
parent 89e806e4
#!/usr/local/bin/python2.7
"""
Copyright (c) 2015 Ad Schellevis
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.
--------------------------------------------------------------------------------------
connect ipsec connection
"""
import sys
import os
import subprocess
import ujson
import vici
# parse input parameter
conn_id = None
if len(sys.argv) > 1:
p_conn_id = sys.argv[1].strip()
# validate if SA is active before trying to disconnect, validates input data
# and collect child sa's to bring up.
conns_found = []
s = vici.Session()
for conns in s.list_conns():
for conn in conns:
if conn == p_conn_id:
conns_found.append(conn)
for child in conns[conn]['children']:
if child not in conns_found:
conns_found.append(child)
# setup connection if found
for conn_id in conns_found:
devnull = open(os.devnull, 'w')
subprocess.call(['/usr/local/sbin/ipsec', 'up', conn_id], stdin=devnull, stdout=devnull, stderr=devnull)
#!/usr/local/bin/python2.7
"""
Copyright (c) 2015 Ad Schellevis
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.
--------------------------------------------------------------------------------------
disconnect ipsec connection
"""
import sys
import os
import subprocess
import ujson
import vici
# parse input parameter
conn_id = None
if len(sys.argv) > 1:
conn_id = sys.argv[1].strip()
# validate if SA is active before trying to disconnect, validates input data
conn_found = False
s = vici.Session()
for sas in s.list_sas():
for sa in sas:
if sa == conn_id:
conn_found = True
# terminate connection if found
if conn_found:
devnull = open(os.devnull, 'w')
subprocess.call(['/usr/local/sbin/ipsec', 'down', conn_id], stdin=devnull, stdout=devnull, stderr=devnull)
......@@ -39,11 +39,12 @@ for conns in s.list_conns():
for connection_id in conns:
result[connection_id] = dict()
result[connection_id]['version'] = conns[connection_id]['version']
result[connection_id]['local_addrs'] = ','.join(conns[connection_id]['local_addrs'])
result[connection_id]['local-addrs'] = ','.join(conns[connection_id]['local_addrs'])
result[connection_id]['local-id'] = ''
result[connection_id]['local-class'] = []
result[connection_id]['remote-id'] = ''
result[connection_id]['remote-class'] = []
result[connection_id]['remote-addrs'] = ','.join(conns[connection_id]['remote_addrs'])
result[connection_id]['children'] = conns[connection_id]['children']
result[connection_id]['sas'] = []
......
......@@ -3,3 +3,15 @@ command:/usr/local/opnsense/scripts/ipsec/list_status.py
parameters:
type:script_output
message:IPsec list status
[connect]
command:/usr/local/opnsense/scripts/ipsec/connect.py
parameters:%s
type=script
message:IPsec connect %s
[disconnect]
command:/usr/local/opnsense/scripts/ipsec/disconnect.py
parameters:%s
type=script
message:IPsec disconnect %s
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2004-2009 Scott Ullrich
Copyright (C) 2008 Shrew Soft Inc <mgrooms@shrew.net>.
Copyright (C) 2003-2004 Manuel Kasper
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.
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2004-2009 Scott Ullrich
Copyright (C) 2008 Shrew Soft Inc <mgrooms@shrew.net>.
Copyright (C) 2003-2004 Manuel Kasper
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.
*/
require_once("guiconfig.inc");
require_once("vpn.inc");
require_once("services.inc");
require_once("interfaces.inc");
function ipsec_fixup_network($network) {
if (substr($network, -3) == '|/0')
$result = substr($network, 0, -3);
else {
$tmp = explode('|', $network);
if (isset($tmp[1]))
$result = $tmp[1];
else
$result = $tmp[0];
unset($tmp);
}
return $result;
}
if (!isset($config['ipsec']) || !is_array($config['ipsec'])) {
$config['ipsec'] = array();
}
if (!isset($config['ipsec']['phase1'])) {
$config['ipsec']['phase1'] = array();
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// check if post can be valid
if (!empty($_POST['ikeid']) && ctype_digit(str_replace('-','',$_POST['ikeid'])) && !empty($_POST['action'])) {
// temporary solution to find related IKEv1 connections
// eventually we need to look at VICI (https://wiki.strongswan.org/projects/strongswan/wiki/VICI)
$ipsec_connlist = array();
exec("/usr/local/sbin/ipsec statusall", $ipsec_status_all);
foreach ($ipsec_status_all as $line ) {
if (strpos($line, "child:") !== false) {
$connId = trim(explode(":",$line)[0]);
if (strpos($line, "-") !== false) {
// IKEv1 items with more then one phase 2 entry
if (!isset($ipsec_connlist[explode("-",$connId)[0]])) {
$ipsec_connlist[trim(explode("-",$connId)[0])] = array();
}
$ipsec_connlist[trim(explode("-",$connId)[0])][] = $connId;
} else {
$ipsec_connlist[$connId] = array($connId);
}
}
}
$act = $_POST['action'];
$ikeid = 'con'.$_POST['ikeid'];
// check if a valid ikesaid is provided
if (!empty($_POST['ikesaid']) && ctype_digit($_POST['ikesaid'])) {
$ikesaid = $_POST['ikesaid'];
} else {
$ikesaid = null;
}
// todo: move to configctl calls
switch ($act) {
case 'connect':
if (isset($ipsec_connlist[$ikeid])) {
foreach ($ipsec_connlist[$ikeid] as $client) {
mwexec("/usr/local/sbin/ipsec down " . $client);
mwexec("/usr/local/sbin/ipsec up " . $client);
}
} else {
// ipsec statusall should have found this connection
mwexec("/usr/local/sbin/ipsec down " . $ikeid);
mwexec("/usr/local/sbin/ipsec up " . $ikeid);
}
break;
case 'ikedisconnect':
if ($ikesaid !== null) {
mwexec("/usr/local/sbin/ipsec down " . $ikeid . "[" . $ikesaid . "]");
} else {
mwexec("/usr/local/sbin/ipsec down " . $ikeid);
}
break;
case 'childdisconnect':
mwexec("/usr/local/sbin/ipsec down " . $ikeid . "{" . $ikesaid . "}");
break;
}
}
if (isset($_POST['action'])) {
$act = $_POST['action'];
} else {
$act = null;
}
switch ($act) {
case 'connect':
if (!empty($_POST['connid'])) {
configd_run("ipsec connect ".$_POST['connid']);
}
break;
case 'disconnect':
if (!empty($_POST['connid'])) {
configd_run("ipsec disconnect ".$_POST['connid']);
}
break;
default:
break;
}
header("Location: diag_ipsec.php");
exit(0);
}
$status = ipsec_smp_dump_status();
$pconfig = $config['ipsec']['phase1'];
legacy_html_escape_form_data($pconfig);
legacy_html_escape_form_data($status);
$ipsec_status = json_decode(configd_run("ipsec list_status"), true);
if ($ipsec_status == null) {
$ipsec_status = array();
}
$pgtitle = array(gettext('VPN'), gettext('IPsec'), gettext('Status Overview'));
$shortcut_section = 'ipsec';
include("head.inc");
?>
<script type="text/javascript">
//<![CDATA[
function show_childsa(id, buttonid) {
document.getElementById(buttonid).innerHTML='';
aodiv = document.getElementById(id);
aodiv.style.display = "";
}
//]]>
$( document ).ready(function() {
// show / hide connection details
$(".ipsec_info").click(function(event){
$("#" + $(this).data('target')).toggleClass('hidden visible');
event.preventDefault();
});
});
</script>
<body>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><?= gettext("Description");?></th>
<th><?= gettext("Local ID");?></th>
<th><?= gettext("Local IP");?></th>
<th><?= gettext("Remote ID");?></th>
<th><?= gettext("Remote IP");?></th>
<th><?= gettext("Role");?></th>
<th><?= gettext("Status");?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$ipsecconnected = array();
if (isset($status['query']['ikesalist']['ikesa'])):
foreach ($status['query']['ikesalist']['ikesa'] as $ikeid => $ikesa):
// first do formatting
$con_id = substr($ikesa['peerconfig'], 3);
$ipsecconnected[trim(explode("-",$con_id)[0])] = $con_id;
$ipsec_get_descr = '';
foreach ($pconfig as $p1) {
if ($p1['ikeid'] == $con_id) {
$ipsec_get_descr = $p1['descr'];
break;
}
}
$ipsec_local_identification = 'Unknown';
if (!empty($ikesa['local']['identification'])) {
if ($ikesa['local']['identification'] = "%any" ){
$ipsec_local_identification = 'Any identifier';
} else {
$ipsec_local_identification = $ikesa['local']['identification'];
}
}
$ipsec_local_address = 'Unknown';
if (!empty($ikesa['local']['address'])) {
$ipsec_local_address = $ikesa['local']['address'] . '<br/>Port:' . $ikesa['local']['port'];
}
if (isset($ikesa['local']['nat']) && $ikesa['local']['nat'] != 'false') {
$ipsec_local_address .= ' NAT-T';
}
$ipsec_remote_identification = 'Unknown';
if (!empty($ikesa['remote']['identification'])) {
if ($ikesa['remote']['identification'] == '%any') {
$ipsec_remote_identification = 'Any identifier';
} else {
$ipsec_remote_identification = $ikesa['remote']['identification'];
}
}
if (!empty($ikesa['remote']['auth'][0]['identity'])) {
$ipsec_remote_identification = $ikesa['remote']['auth'][0]['identity'] . '<br/>'. $ipsec_remote_identification;
}
$ipsec_remote_address = 'Unknown';
if (!empty($ikesa['remote']['address'])) {
$ipsec_remote_address = $ikesa['remote']['address'] . '<br/>Port:';
}
if (isset($ikesa['remote']['nat']) && $ikesa['remote']['nat'] != 'false') {
$ipsec_remote_address .= ' NAT-T';
}
$connected = false;
if (ipsec_phase1_status($status['query']['ikesalist']['ikesa'], $ikesa['id'])) {
$icon = "glyphicon glyphicon-play text-success";
$connected = true;
} elseif(!isset($config['ipsec']['enable'])) {
$icon = "glyphicon glyphicon-remove text-danger";
} else {
$icon = "glyphicon glyphicon-remove text-warning";
}
?>
<tr>
<td><?= $ipsec_get_descr;?></td>
<td><?= $ipsec_local_identification ?></td>
<td><?= $ipsec_local_address ?> </td>
<td><?= $ipsec_remote_identification ?> </td>
<td><?= $ipsec_remote_address ?> </td>
<td><?= $ikesa['role'];?></td>
<td>
<span class="<?= $icon; ?>" title="<?= $ikesa['status']; ?>" alt=""></span>
<small><?= $ikesa['status'];?></small>
</td>
<td>
<form method="post">
<input type="hidden" value="<?=$con_id?>" name="ikeid"/>
<input type="hidden" value="<?=isset($ikesa['id']) ? $ikesa['id'] :""?>" name="ikesaid" />
<?php if (!$connected): ?>
<button type="submit" class="btn btn-xs" name="action" value="connect" title="<?=gettext("Connect VPN");?>">
<span class="glyphicon glyphicon-play"/>
</button>
<?php else: ?>
<button type="submit" class="btn btn-xs" name="action" value="ikedisconnect" title="<?=gettext("Disconnect VPN");?>">
<span class="glyphicon glyphicon-stop"/>
</button>
<?php endif; ?>
</form>
</td>
</tr>
<?php if (isset($ikesa['childsalist']) && is_array($ikesa['childsalist']) ): ?>
<tr>
<td colspan="8">
<div id="btnchildsa-<?=$ikeid;?>">
<button class="btn btn-xs" type="button" onclick="show_childsa('childsa-<?=$ikeid;?>','btnchildsa-<?=$ikeid;?>');" >
<i class="fa fa-plus"></i> - <?=gettext("Show child SA entries");?>
</button>
</div>
<table class="table table-condensed" id="childsa-<?=$ikeid;?>" style="display:none">
<thead>
<tr>
<th> </th>
<th><?php echo gettext("Local subnets");?></th>
<th><?php echo gettext("Local SPI(s)");?></th>
<th><?php echo gettext("Remote subnets");?></th>
</tr>
</thead>
<tbody>
<?php
if (is_array($ikesa['childsalist']['childsa'])) {
foreach ($ikesa['childsalist']['childsa'] as $childsa) {
?>
<tr>
<td>
<form method="post">
<input type="hidden" value="<?=$con_id?>" name="ikeid"/>
<input type="hidden" value="<?=$childsa['reqid'];?>" name="ikesaid"/>
<button type="submit" class="btn btn-xs" name="action" value="childdisconnect">
<span class="glyphicon glyphicon-remove text-default"/>
</button>
</form>
</td>
<td>
<?php if (isset($childsa['local']['networks']['network'])):
foreach ($childsa['local']['networks']['network'] as $lnets):
?>
<?=htmlspecialchars(ipsec_fixup_network($lnets));?> <br/>
<?php endforeach;
else:
?>
Unknown <br/>
<?php endif;
?>
</td>
<td>
<?php if (isset($childsa['local']['spi'])):
?>
Local : <?=htmlspecialchars($childsa['local']['spi']);?>
<?php endif;
?>
<?php if (isset($childsa['remote']['spi'])):
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
<section class="col-xs-12">
<div class="tab-content content-box">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><?= gettext("Connection");?></th>
<th class="hidden-xs hidden-sm"><?= gettext("Version");?></th>
<th class="hidden-xs"><?= gettext("Local ID");?></th>
<th class="hidden-xs"><?= gettext("Local IP");?></th>
<th class="hidden-xs"><?= gettext("Remote ID");?></th>
<th><?= gettext("Remote IP");?></th>
<th class="hidden-xs hidden-sm"><?= gettext("Local Auth");?></th>
<th class="hidden-xs hidden-sm"><?= gettext("Remote Auth");?></th>
<th><?= gettext("Status");?></th>
</tr>
</thead>
<tbody>
<?php foreach ($ipsec_status as $ipsec_conn_key => $ipsec_conn): ?>
<tr>
<td><?= $ipsec_conn_key;?></td>
<td class="hidden-xs hidden-sm"><?= $ipsec_conn['version'] ?></td>
<td class="hidden-xs"><?= $ipsec_conn['local-id'] ?></td>
<td class="hidden-xs"><?= $ipsec_conn['local-addrs'] ?></td>
<td class="hidden-xs"><?= $ipsec_conn['remote-id'] ?></td>
<td><?= $ipsec_conn['remote-addrs'] ?></td>
<td class="hidden-xs hidden-sm"><?= $ipsec_conn['local-class'] ?></td>
<td class="hidden-xs hidden-sm"><?= $ipsec_conn['remote-class'] ?></td>
<td>
<?php if (count($ipsec_conn['sas'])):
?>
<br/>Remote : <?=htmlspecialchars($childsa['remote']['spi']);?>
<?php endif;
<form method="post">
<input type="hidden" value="<?=$ipsec_conn_key;?>" name="connid"/>
<button type="submit" class="btn btn-xs" name="action" value="disconnect">
<span class="glyphicon glyphicon-remove text-default"/>
</button>
<button type="submit" class="btn btn-xs" name="action" value="connect">
<span class="glyphicon glyphicon-play text-success" title="" alt=""></span>
</button>
<button type="none" class="btn btn-xs ipsec_info" data-target="info_<?=$ipsec_conn_key?>">
<span class="glyphicon glyphicon-info-sign"></i>
</button>
</form>
<?php else:
?>
</td>
<td>
<?php if (isset($childsa['remote']['networks']['network'])):
foreach ($childsa['remote']['networks']['network'] as $rnets):
<form method="post">
<input type="hidden" value="<?=$ipsec_conn_key;?>" name="connid"/>
<button type="submit" class="btn btn-xs" name="action" value="connect">
<span class="glyphicon glyphicon-play text-warning"/>
</button>
</form>
<?php endif;
?>
<?=htmlspecialchars(ipsec_fixup_network($rnets));?> <br/>
<?php endforeach;
else:
</td>
</tr>
<?php if (count($ipsec_conn['sas'])):
?>
Unknown <br/>
<?php endif;
<tr>
<td colspan="9" class="hidden" id="info_<?=$ipsec_conn_key?>">
<table class="table table-condensed">
<thead>
<tr>
<th><?= gettext("Local subnets");?></th>
<th class="hidden-xs hidden-sm"><?= gettext("SPI(s)");?></th>
<th><?= gettext("Remote subnets");?></th>
<th class="hidden-xs hidden-sm"><?= gettext("State");?></th>
<th><?= gettext("Stats");?></th>
</tr>
</head>
<tbody>
<?php foreach ($ipsec_conn['sas'] as $sa_key => $sa):?>
<?php foreach ($sa['child-sas'] as $child_sa_key => $child_sa):?>
<tr>
<td>
<?= implode('<br/>', $child_sa['local-ts'])?>
</td>
<td class="hidden-xs hidden-sm">
<?=gettext('in')?> : <?= $child_sa['spi-in'] ?><br/>
<?=gettext('out')?> : <?= $child_sa['spi-out'] ?>
</td>
<td>
<?= implode('<br/>', $child_sa['remote-ts'])?>
</td>
<td class="hidden-xs hidden-sm">
<?= $child_sa['state']?>
</td>
<td>
<small>
<?= gettext('Time');?> : <?= $child_sa['install-time']?><br/>
<?= gettext('Bytes in');?> : <?= $child_sa['bytes-in']?><br/>
<?= gettext('Bytes out');?> : <?= $child_sa['bytes-out']?>
</small>
</td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</table>
</td>
</tr>
<?php endif;
?>
</td>
</tr>
<?php } } ?>
<tr style="display:none;"><td></td></tr>
</tbody>
</table>
</td>
</tr>
<?php endif;
unset($con_id);
// close outer loop {foreach ($status['query']['ikesalist']['ikesa'] as $ikeid => $ikesa)}
endforeach;
endif;
$rgmap = array();
foreach ($pconfig as $ph1ent):
if (isset($ph1ent['remote-gateway'])) {
$rgmap[$ph1ent['remote-gateway']] = $ph1ent['remote-gateway'];
}
if (isset($ipsecconnected[$ph1ent['ikeid']])) {
continue;
}
$ph1src = ipsec_get_phase1_src($ph1ent);
$ph1dst = ipsec_get_phase1_dst($ph1ent);
list ($myid_type, $myid_data) = ipsec_find_id($ph1ent, "local");
list ($peerid_type, $peerid_data) = ipsec_find_id($ph1ent, "peer", $rgmap);
?>
<tr>
<td><?php echo htmlspecialchars($ph1ent['descr']);?></td>
<td><?=!empty($myid_data) ? htmlspecialchars($myid_data) : "Unknown"?></td>
<td><?=!empty($ph1src) ? htmlspecialchars($ph1src) : "Unknown"?></td>
<td><?=!empty($peerid_data) ? htmlspecialchars($peerid_data) : "Unknown"?></td>
<td><?=!empty($ph1dst) ? htmlspecialchars($ph1dst) : "Unknown"?></td>
<td></td>
<td>
<span class="glyphicon glyphicon-remove text-warning" title="Disconnected" alt=""></span>
<small>Disconnected</small>
</td>
<td >
<form method="post">
<input type="hidden" value="<?=$ph1ent['ikeid']?>" name="ikeid"/>
<button type="submit" class="btn btn-xs" name="action" value="connect">
<span class="glyphicon glyphicon-play"/>
</button>
</form>
</td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
</div>
</div>
</section>
</div>
</div>
</section>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</section>
</div>
</div>
</section>
<?php
include("foot.inc"); ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment