Created
April 26, 2015 16:07
-
-
Save prauscher/4596b7c339bcf900c8a7 to your computer and use it in GitHub Desktop.
dns-hydra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# mtn uses different timestamp-format and we do not want AM/PM | |
export LC_ALL="de_DE.UTF8" | |
cd $(dirname $0)/registry | |
mtn sync mtn://mtn.xuu.me/?net.dn42.* 2> /dev/null | |
mtn sync mtn://mtn.grmml.dn42/?net.dn42.* 2> /dev/null | |
mtn pull mtn://mtn.nixnodes.dn42/?net.dn42.* 2>/dev/null | |
mtn update 2> /dev/null | |
touch /tmp/revs.$$ | |
handle_subtree() { | |
echo "$1" >> /tmp/revs.$$ | |
parents=$(mtn au parents "$1") | |
for parent in $parents; do | |
echo " \"$(print_revid $1)\" -> \"$(print_revid $parent)\";" | |
[ $2 -gt 0 ] && ! grep $parent /tmp/revs.$$ > /dev/null && handle_subtree $parent $(( $2 - 1 )) | |
done | |
} | |
print_revid() { | |
rev="$1" | |
echo "${rev:0:8}\n$(mtn log --brief --no-graph -r $rev | awk '{ print $3" "$4 }')" | |
} | |
echo "digraph mtndns {" | |
dig ns dn42 +short | while read line; do | |
host=$line | |
rev=$(dig +short txt _rev._info.dn42 @$line | tr -d '"') | |
echo " \"$host\" [shape=box];" | |
if [ -n "$rev" ]; then | |
i=0 | |
echo " \"$host\" -> \"$(print_revid $rev)\";" | |
! grep $rev /tmp/revs.$$ > /dev/null && handle_subtree "$rev" 10 | |
fi | |
done | |
echo "}" | |
rm /tmp/revs.$$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
$(dirname $0)/dns-hydra.sh 2>/dev/null | dot -Tsvg > /srv/www/sheldon.prauscher.de/htdocs/dns-hydra_.svg | |
mv /srv/www/sheldon.prauscher.de/htdocs/dns-hydra_.svg /srv/www/sheldon.prauscher.de/htdocs/dns-hydra.svg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment