scripts/adblock_test.sh
borekon 69a0197525 Use only ipv4
Added -4 to dig command
2024-03-25 18:02:44 +00:00

29 lines
778 B
Bash

#!/bin/bash
source <(curl -s https://gitea.avc.cx/borekon/scripts/raw/branch/main/colores.sh)
ip_to_find="0.0.0.0"
blocked=0
#if [ -z "$1" ]
# then
# dns=$(cat /etc/resolv.conf | grep ^nameserver | cut -d " " -f 2)
# else
# dns=$1
#fi
dns=${1:-$(head -n 1 /etc/resolv.conf | grep ^nameserver | cut -d " " -f 2)}
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"
for j in $domains; do
echo -e "${YELLOW}$j${NC}:"
output=$(dig -4 @$dns $j +short)
if [[ "$output" == *"$ip_to_find"* ]]; then
verde $output
((blocked++))
else
rojo $output
fi
echo ""
done;
porcentaje=$(( blocked * 10 ))
azul "$porcentaje % dominios bloqueados"