[PATCH 2/2] configurehood: Check for timestamp of hood file over LAN
mail at adrianschmutzler.de
mail at adrianschmutzler.de
So Mär 11 16:01:31 CET 2018
Hallo,
gerade getestet mit folgendem Setup:
dez. GW <--- WiFi --> FF-Router 1 <--- Ethernet ---> FF-Router 2
Sowohl für Trennung des Ethernet-Clusters vom Uplink/GW (z.B. bei Änderung
der mesh-SSID) als auch für Wechsel der Datei ohne Mesh-Unterbrechung (z.B.
bei Änderung der AP-SSID) scheint jetzt alles zu klappen.
Tested-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
Grüße
Adrian
> -----Original Message-----
> From: franken-dev [mailto:franken-dev-bounces at freifunk.net] On Behalf
> Of Adrian Schmutzler
> Sent: Donnerstag, 8. März 2018 21:25
> To: franken-dev at freifunk.net
> Subject: [PATCH 2/2] configurehood: Check for timestamp of hood file over
> LAN
>
> This patch does no more take the first hood file it finds, but compares
the
> timestamps provided.
>
> Additionally, we again started to check for the gateway at the end, but
only
> take the file if its newer and FROM THE SAME HOOD.
>
> Thus, we enable updates, but prohobit switching from a cable hood to a
WiFi
> peer. (Bug # 68)
>
> Fixes #95.
>
> Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
>
> ---
>
> NOT TESTED!
> ---
> .../fff/fff-hoods/files/usr/sbin/configurehood | 26
++++++++++++++++---
> ---
> 1 file changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> index 127ce5b..3a6fb9b 100755
> --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> @@ -145,6 +145,7 @@ else
>
> # check eth first
> oldhood=""
> + oldtime="0"
> ethfile="${hoodfile}eth"
> for eth in $(batctl if | grep "eth" | sed -nE
> 's/.*(eth[^:]+):.*/\1/p'); do
> for mac in $(batctl n | grep "$eth" | sed
-nE
> 's/.*eth[0-9.]+\s+([^\s]+)\s.*/\1/p'); do @@ -154,6 +155,7 @@ else
> json_load "$(cat
"$ethfile")"
> json_select hood
> json_get_var newhood name
> + json_get_var newtime
> timestamp
> if [ -n "$oldhood" ] && [ -n
> "$newhood" ] && ( ! [ "$newhood" = "$oldhood" ] ) ; then
> # 2nd hood found,
kill
> interface and go on (next try in 5 min.)
> echo "Two hoods
> detected. Remove cables to stay in just one."
> @@ -161,18 +163,28 @@ else
> touch
> "$resetnetworkfile"
> continue 2 # go to
the
> next interface
> fi
> - mv "$ethfile" "$hoodfile" #
> Only use hoodfile if sane
> + if [ "$oldtime" -lt
"$newtime" ]
> ; then
> + mv "$ethfile"
> "$hoodfile" # Only use hoodfile if sane and newer
> + oldtime="$newtime"
> + fi
> [ -n "$oldhood" ] ||
> oldhood="$newhood" # only set oldhood once
> fi
> done
> done
> - if [ ! -s "$hoodfile" ]; then
> - # Only load hoodfile from gateway if not
> already present from local network
> - # - This gives local network a precedence
> (take the hood from local network)
> - # - This prevents file insertion from a
third
> person, as I will only connect via LAN to who I trust
> - wget -T15 -t5 "http://[fe80::1%br-
> mesh]:2342/keyxchangev2data" -O "$hoodfile"
> +
> + # check gateway
> + wget -T15 -t5 "http://[fe80::1%br-
> mesh]:2342/keyxchangev2data" -O "$ethfile"
> + if [ -s "$ethfile" ]; then
> + json_load "$(cat "$ethfile")"
> + json_select hood
> + json_get_var newhood name
> + json_get_var newtime timestamp
> + if [ -z "$oldhood" ] || [ "$newhood" =
> "$oldhood" ] ; then
> + # Gateway on same hood, check for
> newer hood file
> + [ "$oldtime" -lt "$newtime" ] && mv
> "$ethfile" "$hoodfile" # Only use hoodfile if sane and newer
> + fi
> fi
> - #UPLINK: Do nothing
> + #SECTORFILE: Do nothing
> fi
> fi
> fi
> --
> 2.7.4
>
> --
> franken-dev mailing list
> franken-dev at freifunk.net
> http://lists.freifunk.net/mailman/listinfo/franken-dev-freifunk.net
Mehr Informationen über die Mailingliste franken-dev