最終更新 1 month ago

nuno revised this gist 1 month ago. Go to revision

1 file changed, 21 insertions

gistfile1.txt(file created)

@@ -0,0 +1,21 @@
1 + function fw::restore_block_rules() {
2 + while IFS= read -r peer_name; do
3 + local block_file
4 + block_file="$(ctx::block::path "${peer_name}.block")"
5 + [[ ! -f "$block_file" ]] && continue
6 +
7 + local client_ip
8 + client_ip=$(peers::get_ip "$peer_name")
9 + [[ -z "$client_ip" ]] && continue
10 +
11 + while IFS="|" read -r bname btype target port proto; do
12 + [[ -z "$btype" ]] && continue
13 + case "$btype" in
14 + full) fw::block_all "$client_ip" "$peer_name" ;;
15 + ip) fw::block_ip "$client_ip" "$target" ;;
16 + port) fw::block_port "$client_ip" "$target" "$port" "${proto:-tcp}" ;;
17 + subnet) fw::block_subnet "$client_ip" "$target" ;;
18 + esac
19 + done < <(json::block_get_rules "$block_file")
20 + done < <(peers::all)
21 + }
Newer Older