From: Siraaj Khandkar Date: Fri, 8 Oct 2021 14:47:03 +0000 (-0400) Subject: Back-off exponentially on scan failures X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=ae3941ece4c7f45d06ab845a2568b0e470fe3c73;p=khome.git Back-off exponentially on scan failures --- diff --git a/home/bin/arp-recon b/home/bin/arp-recon index c96192f..6444a38 100755 --- a/home/bin/arp-recon +++ b/home/bin/arp-recon @@ -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]+/ {