[RFC,v1,4/4] Revert "configurehood: Prevent connecting two hoods"

Submitted by Tim Niemeyer on April 3, 2018, 7:27 p.m.

Details

Message ID 20180403192749.28637-5-tim@tn-x.org
State Superseded
Headers show

Commit Message

Tim Niemeyer April 3, 2018, 7:27 p.m.
Fixes #95

This reverts commit 6cc6b4b786d24faf067a6b29118e997c28c4e70b.

Signed-off-by: Tim Niemeyer <tim@tn-x.org>
---

 .../fff/fff-hoods/files/usr/sbin/configurehood     | 37 +---------------------
 1 file changed, 1 insertion(+), 36 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
index 2672cfa..e2c1fab 100755
--- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
+++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
@@ -9,7 +9,6 @@ 
 sectorlocal=/etc/sectorfile
 sectortmp=/tmp/sectorfile
 sectorcopy=/www/hood/sectorfile
-resetnetworkfile=/tmp/resetnetwork
 hoodlocal=/etc/hoodfile
 
 rm -f "$hoodfile"
@@ -73,12 +72,6 @@  fi
 lat=$(uci -q get fff.system.latitude)
 long=$(uci -q get fff.system.longitude)
 
-# reenable network interfaces in case we disabled them earlier
-if [ -f "$resetnetworkfile" ]; then
-	/etc/init.d/network restart
-	rm "$resetnetworkfile"
-fi
-
 if [ -s "$hoodlocal" ]; then
 	hoodfile="$hoodlocal"
 	echo "Use local hood file"
@@ -144,35 +137,7 @@  else
 			fi
 		else
 			echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1"
-			# check eth first
-			oldhood=""
-			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
-					EUI="$(echo "$mac" | awk -F: '{ printf("%02x%s:%sff:fe%s:%s%s\n", xor(("0x"$1),2), $2, $3, $4, $5, $6) }')"
-					wget -T2 -t3 "http://[fe80::${EUI}%${eth}]:2342/keyxchangev2data" -O "$ethfile"
-					if [ -s "$ethfile" ]; then
-						json_load "$(cat "$ethfile")"
-						json_select hood
-						json_get_var newhood name
-						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."
-							ifconfig "$eth" down
-							touch "$resetnetworkfile"
-							continue 2 # go to the next interface
-						fi
-						mv "$ethfile" "$hoodfile" # Only use hoodfile if sane
-						[ -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"
-			fi
+			wget -T15 -t5 "http://[fe80::1%br-mesh]:2342/keyxchangev2data" -O "$hoodfile"
 			#UPLINK: Do nothing
 		fi
 	fi

Comments

Christian Dresel June 10, 2018, 7:07 a.m.
Hi

da diese Logik bei Fabian seinen Patch wieder mit drinnen landet ein

Reviewed-by: Christian Dresel <fff@chrisi01.de>

sofern darauf Fabian sein Patch folgt.

mfg

Christian

On 03.04.2018 21:27, Tim Niemeyer wrote:
> Fixes #95
> 
> This reverts commit 6cc6b4b786d24faf067a6b29118e997c28c4e70b.
> 
> Signed-off-by: Tim Niemeyer <tim@tn-x.org>
> ---
> 
>  .../fff/fff-hoods/files/usr/sbin/configurehood     | 37 +---------------------
>  1 file changed, 1 insertion(+), 36 deletions(-)
> 
> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> index 2672cfa..e2c1fab 100755
> --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> @@ -9,7 +9,6 @@
>  sectorlocal=/etc/sectorfile
>  sectortmp=/tmp/sectorfile
>  sectorcopy=/www/hood/sectorfile
> -resetnetworkfile=/tmp/resetnetwork
>  hoodlocal=/etc/hoodfile
>  
>  rm -f "$hoodfile"
> @@ -73,12 +72,6 @@ fi
>  lat=$(uci -q get fff.system.latitude)
>  long=$(uci -q get fff.system.longitude)
>  
> -# reenable network interfaces in case we disabled them earlier
> -if [ -f "$resetnetworkfile" ]; then
> -	/etc/init.d/network restart
> -	rm "$resetnetworkfile"
> -fi
> -
>  if [ -s "$hoodlocal" ]; then
>  	hoodfile="$hoodlocal"
>  	echo "Use local hood file"
> @@ -144,35 +137,7 @@ else
>  			fi
>  		else
>  			echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1"
> -			# check eth first
> -			oldhood=""
> -			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
> -					EUI="$(echo "$mac" | awk -F: '{ printf("%02x%s:%sff:fe%s:%s%s\n", xor(("0x"$1),2), $2, $3, $4, $5, $6) }')"
> -					wget -T2 -t3 "http://[fe80::${EUI}%${eth}]:2342/keyxchangev2data" -O "$ethfile"
> -					if [ -s "$ethfile" ]; then
> -						json_load "$(cat "$ethfile")"
> -						json_select hood
> -						json_get_var newhood name
> -						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."
> -							ifconfig "$eth" down
> -							touch "$resetnetworkfile"
> -							continue 2 # go to the next interface
> -						fi
> -						mv "$ethfile" "$hoodfile" # Only use hoodfile if sane
> -						[ -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"
> -			fi
> +			wget -T15 -t5 "http://[fe80::1%br-mesh]:2342/keyxchangev2data" -O "$hoodfile"
>  			#UPLINK: Do nothing
>  		fi
>  	fi
>