Compare commits

..

No commits in common. "d04659676624f09fb9763c882a019154205e9fd8" and "bc06c5df314c5c3d0336d811c0883ff03ee9c1d6" have entirely different histories.

2 changed files with 28 additions and 39 deletions

View file

@ -283,19 +283,13 @@ function cmd::list::_collect_all_rows() {
local status="${state%%|*}"
# Resolve last seen
local 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)"
last_seen=$(fmt::datetime_short "$attempt_ts")
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
last_seen=$(fmt::datetime_short "$handshake_ts")
fi
printf "%s|%s|%s|%s|%s|%s|%s|%s|%s\n" \
@ -419,11 +413,7 @@ function cmd::list::_render_detailed() {
while IFS='|' read -r name ip type rule group status last_seen is_blocked is_restricted; do
[[ -z "$name" ]] && continue
local subnet
subnet=$(peers::get_meta "$name" "subnet" 2>/dev/null)
if [[ -z "$subnet" ]]; then
local peer_type="${p_types[$name]:-}"
[[ -n "$peer_type" ]] && subnet="$peer_type"
fi
subnet=$(peers::get_meta "$name" "subnet" 2>/dev/null) || subnet="-"
[[ -z "$subnet" ]] && subnet="-"
ui::peer::list_row_detailed \
"$w_name" "$w_ip" "$w_type" "$w_rule" "$w_group" "$w_subnet" \
@ -441,12 +431,8 @@ function cmd::list::_render_detailed() {
while IFS='|' read -r name ip type rule group status last_seen is_blocked is_restricted; do
[[ -z "$name" ]] && continue
local subnet
subnet=$(peers::get_meta "$name" "subnet" 2>/dev/null)
if [[ -z "$subnet" ]]; then
local peer_type="${p_types[$name]:-}"
[[ -n "$peer_type" ]] && subnet="$peer_type"
fi
[[ -z "$subnet" ]] && subnet="-"
subnet=$(peers::get_meta "$name" "subnet" 2>/dev/null) || subnet="—"
[[ -z "$subnet" ]] && subnet="—"
ui::peer::list_row_detailed \
"$w_name" "$w_ip" "$w_type" "$w_rule" "$w_group" "$w_subnet" \
"$name" "$ip" "$type" "$rule" "$group" "$subnet" \

View file

@ -29,18 +29,21 @@ function ui::peer::list_row_compact() {
status_color="\033[1;32m"
fi
# Last seen mirrors status color
local ls_color="$status_color"
local ls_color="\033[0;37m"
[[ "$status" == "online" ]] && ls_color="\033[1;32m"
local rule_val="${rule:--}"
local group_val="${group:--}"
# Pad name, ip, type — pure ASCII, safe for printf
local name_pad ip_pad type_pad status_pad
name_pad=$(printf "%-${w_name}s" "$name")
ip_pad=$(printf "%-${w_ip}s" "$ip")
type_pad=$(printf "%-${w_type}s" "$type")
status_pad=$(printf "%-8s" "$status")
# Padding for label+value fields — compute trailing spaces manually
# so ANSI codes in labels don't confuse printf width calculation
local rule_pad_n group_pad_n
rule_pad_n=$(( w_rule - ${#rule_val} ))
group_pad_n=$(( w_group - ${#group_val} ))
@ -127,12 +130,12 @@ function ui::peer::list_row_detailed() {
status_color="\033[1;32m"
fi
# Last seen mirrors status color
local ls_color="$status_color"
local ls_color="\033[0;37m"
[[ "$status" == "online" ]] && ls_color="\033[1;32m"
local rule_val="${rule:--}"
local group_val="${group:--}"
local subnet_val="${subnet:--}"
local rule_val="${rule:-}"
local group_val="${group:-}"
local subnet_val="${subnet:-}"
local name_pad ip_pad type_pad status_pad
name_pad=$(printf "%-${w_name}s" "$name")