diff options
-rwxr-xr-x | network-topology-scanner | 49 |
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) |