Compare commits
2 commits
bc06c5df31
...
d046596766
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d046596766 | ||
|
|
15897203a5 |
2 changed files with 39 additions and 28 deletions
|
|
@ -283,13 +283,19 @@ 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")
|
||||
last_seen="$(fmt::datetime_short "$attempt_ts") (dropped)"
|
||||
elif [[ -n "$handshake_ts" && "$handshake_ts" != "0" ]]; then
|
||||
last_seen=$(fmt::datetime_short "$handshake_ts")
|
||||
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" \
|
||||
|
|
@ -413,7 +419,11 @@ 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) || 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="-"
|
||||
ui::peer::list_row_detailed \
|
||||
"$w_name" "$w_ip" "$w_type" "$w_rule" "$w_group" "$w_subnet" \
|
||||
|
|
@ -431,8 +441,12 @@ 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) || subnet="—"
|
||||
[[ -z "$subnet" ]] && 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="-"
|
||||
ui::peer::list_row_detailed \
|
||||
"$w_name" "$w_ip" "$w_type" "$w_rule" "$w_group" "$w_subnet" \
|
||||
"$name" "$ip" "$type" "$rule" "$group" "$subnet" \
|
||||
|
|
|
|||
|
|
@ -29,21 +29,18 @@ function ui::peer::list_row_compact() {
|
|||
status_color="\033[1;32m"
|
||||
fi
|
||||
|
||||
local ls_color="\033[0;37m"
|
||||
[[ "$status" == "online" ]] && ls_color="\033[1;32m"
|
||||
# Last seen mirrors status color
|
||||
local ls_color="$status_color"
|
||||
|
||||
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} ))
|
||||
|
|
@ -130,12 +127,12 @@ function ui::peer::list_row_detailed() {
|
|||
status_color="\033[1;32m"
|
||||
fi
|
||||
|
||||
local ls_color="\033[0;37m"
|
||||
[[ "$status" == "online" ]] && ls_color="\033[1;32m"
|
||||
# Last seen mirrors status color
|
||||
local ls_color="$status_color"
|
||||
|
||||
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")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue