gistfile1.txt
· 698 B · Text
Sin formato
"function firewall::restore_blocks" /etc/wireguard/wgctl/modules/firewall.module.sh
function firewall::restore_blocks() {
local blocks_dir
blocks_dir="$(ctx::blocks)"
# Restore guest rules if marker exists
local marker="${blocks_dir}/_guest_rules.active"
if [[ -f "$marker" ]]; then
firewall::apply_guest_rules
log::wg "Restored guest firewall rules"
fi
# Restore per-client block rules
for block_file in "${blocks_dir}"/*.block; do
[[ -f "$block_file" ]] || continue
local name
name=$(basename "$block_file" .block)
while IFS=" " read -r client_ip target port proto; do
if [[ -z "$target" ]]; then
firewall::block_all "$client_ip" "$name"
| 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" |