#!/usr/bin/env bash

curl https://raw.githubusercontent.com/ngosang/trackerslist/refs/heads/master/trackers_all_ip.txt | sed -e 's/.*:\/\/\(.*\):.*/\1/' | sed -e '/^[[:space:]]*$/d'

for http in $(curl https://raw.githubusercontent.com/ngosang/trackerslist/refs/heads/master/trackers_all_http.txt| sed -e 's/.*:\/\/\(.*\):.*/\1/' | sed -e '/^[[:space:]]*$/d'); do
    RES=$(dig +short $http)
    if [[ "${RES}" =~ [a-z] ]]; then
        RES=$(dig +short $RES)
    fi
    for res in $RES; do
        echo $res;
    done
done

for http in $(curl https://raw.githubusercontent.com/ngosang/trackerslist/refs/heads/master/trackers_all_https.txt| sed -e 's/.*:\/\/\(.*\):.*/\1/' | sed -e '/^[[:space:]]*$/d'); do
    RES=$(dig +short $http)
    if [[ "${RES}" =~ [a-z] ]]; then
        RES=$(dig +short $RES)
    fi
    for res in $RES; do
        echo $res;
    done
done

for http in $(curl https://raw.githubusercontent.com/ngosang/trackerslist/refs/heads/master/trackers_all_udp.txt| sed -e 's/.*:\/\/\(.*\):.*/\1/' | sed -e '/^[[:space:]]*$/d'); do
    RES=$(dig +short $http)
    if [[ "${RES}" =~ [a-z] ]]; then
        RES=$(dig +short $RES)
    fi
    for res in $RES; do
        echo $res;
    done
done

for http in $(curl https://raw.githubusercontent.com/ngosang/trackerslist/refs/heads/master/trackers_all_ws.txt| sed -e 's/.*:\/\/\(.*\):.*/\1/' | sed -e '/^[[:space:]]*$/d'); do
    RES=$(dig +short $http)
    if [[ "${RES}" =~ [a-z] ]]; then
        RES=$(dig +short $RES)
    fi
    for res in $RES; do
        echo $res;
    done
done