diff --git a/neofetch b/neofetch index c298ad3f..7a8e3c14 100755 --- a/neofetch +++ b/neofetch @@ -5300,6 +5300,16 @@ get_local_ip() { } get_public_ip() { + if [[ -z "$public_ip_host" ]] && type -p dig >/dev/null; then + public_ip="$(dig +time=1 +tries=1 +short TXT ch whoami.cloudflare @1.1.1.1 | tr -d '"')" + [[ "$public_ip" =~ ^\; ]] && unset public_ip + fi + + if [[ -z "$public_ip_host" ]] && [[ -z "$public_ip" ]] && type -p drill >/dev/null; then + public_ip="$(drill whoami.cloudflare TXT CH @1.1.1.1 | awk '/^whoami\./ && $3 == "CH" {print $5}' | tr -d '"')" + fi + + # Fallback if [[ -z "$public_ip_host" ]] && type -p dig >/dev/null; then public_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com)" [[ "$public_ip" =~ ^\; ]] && unset public_ip