diff options
author | tv <tv@nomic.retiolum> | 2013-02-02 01:22:08 +0100 |
---|---|---|
committer | tv <tv@nomic.retiolum> | 2013-02-02 01:22:08 +0100 |
commit | c6f8c72d483fdcdf2ba4554ca7f578089df9f1c2 (patch) | |
tree | 892d71bd132b6bac607d8873bee4c53490a33df4 /retiolum | |
parent | 374ad7c3f0389372ee5bf79988a35883cd80a7a4 (diff) |
//retiolum list-known-public-addresses: factorize
Diffstat (limited to 'retiolum')
-rwxr-xr-x | retiolum/bin/list-known-public-addresses | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/retiolum/bin/list-known-public-addresses b/retiolum/bin/list-known-public-addresses index d157cea4..d8073791 100755 --- a/retiolum/bin/list-known-public-addresses +++ b/retiolum/bin/list-known-public-addresses @@ -4,25 +4,29 @@ # set -eu -cd /etc/tinc/retiolum/hosts +_list_hostname_address() { + cd /etc/tinc/retiolum/hosts + grep --with-filename '^Address' * | + sed -n ' + s/: */ / + s/ *= */ / + s/ Address \([a-zA-Z0-9.:_]*\) \?.*/ \1/p' +} +_lookup_address() { + sed ' + /:/!{/ [0-9.]*$/!{s/ / `dig +short /;s/$/` \&/}} + s/^/echo / + $s/$/\nwait/ + ' | sh +} +_filter_public() { + sed ' + # drop private IPv4 addresses + / 10\./d + / 172\.\(1[6-9]\|2[0-9]\|3[01]\)\./d + / 192\.168\./d + # TODO drop private IPv6 addresses + ' +} -grep --with-filename '^Address' * | -sed ' - # filter "%s %s %s\n" hostname var val - s/: */ / - s/ *= */ / - # filter "%s %s\n" hostname address - s/ Address \([a-zA-Z0-9.:_]*\) \?.*/ \1/ - T - # prepare hostname lookup - /:/!{/ [0-9.]*$/!{s/ / `dig +short /;s/$/` \&/}} - s/^/echo / - $s/$/\nwait/ - # perform hostname lookup -' | sh | sed ' - # drop private IPv4 addresses - / 10\./d - / 172\.\(1[6-9]\|2[0-9]\|3[01]\)\./d - / 192\.168\./d - # TODO drop private IPv6 addresses -' +_list_hostname_address | _lookup_address | _filter_public |