最終更新 2 months ago

nuno revised this gist 2 months ago. Go to revision

1 file changed, 22 insertions

gistfile1.txt(file created)

@@ -0,0 +1,22 @@
1 + "function firewall::restore_blocks" /etc/wireguard/wgctl/modules/firewall.module.sh
2 + function firewall::restore_blocks() {
3 + local blocks_dir
4 + blocks_dir="$(ctx::blocks)"
5 +
6 + # Restore guest rules if marker exists
7 + local marker="${blocks_dir}/_guest_rules.active"
8 + if [[ -f "$marker" ]]; then
9 + firewall::apply_guest_rules
10 + log::wg "Restored guest firewall rules"
11 + fi
12 +
13 + # Restore per-client block rules
14 + for block_file in "${blocks_dir}"/*.block; do
15 + [[ -f "$block_file" ]] || continue
16 +
17 + local name
18 + name=$(basename "$block_file" .block)
19 +
20 + while IFS=" " read -r client_ip target port proto; do
21 + if [[ -z "$target" ]]; then
22 + firewall::block_all "$client_ip" "$name"
Newer Older