#!/bin/bash # # Needs CJDNS tools in your PATH # # Ref: https://github.com/cjdelisle/cjdns # counter=0 printf '[' > walk.aknet dumpLinks \ | cut -d ' ' -f 2,4 \ | sed 's/ /\n/g' \ | sort \ | uniq \ | while read -r ip || [ -n "$ip" ] do node_info="`curl \ -A 'akd/0.1.0; https://github.com/arching-kaos' \ --connect-timeout 3 \ "http://[$(publictoip6 $ip)]:8610/v0/node_info" 2>/dev/null`" if [ "$?" == "0" ] then if [ "$counter" -ne "0" ] then printf ',' >> walk.aknet fi printf '{"cjdns":{"public_key":"%s","ip":"%s"},"node_info":%s}' \ "$ip" "`publictoip6 $ip`" "$node_info" >> walk.aknet counter="`expr $counter + 1`" fi done printf ']' >> walk.aknet mv walk.aknet $AK_ZPEERSFILE