function cmd::list::_collect_all_rows() { local dir dir="$(ctx::clients)" local _verbose_status="${LIST_VERBOSE_STATUS:-true}" for conf in "${dir}"/*.conf; do [[ -f "$conf" ]] || continue local client_name client_name=$(basename "$conf" .conf) [[ -z "$client_name" ]] && continue if [[ ${#p_identity_filter[@]} -gt 0 && \ -z "${p_identity_filter[$client_name]:-}" ]]; then continue fi local ip="${p_ips[$client_name]:-}" [[ -z "$ip" ]] && ip=$(grep "^Address" "$conf" | awk '{print $3}' | cut -d'/' -f1) [[ -z "$ip" ]] && continue local type="${p_types[$client_name]:-unknown}" [[ -n "$filter_type" && "$type" != "$filter_type" ]] && continue local pubkey="${p_pubkeys[$client_name]:-}" local handshake_ts="${wg_handshakes[$pubkey]:-0}" local is_blocked="${p_blocked[$client_name]:-false}" local is_restricted="${p_restricted[$client_name]:-false}" local last_ts="${p_last_ts[$client_name]:-}" local rule="${p_rules[$client_name]:-}" local group="${p_main_groups[$client_name]:-}" if $online_only; then peers::is_online "$client_name" "$handshake_ts" "$last_ts" || continue; fi if $offline_only; then peers::is_offline "$client_name" "$handshake_ts" "$last_ts" || continue; fi if $restricted_only && [[ "$is_restricted" != "true" ]]; then continue; fi if $blocked_only && [[ "$is_blocked" != "true" ]]; then continue; fi if $allowed_only && { [[ "$is_blocked" == "true" ]] || \ [[ "$is_restricted" == "true" ]]; }; then continue; fi if [[ -n "$filter_rule" && "$rule" != "$filter_rule" ]]; then continue; fi if [[ -n "$filter_group" ]]; then local all_groups="${peer_group_map[$client_name]:-}" [[ "$all_groups" != *"$filter_group"* ]] && continue fi # Resolve status — verbose or simple local status if [[ "$_verbose_status" == "true" ]]; then status=$(peers::format_status_verbose "$client_name" "$pubkey" \ "$is_blocked" "$is_restricted" "$handshake_ts" "$last_ts" | \ sed 's/\x1b\[[0-9;]*m//g') else local state state=$(peers::connection_state "$is_blocked" "$is_restricted" "$handshake_ts" "$last_ts") status="${state%%|*}" fi # Resolve last seen local last_seen="-" if [[ "$is_blocked" == "true" && -n "$last_ts" && "$last_ts" != "0" ]]; then local attempt_ts attempt_ts=$(json::iso_to_ts "$last_ts") last_seen="$(fmt::datetime_short "$attempt_ts") (dropped)" elif [[ -n "$handshake_ts" && "$handshake_ts" != "0" ]]; then local ts_display ts_display=$(fmt::datetime_short "$handshake_ts") if [[ "$status" == "online"* ]]; then last_seen="${ts_display} (handshake)" else last_seen="$ts_display" fi fi printf "%s|%s|%s|%s|%s|%s|%s|%s|%s\n" \ "$client_name" "$ip" "$type" \ "${rule:--}" "${group:--}" \ "$status" "$last_seen" \ "$is_blocked" "$is_restricted" done }