最后活跃于 1 month ago

nuno 修订了这个 Gist 1 month ago. 转到此修订

1 file changed, 33 insertions

gistfile1.txt(文件已创建)

@@ -0,0 +1,33 @@
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 + }
上一页 下一页