#!/bin/sh # Copyright Michael John Wensley 2005 2006 # this script generates a graph of the GNUnet network via participating nodes. # set to a location containing a readable user's .gnunet/ directory export HOME=/home/michael function matching () { # echo ${1:1:4}"+"${2:0:4} [ "${1:1:4}" == "${2:0:4}" ] } function format () { echo -ne ${1:0:6}" [label=\"${1:1:4} ${2}\"" if [ "${1:1:4}" != "" ] then echo -ne ",fillcolor=\"0.4,0.5,1\"" fi echo "]" } # "Here Command" from the bash manpage if grep -q model/vrml <<<$HTTP_ACCEPT then echo -ne "Content-Type: model/vrml\r\n" GRAPH=-v else echo -ne "Content-Type: image/png\r\n" GRAPH="" fi { echo "digraph G {" gnunet-tracekit -F 1 | while read N1 N2 N3 N4 N5 do if [ "$N2" == "->" ] then echo $N1 $N2 $N3 # push N1 on stack KEY[${#KEY[*]}]=$N3 fi if [ "$N1" == "}" ] then gnunet-peer-info 2> /dev/null | tr -d \'\` | while read N KEYX N N TRUST N N ADDR TYPE N do for N in ${KEY[@]} do # find IP address for this key if matching $N $KEYX then LOC="" CO=1 I=1 case $TYPE in \(UDP\)) CO=6; I=4 ;; \(TCP\)) CO=17; I=4 ;; \(UDP6\)) CO=12; I=6 ;; \(TCP6\)) CO=23; I=6 ;; esac if [ "$I" = "4" ] then IP=`echo $ADDR | cut -d: -f1` LOC=`geoiplookup $IP | cut -d: -f2 | cut -c2-3` fi if [ "$I" = "6" ] then IP=`echo $ADDR | rev | cut -f2- -d: | rev` IPV4="" export `ipv6calc -imq $IP | grep -v \"` if [ "$IPV4" != "" ] then LOC=`geoiplookup $IPV4 | cut -d: -f2 | cut -c2-3` fi fi if [ "$OUT" != "$KEYX" ] then format $N $LOC OUT=$KEYX fi fi done done fi done echo "}" } | springgraph $GRAPH 2> /dev/null | /usr/local/sbin/lengen --http