Back-off exponentially on scan failures
authorSiraaj Khandkar <siraaj@khandkar.net>
Fri, 8 Oct 2021 14:47:03 +0000 (10:47 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Fri, 8 Oct 2021 14:47:03 +0000 (10:47 -0400)
home/bin/arp-recon

index c96192f..6444a38 100755 (executable)
@@ -44,16 +44,22 @@ debug() {
 }
 
 log() {
-    local -r interval="$1"
+    local -r interval_init="$1"
     local -r log_file="$2"
+    local    interval_curr="$interval_init"
 
     while :; do
         debug '(>) scan'
-        if ! sudo arp-scan --localnet; then
-            error 'scan failed'
+        if sudo arp-scan --localnet; then
+            debug '(.) scan ok'
+            interval_curr="$interval_init"
+        else
+            error '(.) scan failure'
+            interval_curr=$(( interval_curr * 2 ))
         fi
-        debug '(.) scan'
-        sleep "$interval";
+        debug '(>) sleep for %d seconds' "$interval_curr"
+        sleep "$interval_curr";
+        debug '(.) sleep'
     done \
     | stdbuf -o L awk '
         /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ {
This page took 0.037465 seconds and 4 git commands to generate.