aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/utils/wireguard-tools/files/wireguard_watchdog
diff options
context:
space:
mode:
Diffstat (limited to 'package/network/utils/wireguard-tools/files/wireguard_watchdog')
-rw-r--r--package/network/utils/wireguard-tools/files/wireguard_watchdog10
1 files changed, 9 insertions, 1 deletions
diff --git a/package/network/utils/wireguard-tools/files/wireguard_watchdog b/package/network/utils/wireguard-tools/files/wireguard_watchdog
index c0a5a0aa33c..fc90f4a25b3 100644
--- a/package/network/utils/wireguard-tools/files/wireguard_watchdog
+++ b/package/network/utils/wireguard-tools/files/wireguard_watchdog
@@ -17,6 +17,7 @@
check_peer_activity() {
local cfg=$1
local iface=$2
+ local disabled
local public_key
local endpoint_host
local endpoint_port
@@ -24,9 +25,16 @@ check_peer_activity() {
local last_handshake
local idle_seconds
+ config_get_bool disabled "${cfg}" "disabled" 0
config_get public_key "${cfg}" "public_key"
config_get endpoint_host "${cfg}" "endpoint_host"
config_get endpoint_port "${cfg}" "endpoint_port"
+
+ if [ "${disabled}" -eq 1 ]; then
+ # skip disabled peers
+ return 0
+ fi
+
persistent_keepalive=$(wg show ${iface} persistent-keepalive | grep ${public_key} | awk '{print $2}')
# only process peers with endpoints and keepalive set
@@ -51,7 +59,7 @@ check_peer_activity() {
}
# query ubus for all active wireguard interfaces
-wg_ifaces=$(ubus -S call network.interface dump | jsonfilter -e '@.interface[@.up=true]' | jsonfilter -a -e '@[@.proto="wireguard"].interface' | tr "\n" " ")
+eval $(ubus -S call network.interface dump | jsonfilter -e 'wg_ifaces=@.interface[@.up=true && @.proto="wireguard"].interface')
# check every peer in every active wireguard interface
config_load network