From fe8e416909385a32f08a16c3a9285f29dcfbfcf9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 11 Sep 2015 19:36:04 +0100 Subject: [PATCH] Simplifying avahi browsing --- src/freedombone-mesh | 2 +- src/freedombone-meshweb | 2 +- src/zeronetavahi | 13 ++++--------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/freedombone-mesh b/src/freedombone-mesh index 3d08f244..1d3754e5 100755 --- a/src/freedombone-mesh +++ b/src/freedombone-mesh @@ -250,7 +250,7 @@ if [[ $SERVER_INSTALLATION == "no" ]]; then fi fi -avahi-browse -atl | grep "Workstation" | awk -F ' ' '{print $4}' | sort -u > $PEERS_FILE +avahi-browse -atl | awk -F ' ' '{print $4}' | sort -u > $PEERS_FILE if [ ! -f $PEERS_FILE ]; then echo 'No peers were found' diff --git a/src/freedombone-meshweb b/src/freedombone-meshweb index 5b7b6595..df7f9bca 100755 --- a/src/freedombone-meshweb +++ b/src/freedombone-meshweb @@ -277,7 +277,7 @@ if [[ $SERVER_INSTALLATION == "no" ]]; then fi fi -avahi-browse -atl | grep "Workstation" | awk -F ' ' '{print $4}' | sort -u > $PEERS_FILE +avahi-browse -atl | awk -F ' ' '{print $4}' | sort -u > $PEERS_FILE if [ ! -f $PEERS_FILE ]; then echo 'No peers were found' diff --git a/src/zeronetavahi b/src/zeronetavahi index 60d07a92..cb32f6b5 100755 --- a/src/zeronetavahi +++ b/src/zeronetavahi @@ -114,7 +114,7 @@ fi TEMPFILE_BASE=/tmp/tmpzeronetavahibase.txt TEMPFILE=/tmp/tmpzeronetavahi.txt avahi-browse -atr > $TEMPFILE_BASE -cat $TEMPFILE_BASE | grep "Workstation\|hostname =\|address =\|port =" > $TEMPFILE +cat $TEMPFILE_BASE | grep "hostname =\|address =\|port =" > $TEMPFILE if [ ! -f $TEMPFILE ]; then exit 1 fi @@ -131,7 +131,7 @@ address="" peer="" tracker_ctr=0 while IFS='' read -r line || [[ -n "$line" ]]; do - if [ ${state} -eq "2" ]; then + if [ ${state} -eq "1" ]; then if [[ $line == *"address ="* ]]; then address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}') echo " http://$peer:$TRACKER_PORT/announce" >> $ZERONET_CONFIG.new @@ -139,13 +139,8 @@ while IFS='' read -r line || [[ -n "$line" ]]; do tracker_ctr=$((tracker_ctr + 1)) fi fi - if [ ${state} -eq "1" ]; then - if [[ $line == *"hostname ="* ]]; then - peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}') - state=2 - fi - fi - if [[ $line == *"Workstation"* && $line == "= "* ]]; then + if [[ $line == *"hostname ="* ]]; then + peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}') state=1 fi done < "$TEMPFILE"