gistfile1.txt
· 754 B · Text
Исходник
function fw::restore_block_rules() {
while IFS= read -r peer_name; do
local block_file
block_file="$(ctx::block::path "${peer_name}.block")"
[[ ! -f "$block_file" ]] && continue
local client_ip
client_ip=$(peers::get_ip "$peer_name")
[[ -z "$client_ip" ]] && continue
while IFS="|" read -r bname btype target port proto; do
[[ -z "$btype" ]] && continue
case "$btype" in
full) fw::block_all "$client_ip" "$peer_name" ;;
ip) fw::block_ip "$client_ip" "$target" ;;
port) fw::block_port "$client_ip" "$target" "$port" "${proto:-tcp}" ;;
subnet) fw::block_subnet "$client_ip" "$target" ;;
esac
done < <(json::block_get_rules "$block_file")
done < <(peers::all)
}
| 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 | } |