local endpoint_display endpoint_display=$(resolve::ip "${endpoint:-}") [[ -z "$endpoint_display" ]] && endpoint_display="${endpoint:--}" # Build row with ts prefix for sorting local row row=$(ui::watch::wg_row "$ts_fmt" "$client_name" "$endpoint_display" "handshake" \ "$w_client" "$w_dest") rows+=("${ts}|${row}") done < <(wg show "$(config::interface)" latest-handshakes 2>/dev/null) # Sort by ts descending (most recent first) and print if [[ ${#rows[@]} -gt 0 ]]; then printf '%s\n' "${rows[@]}" | sort -t'|' -k1,1rn | while IFS= read -r entry; do _WATCH_LAST_FW["$fw_key"]="$now" local ts_fmt ts_fmt=$(fmt::datetime_short "$(json::iso_to_ts "$ts" 2>/dev/null || echo 0)") local dest_display dest_display=$(resolve::dest "$dest_ip" "$dest_port" "$proto") ui::watch::fw_row "$ts_fmt" "$client" "$dest_display" "$w_client" "$w_dest" else $restricted_only && continue local ev_data ev_data=$(python3 "$(ctx::json_helper)" parse_event "$line" 2>/dev/null) || continue [[ -z "$ev_data" ]] && continue local endpoint_resolved endpoint_resolved=$(resolve::ip "${endpoint:-}") if [[ -z "$endpoint_resolved" && -n "$endpoint" ]]; then endpoint_resolved="$endpoint" fi [[ -z "$endpoint_resolved" ]] && endpoint_resolved="-" ui::watch::wg_row "$ts_fmt" "$client" "$endpoint_resolved" "$event" \ "$w_client" "$w_dest" fi done rm -f "$source_file"