Ultima attività 1 month ago

nuno ha revisionato questo gist 1 month ago. Vai alla revisione

1 file changed, 28 insertions

gistfile1.txt(file creato)

@@ -0,0 +1,28 @@
1 + function cmd::logs::show_wg_events() {
2 + local filter_ip="${1:-}" filter_name="${2:-}" filter_type="${3:-}" limit="${4:-50}" collapse="${5:-1}"
3 +
4 + [[ ! -f "$WG_EVENTS_LOG" ]] && return 0
5 +
6 + local data
7 + data=$(json::wg_events "$WG_EVENTS_LOG" "$filter_name" "$filter_type" "$limit" "$collapse" 2>/dev/null)
8 +
9 + [[ -z "$data" ]] && return 0
10 +
11 + # Measure column widths
12 + local w_client=16 w_endpoint=16
13 + while IFS='|' read -r ts client endpoint event count; do
14 + [[ -z "$ts" ]] && continue
15 + (( ${#client} > w_client )) && w_client=${#client}
16 + (( ${#endpoint} > w_endpoint )) && w_endpoint=${#endpoint}
17 + done <<< "$data"
18 + (( w_client += 2 ))
19 + (( w_endpoint += 2 ))
20 +
21 + ui::logs::wg_section_header
22 + while IFS='|' read -r ts client endpoint event count; do
23 + [[ -z "$ts" ]] && continue
24 + ui::logs::wg_row "$ts" "$client" "$endpoint" "$event" \
25 + "$count" "$w_client" "$w_endpoint"
26 + done <<< "$data"
27 + printf "\n"
28 + }
Più nuovi Più vecchi