nuno ревизий этого фрагмента 1 month ago. К ревизии
1 file changed, 42 insertions
gistfile1.txt(файл создан)
| @@ -0,0 +1,42 @@ | |||
| 1 | + | grep -A 15 "function block::restore_peer" \ | |
| 2 | + | > /etc/wireguard/wgctl/modules/block.module.sh | |
| 3 | + | function block::restore_peer() { | |
| 4 | + | local name="${1:?}" client_ip="${2:?}" | |
| 5 | + | fw::unblock_all "$client_ip" | |
| 6 | + | fw::flush_peer "$client_ip" | |
| 7 | + | monitor::unwatch_client "$name" | |
| 8 | + | if ! peers::exists_in_server "$name"; then | |
| 9 | + | local public_key | |
| 10 | + | public_key=$(keys::public "$name") || return 1 | |
| 11 | + | peers::add_to_server "$name" "$public_key" "$client_ip" | |
| 12 | + | peers::reload | |
| 13 | + | fi | |
| 14 | + | } | |
| 15 | + | ||
| 16 | + | function block::restore_all() { | |
| 17 | + | while IFS= read -r peer_name; do | |
| 18 | + | block::has_file "$peer_name" || continue | |
| 19 | + | ||
| 20 | + | grep -A 20 "function block::restore_peer" \ | |
| 21 | + | > /etc/wireguard/wgctl/modules/block.module.sh | |
| 22 | + | function block::restore_peer() { | |
| 23 | + | local name="${1:?}" client_ip="${2:?}" | |
| 24 | + | fw::unblock_all "$client_ip" | |
| 25 | + | fw::flush_peer "$client_ip" | |
| 26 | + | monitor::unwatch_client "$name" | |
| 27 | + | if ! peers::exists_in_server "$name"; then | |
| 28 | + | local public_key | |
| 29 | + | public_key=$(keys::public "$name") || return 1 | |
| 30 | + | peers::add_to_server "$name" "$public_key" "$client_ip" | |
| 31 | + | peers::reload | |
| 32 | + | fi | |
| 33 | + | } | |
| 34 | + | ||
| 35 | + | function block::restore_all() { | |
| 36 | + | while IFS= read -r peer_name; do | |
| 37 | + | block::has_file "$peer_name" || continue | |
| 38 | + | local client_ip | |
| 39 | + | client_ip=$(peers::get_ip "$peer_name") | |
| 40 | + | [[ -z "$client_ip" ]] && continue | |
| 41 | + | while IFS="|" read -r bname btype target port proto; do | |
| 42 | + | [[ -z "$btype" ]] && continue | |
Новее
Позже