Skip to content
Snippets Groups Projects
Commit 17d809f2 authored by root's avatar root
Browse files

Using DNSv4 as fallback, if DNSv6 is not working. Memory-File not longer...

Using DNSv4 as fallback, if DNSv6 is not working. Memory-File not longer neccessary, because DNS always gives an answer, even if node is not registered.
parent 7e9cf182
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,6 @@ start () {
/etc/init.d/fastd restart
fi
rm /tmp/.seg.ffs
/etc/init.d/micrond enable
/etc/init.d/micrond restart
}
......
#!/bin/sh
SEGSET=/tmp/.seg.ffs
ME=$(basename $0)
if [ $(ps | grep -c "$ME") -gt 4 ]; then
logger -s -t $ME "started twice"
......@@ -24,20 +22,30 @@ fi
NODEID=$(uci get network.bat0.macaddr | sed 's/://g')
PUBKEY=$(/etc/init.d/fastd show_key mesh_vpn | cut -c1-12)
GITSEG=$(nslookup ffs-${NODEID}-${PUBKEY}.segassign.freifunk-stuttgart.de ::1#54 | grep "2001:2:0:711::" | cut -d':' -f7)
DNSDOM="freifunk-stuttgart.de"
DNSREQ="ffs-${NODEID}-${PUBKEY}.segassign.${DNSDOM}"
logger -t $ME "DNSv6 on ${DNSREQ} ..."
GITSEG=$(nslookup ${DNSREQ} ::1#54 | grep "2001:2:0:711::" | cut -d':' -f7)
if [ -z "$GITSEG" ]; then
if [ -f $SEGSET ]; then
GITSEG=$(cat $SEGSET)
logger -t $ME "Node is in Segment: $GITSEG"
else
logger -t $ME "Node not registered"
GITSEG=99
logger -t $ME "DNSv4 on ${DNSREQ} ..."
GITSEG=$(nslookup ${DNSREQ} ::1#54 | grep "198.18.190." | cut -d'.' -f4)
fi
if [ -z "$GITSEG" ]; then
logger -t $ME "DNS not working!"
exit 1
else
if [ -n "$BATSEG" ] && [ "$BATSEG" != "$GITSEG" ]; then
logger -t $ME "Avoiding Shortcut"
logger -t $ME "Avoiding Shortcut: $BATSEG - $GITSEG"
GITSEG=99
else
if [ "$GITSEG" = "99" ]; then
logger -t $ME "Node not registered"
else
logger -t $ME "Node is in Segment $GITSEG"
fi
fi
fi
......@@ -48,7 +56,7 @@ for i in `seq 1 10`;
do
GW=$(printf "gw%02d" $i)
OLDPEER=$(uci get fastd.mesh_vpn_backbone_peer_${GW}.remote)
NEWPEER=$(printf "\"gw%02ds%02d.gw.freifunk-stuttgart.de\" port %d" $i $GITSEG $PORT)
NEWPEER=$(printf "\"gw%02ds%02d.gw.${DNSDOM}\" port %d" $i $GITSEG $PORT)
if [ "$NEWPEER" != "$OLDPEER" ]; then
uci set fastd.mesh_vpn_backbone_peer_${GW}.remote="$NEWPEER"
......@@ -57,12 +65,6 @@ do
done
if [ "$CHANGED" = "1" ]; then
if [ "$GITSEG" = "99" ]; then
rm $SEGSET
else
echo $GITSEG >$SEGSET
fi
/sbin/ifdown client
/etc/init.d/fastd restart
/sbin/ifup client
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment