Last active
January 30, 2025 14:49
-
-
Save cyyself/90047489a6b51ec36cba3a4066b90782 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
wg_filter="wg0 wg1" # EDITME | |
current_time=$(date +%s) | |
wg show all dump | awk '{if ($5 != "off") print $1,$6}' | while read -r each_dump; do | |
interface=$(echo $each_dump | cut -d' ' -f1) | |
last_handshake=$(echo $each_dump | cut -d' ' -f2) | |
if echo $wg_filter | grep -q $interface; then | |
if [ $((current_time - last_handshake)) -gt 240 ]; then | |
wg set $interface listen-port 0 | |
fi | |
fi | |
done < <(wg show all dump | awk '{if ($5 != "off") print $1,$6}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment