From 16a7bee6d01d4656325ffe1b57f0c319aecd8473 Mon Sep 17 00:00:00 2001 From: borekon Date: Fri, 31 May 2024 07:12:30 +0000 Subject: [PATCH] dns servers converted to array In some systems could be more than one DNS server in resolv.conf. With this fix, we only pick the first element Signed-off-by: borekon --- adblock_test.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/adblock_test.sh b/adblock_test.sh index 7688ed7..476ccec 100644 --- a/adblock_test.sh +++ b/adblock_test.sh @@ -10,12 +10,13 @@ blocked=0 # else # dns=$1 #fi -dns=${1:-$(cat /etc/resolv.conf | grep ^nameserver | cut -d " " -f 2)} +dns_raw=${1:-$(cat /etc/resolv.conf | grep ^nameserver | cut -d " " -f 2)} +dns=($dns_raw) domains=$(curl -s https://raw.githubusercontent.com/StevenBlack/hosts/master/data/StevenBlack/hosts | grep -v ^# | shuf -n 10 | cut -d" " -f2) -verde "Using $dns DNS server" +verde "Using ${dns[0]} DNS server" for j in $domains; do echo -e "${YELLOW}$j${NC}:" - output=$(dig -4 @$dns $j +short) + output=$(dig -4 @${dns[0]} $j +short) if [[ "$output" == *"$ip_to_find"* ]]; then verde $output ((blocked++))