summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-11-30 11:07:19 +0100
committerErich Eckner <git@eckner.net>2018-11-30 11:07:19 +0100
commit85f488783fc83737a79bcee2a6725b0b9ccb35d4 (patch)
treef4ce8479a827fd5b962a1978d11fd6ae29be59f7
parentea4e3f9be9a1d864b601e3a56f937cd22a4a7dc4 (diff)
downloadnetwork-topology-scanner-85f488783fc83737a79bcee2a6725b0b9ccb35d4.tar.xz
network-topology-scanner: tayga dabeiHEADmaster
-rwxr-xr-xnetwork-topology-scanner49
1 files changed, 48 insertions, 1 deletions
diff --git a/network-topology-scanner b/network-topology-scanner
index a7c4f9a..f131c45 100755
--- a/network-topology-scanner
+++ b/network-topology-scanner
@@ -14,11 +14,11 @@ else
for host in "${hosts[@]}"; do
name="${host% *}"
addr="${host##* }"
- printf '"%s" [fontcolor="#800000"];\n' "${name}" >> "${tmp_dir}/print-content"
ssh "${addr}" '
ip -o addr | sed "s/^/ip /"
sudo iptables-save | sed "s/^/ip4tables /"
sudo ip6tables-save | sed "s/^/ip6tables /"
+ sed "s/^[^#]/tayga \0/;t;d" /etc/tayga.conf
' 2>/dev/null \
| sed '
s/^\S\+ /\0'"${name}"' /
@@ -26,12 +26,15 @@ else
>> "${tmp_dir}/infos"
done
fi
+cp "${tmp_dir}/infos" "infos"
sed '
s/^ip //
t ip
s/^ip\([64]\)tables /\1 /
t iptables
+ s/^tayga //
+ t tayga
s/^/>> unknown: >>/
w /dev/stderr
d
@@ -59,8 +62,52 @@ sed '
s/^\S\+ \S\+ \(\S\+\) \(\S\+\) .*$/\1 \2/
w '"${tmp_dir}"'/ips
d
+ :tayga
+ w '"${tmp_dir}"'/tayga
+ d
' "${tmp_dir}/infos"
+printf '%s\n' "${hosts[@]}" \
+ | sed '
+ s/^\(.*\) \S\+$/"\1" [fontcolor="#800000"];/
+ ' \
+ >> "${tmp_dir}/print-content"
+
+sort "${tmp_dir}/tayga" |
+ sed '
+ :a
+ N
+ s/^\(\S\+ \)\(.*\S\)\s*\n\1\([^\n]*\S\)\s*$/\1\2\\\3/
+ ta
+ P
+ D
+ ' | tee /dev/stderr \
+ | sed '
+ h
+ s/^\(\S\+ \)\(.*\\\)\?dynamic-pool \([^\\[:space:]]\+\)\\\(.*\\\)\?prefix \([^\\[:space:]]\+\)\(\\.*\)\?$/"\3" -> "\5" [dir=both, weight=0, color="#0000ff"];/
+ w '"${tmp_dir}/tayga-print-content"'
+ g
+ s/^\(\S\+\) \(.*\\\)\?dynamic-pool \([^\\[:space:]]\+\)\\\(.*\\\)\?tun-device \([^\\[:space:]]\+\)\(\\.*\)\?$/"\1 \5" -> "\3" [color="#808080"];/
+ w '"${tmp_dir}/tayga-print-content"'
+ g
+ s/^\(\S\+\) \(.*\\\)\?prefix \([^\\[:space:]]\+\)\\\(.*\\\)\?tun-device \([^\\[:space:]]\+\)\(\\.*\)\?$/"\1 \5" -> "\3" [color="#000000"];/
+ w '"${tmp_dir}/tayga-print-content"'
+ g
+ s/^\S\+ \(.*\\\)\?prefix \([^\\[:space:]]\+\)\(\\.*\)\?$/"\2" [fontcolor="#a0a000"];/
+ w '"${tmp_dir}/tayga-print-content"'
+ g
+ s/^\S\+ \(.*\\\)\?dynamic-pool \([^\\[:space:]]\+\)\(\\.*\)\?$/"\2" [fontcolor="#808000"];/
+ w '"${tmp_dir}/tayga-print-content"'
+ g
+ p
+ d
+ '
+
+for name in ips print-content; do
+ cat "${tmp_dir}/tayga-${name}" >> "${tmp_dir}/${name}"
+ rm "${tmp_dir}/tayga-${name}"
+done
+
while read -r version address; do
case ${version} in
inet)