gistfile1.txt
· 956 B · Text
Brut
function cmd::unblock::_unblock_all() {
local name="${1:?name required}"
local client_ip="${2:?client_ip required}"
local quiet="${3:-false}"
local block_file
block_file="$(ctx::block::path "${name}.block")"
# Set direct block to false
block::set_direct "$name" "$client_ip" "false"
local still_blocked
still_blocked=$(block::is_blocked "$name")
# Only actually unblock if no groups still blocking
if [[ "$still_blocked" != "true" ]]; then
fw::unblock_all "$client_ip"
fw::flush_peer "$client_ip"
fw::remove_block_file "$name"
monitor::unwatch_client "$name"
if ! peers::exists_in_server "$name"; then
local public_key
public_key=$(keys::public "$name") || return 1
peers::add_to_server "$name" "$public_key" "$client_ip"
peers::reload
fi
$quiet || log::wg_success "${name} has been unblocked."
else
$quiet || log::wg_warning "${name} still blocked by group(s)"
fi
}
| 1 | function cmd::unblock::_unblock_all() { |
| 2 | local name="${1:?name required}" |
| 3 | local client_ip="${2:?client_ip required}" |
| 4 | local quiet="${3:-false}" |
| 5 | |
| 6 | local block_file |
| 7 | block_file="$(ctx::block::path "${name}.block")" |
| 8 | |
| 9 | # Set direct block to false |
| 10 | block::set_direct "$name" "$client_ip" "false" |
| 11 | |
| 12 | local still_blocked |
| 13 | still_blocked=$(block::is_blocked "$name") |
| 14 | |
| 15 | # Only actually unblock if no groups still blocking |
| 16 | if [[ "$still_blocked" != "true" ]]; then |
| 17 | fw::unblock_all "$client_ip" |
| 18 | fw::flush_peer "$client_ip" |
| 19 | fw::remove_block_file "$name" |
| 20 | monitor::unwatch_client "$name" |
| 21 | |
| 22 | if ! peers::exists_in_server "$name"; then |
| 23 | local public_key |
| 24 | public_key=$(keys::public "$name") || return 1 |
| 25 | peers::add_to_server "$name" "$public_key" "$client_ip" |
| 26 | peers::reload |
| 27 | fi |
| 28 | |
| 29 | $quiet || log::wg_success "${name} has been unblocked." |
| 30 | else |
| 31 | $quiet || log::wg_warning "${name} still blocked by group(s)" |
| 32 | fi |
| 33 | } |