function cmd::list::_render_row() { local client_name="$1" ip="$2" type="$3" 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]:-}" # Apply status filters if $online_only; then peers::is_online "$client_name" "$handshake_ts" "$last_ts" || return 0; fi if $offline_only; then peers::is_offline "$client_name" "$handshake_ts" "$last_ts" || return 0; fi if $restricted_only && [[ "$is_restricted" != "true" ]]; then return 0; fi if $blocked_only && [[ "$is_blocked" != "true" ]]; then return 0; fi if $allowed_only && { [[ "$is_blocked" == "true" ]] || \ [[ "$is_restricted" == "true" ]]; }; then return 0; fi if [[ -n "$filter_group" ]]; then local peer_group="${peer_group_map[$client_name]:-}" [[ "$peer_group" != "$filter_group" ]] && return 0 fi # Format display values local status last_seen display_type rule group_display status=$(peers::format_status "$client_name" "$pubkey" \ "$is_blocked" "$is_restricted" "$handshake_ts" "$last_ts") last_seen=$(peers::format_last_seen "$client_name" "$pubkey" \ "$is_blocked" "$last_ts" "" "$handshake_ts") display_type=$(peers::display_type "$type" "${p_subtypes[$client_name]:-}") rule="${p_rules[$client_name]:-—}" if [[ -n "$filter_rule" && "$rule" != "$filter_rule" ]]; then return 0; fi # Print header on first match if [[ "${_list_header_printed:-false}" == "false" ]]; then log::section "WireGuard Clients" cmd::list::_render_header $has_groups _list_header_printed=true fi # Update rule counts for summary (outer scope array) rule_counts["$rule"]=$(( ${rule_counts[$rule]:-0} + 1 )) || true # Pad status local padded_status padded_status=$(ui::pad_status "$status" 25) # Render row if $has_groups; then group_display="${peer_group_map[$client_name]:-—}" if [[ -n "${peer_group_map[$client_name]:-}" ]]; then group_counts["$group_display"]=$(( ${group_counts[$group_display]:-0} + 1 )) || true fi local rule_col_width=12 group_col_width=12 [[ "$rule" == "—" ]] && rule_col_width=14 [[ "$group_display" == "—" ]] && group_col_width=14 printf " %-28s %-15s %-13s %-${rule_col_width}s %-${group_col_width}s %s %s\n" \ "$client_name" "$ip" "$display_type" "$rule" \ "$group_display" "$padded_status" "$last_seen" else local rule_col_width=12 [[ "$rule" == "—" ]] && rule_col_width=14 printf " %-28s %-15s %-13s %-${rule_col_width}s %s %s\n" \ "$client_name" "$ip" "$display_type" "$rule" \ "$padded_status" "$last_seen" fi }