Last active
January 2, 2019 19:19
-
-
Save TobleMiner/182376850f849f3a6c6c7a5a718f3adc to your computer and use it in GitHub Desktop.
Simple script to analyze the transglobal table of batman
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
#!/usr/bin/env bash | |
node_mac_paths=('.nodes[].nodeinfo.network.mac') | |
batctl_count_hops() { | |
batctl -m "$1" tg | | |
sed 's/([[:space:]]*[0-9]\+)//g' | # Remove tq field | |
sed 's/[[:space:]]\+/ /g' | # Replace duplicate whitespace characters by a single space | |
cut -d' ' -f5 | # Extract nexthop | |
egrep -o '([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}' | # Match mac addresses only | |
sort | uniq -c | sort -k1nr | # Count number of devices using a certain nexthop | |
sed 's/[[:space:]]\+/ /g' | |
} | |
tgstats="`batctl_count_hops bat-ffki`" | |
nodes="`curl https://hopglass.freifunk.in-kiel.de/nodes.json 2> /dev/null`" | |
while read line; do | |
mac="$(echo "$line" | cut -d' ' -f2)" | |
name="$(echo "$nodes" | jq ".nodes | map(select(.nodeinfo.network | .. | strings | contains(\""$mac"\")))[].nodeinfo.hostname")" | |
echo "$line $name" | |
done <<< "$tgstats" |
Das Skript erlaubt das einfache Finden von Knoten mit ungewöhnlich vielen Clients bzw. Einträgen in der Transglobal table. Das hilft beim Finden von falsch konfigurierten Knoten, welche bspw. mesh auf client netz bridgen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wann braucht man dies?