function peers::format_status() { local name="${1:-}" public_key="${2:-}" is_blocked="${3:-false}" local is_restricted="${4:-false}" handshake_ts="${5:-0}" last_ts="${6:-}" local state state=$(peers::connection_state "$is_blocked" "$is_restricted" \ "$handshake_ts" "$last_ts") local conn_str modifier color IFS="|" read -r conn_str modifier color <<< "$state" # Color based on state — modifier overrides base connection color if [[ "$is_blocked" == "true" ]]; then color="\033[1;31m" # red — blocked elif [[ "$is_restricted" == "true" ]]; then color="\033[1;33m" # yellow — restricted elif [[ "$conn_str" == "online" ]]; then color="\033[1;32m" # green — online else color="\033[0;37m" # gray — offline fi local conn_str_padded conn_str_padded=$(printf "%-7s" "$conn_str") echo -e "${color}${conn_str_padded}\033[0m" }