From 8e0a37218b76c794110f087d3831f116637a71c3 Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Sat, 12 Aug 2017 22:36:36 -0500 Subject: [PATCH] Fixed a bug affecting slow system and AP services. The bug was caused by a constant wait time, rather than dynamic. The bug was more likey to affect the airbase-ng service. --- lib/ap/airbase-ng.sh | 12 +++++++----- lib/ap/hostapd.sh | 16 +++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/ap/airbase-ng.sh b/lib/ap/airbase-ng.sh index 6b7b6bf..b49cd2e 100644 --- a/lib/ap/airbase-ng.sh +++ b/lib/ap/airbase-ng.sh @@ -10,10 +10,6 @@ VIAP=$WIAccessPoint # and creates a separate interface, atX, for dhcpd. VIAPAddress="$VIGWNetwork.2" -VIAPRouteDelay=5 - -#APServiceConfPath="$FLUXIONWorkspacePath/APService.conf" - function ap_stop() { killall airbase-ng &> $FLUXIONOutputDevice @@ -41,7 +37,13 @@ function ap_prep() { function ap_start() { xterm $BOTTOMRIGHT -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [airbase-ng]" -e airbase-ng -P -e $APTargetSSID -c $APTargetChannel -a $APRogueMAC $VIAP & - sleep $VIAPRouteDelay; ap_route + + # Wait till airebase-ng has started and created the extra virtual interface. + while [ ! $(ps a | awk '$5~/^airbase-ng/ && $0~/'"$APRogueMAC"'/{print $1}') ] + do sleep 1 + done + + ap_route } # FLUXSCRIPT END diff --git a/lib/ap/hostapd.sh b/lib/ap/hostapd.sh index fd1aa07..49791e1 100644 --- a/lib/ap/hostapd.sh +++ b/lib/ap/hostapd.sh @@ -10,10 +10,6 @@ VIAP=$WIAccessPoint # to master, which is supported by dhcpd. VIAPAddress=$VIGWAddress -VIAPRouteDelay=5 - -APServiceConfPath="$FLUXIONWorkspacePath/APService.conf" - function ap_stop() { killall hostapd &> $FLUXIONOutputDevice @@ -50,7 +46,7 @@ interface=$VIAP driver=nl80211 ssid=$APTargetSSID channel=$APTargetChannel\ -" > "$APServiceConfPath" +" > "$APRogueMAC-hostapd.conf" # Spoof virtual interface MAC address. ifconfig $VIAP down @@ -64,8 +60,14 @@ channel=$APTargetChannel\ } function ap_start() { - xterm $HOLD $BOTTOMRIGHT -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [hostapd]" -e hostapd "$APServiceConfPath" & - sleep $VIAPRouteDelay; ap_route + xterm $HOLD $BOTTOMRIGHT -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [hostapd]" -e hostapd "$APRogueMAC-hostapd.conf" & + + # Wait till hostapd has started and its virtual interface is ready. + while [ ! $(ps a | awk '$5~/^hostapd/ && $0~/'"$APRogueMAC-hostapd.conf"'/{print $1}') ] + do sleep 1 + done + + ap_route } # FLUXSCRIPT END