Last active 1 month ago

nuno revised this gist 1 month ago. Go to revision

1 file changed, 24 insertions

gistfile1.txt(file created)

@@ -0,0 +1,24 @@
1 + function cmd::list::_precompute_block_status() {
2 + local -n _blocked="$1"
3 + local -n _restricted="$2"
4 +
5 + local wg_peers
6 + wg_peers=$(wg show "$(config::interface)" peers 2>/dev/null)
7 +
8 + while IFS= read -r name; do
9 + if block::has_specific_rules "$name" 2>/dev/null; then
10 + _restricted["$name"]=true
11 + else
12 + _restricted["$name"]=false
13 + fi
14 +
15 + # Blocked = removed from WG server
16 + local pubkey
17 + pubkey=$(keys::public "$name" 2>/dev/null || echo "")
18 + if [[ -n "$pubkey" ]] && ! echo "$wg_peers" | grep -qF "$pubkey"; then
19 + _blocked["$name"]=true
20 + else
21 + _blocked["$name"]=false
22 + fi
23 + done < <(peers::all)
24 + }
Newer Older