nuno revised this gist 1 month ago. Go to revision
1 file changed, 19 insertions
gistfile1.txt(file created)
| @@ -0,0 +1,19 @@ | |||
| 1 | + | function cmd::remove::_cleanup() { | |
| 2 | + | local name="${1:-}" client_ip="${2:-}" was_blocked="${3:-false}" | |
| 3 | + | ||
| 4 | + | [[ -n "$client_ip" ]] && fw::flush_peer "$client_ip" | |
| 5 | + | peers::remove_from_server "$name" || return 1 | |
| 6 | + | peers::remove_client_config "$name" || return 1 | |
| 7 | + | keys::remove "$name" || return 1 | |
| 8 | + | ||
| 9 | + | # Remove from all groups | |
| 10 | + | while IFS= read -r group_name; do | |
| 11 | + | group::remove_peer "$group_name" "$name" | |
| 12 | + | log::debug "Removed from group: ${group_name}" | |
| 13 | + | done < <(json::peer_groups "$(ctx::groups)" "$name") | |
| 14 | + | ||
| 15 | + | [[ -n "$client_ip" ]] && $was_blocked && fw::unblock_all "$client_ip" | |
| 16 | + | fw::remove_block_file "$name" 2>/dev/null || true | |
| 17 | + | peers::remove_meta "$name" 2>/dev/null || true | |
| 18 | + | peers::reload || return 1 | |
| 19 | + | } | |
Newer
Older