mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
openvpn: a couple of hours spend on tidying up the status page
This commit is contained in:
parent
135305347d
commit
3786a300cf
@ -1324,9 +1324,9 @@ function openvpn_get_server_status($server, $socket)
|
||||
fclose($fp);
|
||||
} else {
|
||||
$conn = array();
|
||||
$conn['common_name'] = "[error]";
|
||||
$conn['remote_host'] = "Unable to contact daemon";
|
||||
$conn['virtual_addr'] = "Service not running?";
|
||||
$conn['common_name'] = '[error]'; // kind of a marker value now
|
||||
$conn['remote_host'] = gettext('Unable to contact daemon');
|
||||
$conn['virtual_addr'] = gettext('Service not running?');
|
||||
$conn['bytes_recv'] = 0;
|
||||
$conn['bytes_sent'] = 0;
|
||||
$conn['connect_time'] = 0;
|
||||
@ -1438,8 +1438,8 @@ function openvpn_get_client_status($client, $socket)
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
$client['remote_host'] = "Unable to contact daemon";
|
||||
$client['virtual_addr'] = "Service not running?";
|
||||
$client['remote_host'] = gettext('Unable to contact daemon');
|
||||
$client['virtual_addr'] = gettext('Service not running?');
|
||||
$client['bytes_recv'] = 0;
|
||||
$client['bytes_sent'] = 0;
|
||||
$client['connect_time'] = 0;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2019 Franco Fichtner <franco@opnsense.org>
|
||||
* Copyright (C) 2014-2015 Deciso B.V.
|
||||
* Copyright (C) 2010 Jim Pingle <jimp@pfsense.org>
|
||||
* Copyright (C) 2008 Shrew Soft Inc. <mgrooms@shrew.net>
|
||||
@ -111,7 +112,7 @@ include("head.inc"); ?>
|
||||
});
|
||||
// link show/hide routes
|
||||
$(".act_show_routes").click(function () {
|
||||
$("*[data-for='" + $(this).attr('id') + "']").toggleClass("hidden show");
|
||||
$("*[data-for='" + $(this).attr('id') + "']").toggle();
|
||||
});
|
||||
|
||||
// minimize all buttons, some of the buttons come from the shared service
|
||||
@ -124,197 +125,198 @@ include("head.inc"); ?>
|
||||
//]]>
|
||||
</script>
|
||||
<section class="page-content-main">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<section class="col-xs-12">
|
||||
<div class="content-box-main col-xs-12">
|
||||
<form method="get" name="iform">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th colspan="8"><?= gettext('OpenVPN Status') ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($servers as $server): ?>
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
<b><?= $server['name'] ?> <?= gettext('Client connections') ?></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= gettext("Common Name"); ?></td>
|
||||
<td><?= gettext("Real Address"); ?></td>
|
||||
<td><?= gettext("Virtual Address"); ?></td>
|
||||
<td><?= gettext("Connected Since"); ?></td>
|
||||
<td><?= gettext("Bytes Sent"); ?></td>
|
||||
<td><?= gettext("Bytes Received"); ?></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($server['conns'] as $conn): ?>
|
||||
<tr id="<?= html_safe("r:{$server['mgmt']}:{$conn['remote_host']}") ?>">
|
||||
<td><?= $conn['common_name']; ?></td>
|
||||
<td><?= $conn['remote_host']; ?></td>
|
||||
<td><?= $conn['virtual_addr']; ?></td>
|
||||
<td><?= $conn['connect_time']; ?></td>
|
||||
<td><?= format_bytes($conn['bytes_sent']); ?></td>
|
||||
<td><?= format_bytes($conn['bytes_recv']); ?></td>
|
||||
<td></td>
|
||||
<td>
|
||||
<button data-client-port="<?= $server['mgmt']; ?>"
|
||||
data-client-ip="<?= $conn['remote_host']; ?>"
|
||||
title="<?= gettext("Kill client connection from") . " " . $conn['remote_host']; ?>"
|
||||
class="act_kill_client btn btn-default">
|
||||
<i class="fa fa-times fa-fw"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<?php $ssvc = service_by_name('openvpn', array('id' => $server['vpnid'])); ?>
|
||||
<?= service_control_icon($ssvc, true); ?>
|
||||
<?= service_control_links($ssvc, true); ?>
|
||||
</td>
|
||||
<td colspan="6"> </td>
|
||||
</tr>
|
||||
<?php
|
||||
if (isset($server['routes']) && count($server['routes'])): ?>
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
<button class="btn btn-default act_show_routes" type="button"
|
||||
id="showroutes_<?= $i ?>"><i class="fa fa-info"></i>
|
||||
<?= gettext("Show/Hide Routing Table"); ?>
|
||||
</button>
|
||||
<div class="hidden" data-for="showroutes_<?= $i ?>">
|
||||
<small>
|
||||
<?= $server['name']; ?> <?= gettext("Routing Table"); ?>
|
||||
</small>
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= gettext("Common Name"); ?></th>
|
||||
<th><?= gettext("Real Address"); ?></th>
|
||||
<th><?= gettext("Target Network"); ?></th>
|
||||
<th><?= gettext("Last Used"); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($server['routes'] as $conn): ?>
|
||||
<tr id="<?= html_safe("r:{$server['mgmt']}:{$conn['remote_host']}") ?>">
|
||||
<td><?= $conn['common_name']; ?></td>
|
||||
<td><?= $conn['remote_host']; ?></td>
|
||||
<td><?= $conn['virtual_addr']; ?></td>
|
||||
<td><?= $conn['last_time']; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="6"><?= gettext("An IP address followed by C indicates a host currently connected through the VPN.") ?></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endif;
|
||||
$i++;
|
||||
endforeach;
|
||||
if (!empty($sk_servers)): ?>
|
||||
<tr>
|
||||
<td colspan="8"><b><?= gettext('Peer to Peer Server Instance Statistics') ?></b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= gettext("Name"); ?></td>
|
||||
<td><?= gettext("Remote Host"); ?></td>
|
||||
<td><?= gettext("Virtual Addr"); ?></td>
|
||||
<td><?= gettext("Connected Since"); ?></td>
|
||||
<td><?= gettext("Bytes Sent"); ?></td>
|
||||
<td><?= gettext("Bytes Received"); ?></td>
|
||||
<td><?= gettext("Status"); ?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($sk_servers as $sk_server): ?>
|
||||
<tr id="<?= html_safe("r:{$sk_server['port']}:{$sk_server['vpnid']}") ?>">
|
||||
<td><?= $sk_server['name']; ?></td>
|
||||
<td><?= $sk_server['remote_host']; ?></td>
|
||||
<td><?= $sk_server['virtual_addr']; ?></td>
|
||||
<td><?= $sk_server['connect_time']; ?></td>
|
||||
<td><?= format_bytes($sk_server['bytes_sent']); ?></td>
|
||||
<td><?= format_bytes($sk_server['bytes_recv']); ?></td>
|
||||
<td><?= $sk_server['status']; ?></td>
|
||||
<td>
|
||||
<div>
|
||||
<?php $ssvc = service_by_name('openvpn', array('id' => $sk_server['vpnid'])); ?>
|
||||
<?= service_control_icon($ssvc, true); ?>
|
||||
<?= service_control_links($ssvc, true); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
endif; ?>
|
||||
|
||||
<?php
|
||||
if (!empty($clients)):?>
|
||||
<tr>
|
||||
<tr>
|
||||
<td colspan="8"><b><?= gettext('Client Instance Statistics') ?><b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= gettext("Name"); ?></td>
|
||||
<td><?= gettext("Remote Host"); ?></td>
|
||||
<td><?= gettext("Virtual Addr"); ?></td>
|
||||
<td><?= gettext("Connected Since"); ?></td>
|
||||
<td><?= gettext("Bytes Sent"); ?></td>
|
||||
<td><?= gettext("Bytes Received"); ?></td>
|
||||
<td><?= gettext("Status"); ?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($clients as $client): ?>
|
||||
<tr id="<?= html_safe("r:{$client['port']}:{$client['vpnid']}") ?>">
|
||||
<td><?= $client['name']; ?></td>
|
||||
<td><?= $client['remote_host']; ?></td>
|
||||
<td><?= $client['virtual_addr']; ?></td>
|
||||
<td><?= $client['connect_time']; ?></td>
|
||||
<td><?= format_bytes($client['bytes_sent']); ?></td>
|
||||
<td><?= format_bytes($client['bytes_recv']); ?></td>
|
||||
<td><?= $client['status']; ?></td>
|
||||
<td>
|
||||
<div>
|
||||
<?php $ssvc = service_by_name('openvpn', array('id' => $client['vpnid'])); ?>
|
||||
<?= service_control_icon($ssvc, true); ?>
|
||||
<?= service_control_links($ssvc, true); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
<?php
|
||||
endif;
|
||||
if ((empty($clients)) && (empty($servers)) && (empty($sk_servers))): ?>
|
||||
<tr>
|
||||
<td colspan="8"><?= gettext('No OpenVPN instance defined') ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
endif ?>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<section class="col-xs-12">
|
||||
<!-- XXX unused? <form method="get" name="iform">-->
|
||||
<?php foreach ($servers as $i => $server): ?>
|
||||
<div class="tab-content content-box __mb">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="7">
|
||||
<strong><?= $server['name'] ?> <?= gettext('Client connections') ?></strong>
|
||||
<div class="pull-right">
|
||||
<?php $ssvc = service_by_name('openvpn', array('id' => $server['vpnid'])); ?>
|
||||
<?= service_control_icon($ssvc, true); ?>
|
||||
<?= service_control_links($ssvc, true); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?= gettext('Common Name') ?></strong></td>
|
||||
<td><strong><?= gettext('Real Address') ?></strong></td>
|
||||
<td><strong><?= gettext('Virtual Address') ?></strong></td>
|
||||
<td><strong><?= gettext('Connected Since') ?></strong></td>
|
||||
<td><strong><?= gettext('Bytes Sent') ?></strong></td>
|
||||
<td><strong><?= gettext('Bytes Received') ?></strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php if (empty($server['conns'])): ?>
|
||||
<tr>
|
||||
<td colspan="7"><?= gettext('No OpenVPN clients are connected to this instance.') ?></td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($server['conns'] as $conn): ?>
|
||||
<tr id="<?= html_safe("r:{$server['mgmt']}:{$conn['remote_host']}") ?>">
|
||||
<td><?= $conn['common_name'] ?></td>
|
||||
<td><?= $conn['remote_host'] ?></td>
|
||||
<td><?= $conn['virtual_addr'] ?></td>
|
||||
<td><?= $conn['connect_time'] ?></td>
|
||||
<td><?= format_bytes($conn['bytes_sent']) ?></td>
|
||||
<td><?= format_bytes($conn['bytes_recv']) ?></td>
|
||||
<td>
|
||||
<?php if (count($server['conns']) != 1 || $conn['common_name'] != '[error]'): ?>
|
||||
<button data-client-port="<?= $server['mgmt']; ?>"
|
||||
data-client-ip="<?= $conn['remote_host']; ?>"
|
||||
title="<?= gettext("Kill client connection from") . " " . $conn['remote_host']; ?>"
|
||||
class="act_kill_client btn btn-default">
|
||||
<i class="fa fa-times fa-fw"></i>
|
||||
</button>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
<?php endif ?>
|
||||
<?php if (!empty($server['routes'])): ?>
|
||||
<tr>
|
||||
<td colspan="7">
|
||||
<span style="cursor:pointer;" class="act_show_routes" id="showroutes_<?= $i ?>">
|
||||
<i class="fa fa-chevron-down fa-fw"></i>
|
||||
<strong><?= $server['name'] ?> <?= gettext('Routing Table') ?></strong>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="display:none;" data-for="showroutes_<?= $i ?>">
|
||||
<td><strong><?= gettext('Common Name') ?></strong></td>
|
||||
<td><strong><?= gettext('Real Address') ?></strong></td>
|
||||
<td><strong><?= gettext('Target Network') ?></strong></td>
|
||||
<td><strong><?= gettext('Last Used') ?></strong></td>
|
||||
<td colspan="3">
|
||||
</tr>
|
||||
<?php foreach ($server['routes'] as $conn): ?>
|
||||
<tr style="display:none;" data-for="showroutes_<?= $i ?>" id="<?= html_safe("r:{$server['mgmt']}:{$conn['remote_host']}") ?>">
|
||||
<td><?= $conn['common_name'] ?></td>
|
||||
<td><?= $conn['remote_host'] ?></td>
|
||||
<td><?= $conn['virtual_addr'] ?></td>
|
||||
<td><?= $conn['last_time'] ?></td>
|
||||
<td colspan="3">
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
<tr style="display:none;" data-for="showroutes_<?= $i ?>">
|
||||
<td colspan="7"><?= gettext("An IP address followed by C indicates a host currently connected through the VPN.") ?></td>
|
||||
</tr>
|
||||
</tr>
|
||||
<?php endif ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<? endforeach ?>
|
||||
<? if (!empty($sk_servers)): ?>
|
||||
<div class="tab-content content-box __mb">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="8"><strong><?= gettext('Peer to Peer Server Instance Statistics') ?></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?= gettext('Name') ?></strong></td>
|
||||
<td><strong><?= gettext('Remote Host') ?></strong></td>
|
||||
<td><strong><?= gettext('Virtual Addr') ?></strong></td>
|
||||
<td><strong><?= gettext('Connected Since') ?></strong></td>
|
||||
<td><strong><?= gettext('Bytes Sent') ?></strong></td>
|
||||
<td><strong><?= gettext('Bytes Received') ?></strong></td>
|
||||
<td><strong><?= gettext('Status') ?></strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php foreach ($sk_servers as $sk_server): ?>
|
||||
<tr id="<?= html_safe("r:{$sk_server['port']}:{$sk_server['vpnid']}") ?>">
|
||||
<td><?= $sk_server['name'] ?></td>
|
||||
<td><?= $sk_server['remote_host'] ?></td>
|
||||
<td><?= $sk_server['virtual_addr'] ?></td>
|
||||
<td><?= $sk_server['connect_time'] ?></td>
|
||||
<td><?= format_bytes($sk_server['bytes_sent']) ?></td>
|
||||
<td><?= format_bytes($sk_server['bytes_recv']) ?></td>
|
||||
<td><?= $sk_server['status'] ?></td>
|
||||
<td>
|
||||
<div>
|
||||
<?php $ssvc = service_by_name('openvpn', array('id' => $sk_server['vpnid'])); ?>
|
||||
<?= service_control_icon($ssvc, true); ?>
|
||||
<?= service_control_links($ssvc, true); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<? endif ?>
|
||||
<?php if (!empty($clients)): ?>
|
||||
<div class="tab-content content-box __mb">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="8"><strong><?= gettext('Client Instance Statistics') ?><strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?= gettext('Name') ?></strong></td>
|
||||
<td><strong><?= gettext('Remote Host') ?></strong></td>
|
||||
<td><strong><?= gettext('Virtual Addr') ?></strong></td>
|
||||
<td><strong><?= gettext('Connected Since') ?></strong></td>
|
||||
<td><strong><?= gettext('Bytes Sent') ?></strong></td>
|
||||
<td><strong><?= gettext('Bytes Received') ?></strong></td>
|
||||
<td><strong><?= gettext('Status') ?></strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php foreach ($clients as $client): ?>
|
||||
<tr id="<?= html_safe("r:{$client['port']}:{$client['vpnid']}") ?>">
|
||||
<td><?= $client['name'] ?></td>
|
||||
<td><?= $client['remote_host'] ?></td>
|
||||
<td><?= $client['virtual_addr'] ?></td>
|
||||
<td><?= $client['connect_time'] ?></td>
|
||||
<td><?= format_bytes($client['bytes_sent']) ?></td>
|
||||
<td><?= format_bytes($client['bytes_recv']) ?></td>
|
||||
<td><?= $client['status'] ?></td>
|
||||
<td>
|
||||
<div>
|
||||
<?php $ssvc = service_by_name('openvpn', array('id' => $client['vpnid'])); ?>
|
||||
<?= service_control_icon($ssvc, true); ?>
|
||||
<?= service_control_links($ssvc, true); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?php if (empty($clients) && empty($servers) && empty($sk_servers)): ?>
|
||||
<div class="tab-content content-box __mb">
|
||||
<div class="table-responsive">
|
||||
<table class="table-responsive table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="8"><strong><?= gettext('OpenVPN Status') ?></strong></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="8"><?= gettext('No OpenVPN instance defined') ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<!--</form>-->
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php
|
||||
|
||||
|
||||
<?php include("foot.inc"); ?>
|
||||
include 'foot.inc';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user