Naposledy aktivní 1 month ago

Revize e29cdfb20ed0f6b79ddbaa55039adce1913ba638

gistfile1.txt Raw
1function cmd::list::_iter_confs() {
2 # Usage: cmd::list::_iter_confs <filter_type> <callback>
3 local filter_type="$1"
4 local callback="$2"
5 local dir
6 dir="$(ctx::clients)"
7
8 for conf in "${dir}"/*.conf; do
9 [[ -f "$conf" ]] || continue
10 local client_name
11 client_name=$(basename "$conf" .conf)
12 local ip="${p_ips[$client_name]:-}"
13 if [[ -z "$ip" ]]; then
14 ip=$(grep "^Address" "$conf" | awk '{print $3}' | cut -d'/' -f1)
15 fi
16 local type
17 type=$(peers::get_type_from_ip "$ip")
18 [[ -n "$filter_type" && "$type" != "$filter_type" ]] && continue
19 "$callback" "$client_name" "$ip" "$type"
20 done
21}