mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
Add WireGuard widget (#1865)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
PLUGIN_NAME= wireguard
|
||||
PLUGIN_VERSION= 1.1
|
||||
PLUGIN_VERSION= 1.2
|
||||
PLUGIN_COMMENT= WireGuard VPN service
|
||||
PLUGIN_DEPENDS= wireguard
|
||||
PLUGIN_MAINTAINER= m.muenz@gmail.com
|
||||
|
||||
@@ -16,12 +16,16 @@ WWW: https://www.wireguard.com/
|
||||
Changelog
|
||||
---------
|
||||
|
||||
1.2
|
||||
|
||||
* Dashboard widget (contributed by D. Domig)
|
||||
|
||||
1.1
|
||||
|
||||
* Allow adding interface route for PBR
|
||||
|
||||
1.0
|
||||
|
||||
* Support for most features like S2S, Roadwarror
|
||||
* Support for most features like S2S, Roadwarrior
|
||||
* DNS, MTU, PSK
|
||||
* Allow to disable setting routes for PBR
|
||||
|
||||
@@ -39,3 +39,9 @@ command:/usr/local/bin/wg show all latest-handshakes
|
||||
parameters:
|
||||
type:script_output
|
||||
message:show Wireguard handshakes
|
||||
|
||||
[widget]
|
||||
command:/usr/local/bin/wg show all latest-handshakes
|
||||
parameters:
|
||||
type:script_output
|
||||
message:show Wireguard handshakes for widget
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
$wireguard_title = gettext("WireGuard");
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 Deciso B.V.
|
||||
* Copyright (C) 2020 D. Domig
|
||||
* 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("widgets/include/wireguard.inc");
|
||||
|
||||
$data = trim(configd_run("wireguard widget"));
|
||||
|
||||
$empty = strlen($data) == 0;
|
||||
?>
|
||||
|
||||
<table class="table table-striped table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= gettext("Interface") ?></th>
|
||||
<th><?= gettext("Endpoint") ?></th>
|
||||
<th><?= gettext("Latest Handshake") ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php if (!$empty):
|
||||
$handshakes = explode("\n", $data);
|
||||
|
||||
foreach ($handshakes as $handshake):
|
||||
$item = explode("\t", $handshake);
|
||||
|
||||
$epoch = $item[2];
|
||||
$latest = "-";
|
||||
if ($epoch > 0):
|
||||
$dt = new DateTime("@$epoch");
|
||||
$latest = $dt->format(gettext("Y-m-d H:i:sP"));
|
||||
endif; ?>
|
||||
|
||||
<tr>
|
||||
<td><?= $item[0] ?></td>
|
||||
<td><?= gettext(substr($item[1], 0, 10)) ?>...</td>
|
||||
<td><?= $latest ?></td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<tr>
|
||||
<td colspan="3"><?= gettext("No WireGuard instance defined or enabled.") ?></td>
|
||||
</tr>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
Reference in New Issue
Block a user