gistfile1.txt
· 635 B · Text
Исходник
function cmd::list::_iter_confs() {
# Usage: cmd::list::_iter_confs <filter_type> <callback>
local filter_type="$1"
local callback="$2"
local dir
dir="$(ctx::clients)"
for conf in "${dir}"/*.conf; do
[[ -f "$conf" ]] || continue
local client_name
client_name=$(basename "$conf" .conf)
local ip="${p_ips[$client_name]:-}"
if [[ -z "$ip" ]]; then
ip=$(grep "^Address" "$conf" | awk '{print $3}' | cut -d'/' -f1)
fi
local type
type=$(peers::get_type_from_ip "$ip")
[[ -n "$filter_type" && "$type" != "$filter_type" ]] && continue
"$callback" "$client_name" "$ip" "$type"
done
}
| 1 | function 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 | } |