From 939bd0171e231d49914de9461aceef11c947a253 Mon Sep 17 00:00:00 2001 From: ljm42 Date: Thu, 5 Nov 2020 16:00:51 -0800 Subject: [PATCH] Remove WG from Dashboard if no tunnels defined This prevents the page from polling for 'update.wireguard.php' when the WireGuard plugin is installed but there are no tunnels defined --- plugins/dynamix/DashStats.page | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/dynamix/DashStats.page b/plugins/dynamix/DashStats.page index 7e58a0ef3..f50260740 100644 --- a/plugins/dynamix/DashStats.page +++ b/plugins/dynamix/DashStats.page @@ -47,7 +47,8 @@ function vpn_peers($file) { $dockerd = pgrep('dockerd'); $libvirtd = pgrep('libvirtd'); $apcupsd = file_exists('/var/run/apcupsd.pid'); -$wireguard = is_executable('/usr/bin/wg') && file_exists('/var/log/plugins/dynamix.wireguard.plg'); +$conf = glob('/etc/wireguard/wg*.conf'); +$wireguard = is_executable('/usr/bin/wg') && file_exists('/var/log/plugins/dynamix.wireguard.plg') && count($conf); $started = $var['fsState']=='Started'; $sleep = isset($display['sleep']); $array_size = $array_used = 0; @@ -85,7 +86,6 @@ foreach ($devs as $disk) { } $array_percent = number_format(100*$array_used/($array_size ?: 1),1,$dot,''); exec('cat /sys/devices/system/cpu/*/topology/thread_siblings_list|sort -nu', $cpus); -$conf = $wireguard ? glob('/etc/wireguard/wg*.conf') : []; $wg_up = $wireguard ? exec("wg show interfaces") : ''; $wg_up = $wg_up ? explode(' ',$wg_up) : []; $up = count($wg_up); @@ -317,7 +317,7 @@ foreach ($ports as $port) { } ?> - +
_(VPN)_
_(Active tunnels)_: _(Inactive tunnels)_: