Última atividade 1 month ago

nuno revisou este gist 1 month ago. Ir para a revisão

1 file changed, 51 insertions

gistfile1.txt(arquivo criado)

@@ -0,0 +1,51 @@
1 + function cmd::inspect::_peer_info() {
2 + local name="$1"
3 + local ip type rule status endpoint last_seen tunnel public_key
4 + local activity rx tx
5 +
6 + ip=$(peers::get_ip "$name")
7 + type=$(peers::get_type "$name")
8 + rule=$(peers::get_meta "$name" "rule")
9 + public_key=$(keys::public "$name" 2>/dev/null)
10 +
11 + # Status + endpoint + last seen — reuse list helpers
12 + status=$(cmd::list::format_status "$name" "$public_key" "$ip")
13 + last_seen=$(cmd::list::format_last_seen "$name" "$public_key" "$ip")
14 + endpoint=$(monitor::get_cached_endpoint "$name")
15 +
16 + # Tunnel mode from AllowedIPs in conf
17 + local allowed_ips
18 + allowed_ips=$(grep "^AllowedIPs" "$(ctx::clients)/${name}.conf" 2>/dev/null | cut -d'=' -f2- | xargs)
19 +
20 + activity="$(cmd::inspect::_get_activity "$public_key")"
21 +
22 + # Get fresh handshake
23 + local handshake_ts="0"
24 + handshake_ts=$(monitor::get_handshake_ts "$public_key")
25 +
26 + local is_blocked="false"
27 + peers::is_blocked "$name" && is_blocked="true"
28 +
29 + local last_ts
30 + last_ts=$(monitor::last_attempt "$name")
31 +
32 + local status last_seen
33 + status=$(cmd::list::_format_status "$name" "$public_key" \
34 + "$is_blocked" "false" "$handshake_ts" "$last_ts")
35 + last_seen=$(cmd::list::_format_last_seen "$name" "$public_key" \
36 + "$is_blocked" "$last_ts" "" "$handshake_ts")
37 +
38 + cmd::inspect::_section "Client"
39 + ui::row "Name" "$name"
40 + ui::row "IP" "$ip"
41 + ui::row "Type" "$(cmd::list::display_type "$name" "$type")"
42 + ui::row "Rule" "${rule:-—}"
43 + ui::row "Status" "$(echo -e "$status")"
44 + ui::row "Endpoint" "${endpoint:-—}"
45 + ui::row "Last seen" "$last_seen"
46 + ui::row "AllowedIPs" "$allowed_ips"
47 + ui::row "Public key" "${public_key:-—}"
48 + # ui::row "Total transfer" "${rx_hr} ↓ ${tx_hr} ↑"
49 + ui::row "Activity" "${activity:-—}"
50 +
51 + }
Próximo Anterior