scripts/adblock_test.sh

25 lines
723 B
Bash

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