summaryrefslogtreecommitdiffstats
path: root/retiolum/bin/find-active-nodes
blob: 2c316d0eb93a5758e4a6a0ae649b74cea9b5b286 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /bin/dash
set -eu
cd /etc/tinc/retiolum/hosts
for name in `
  grep '^[[:space:]]*Address[[:space:]]*=' * |
    cut -d: -f1 | sort | uniq
`; do
  if eval "`sed -n '
      s/[[:space:]]\+//g
      s/^\(Address\|Port\)=\(.*\)/\1="\${\1+\$\1\n}\2"/p
    ' $name`"; then
    port=${Port-655}
    for host in $Address; do
      if nc -zw 2 $host $port 2>/dev/null; then
        echo "$name [('$host', $port)]"
      fi &
    done
    wait
  fi &
done
wait