From d8b58a10b9c08deb236bd85bea0f4f0cdc6e3c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Par=C3=B3czai=20Oliv=C3=A9r?= Date: Fri, 11 Jun 2021 06:55:35 +0200 Subject: [PATCH] Only use DNS if public_ip_host option is empty (#1737) In config: public_ip_host="" -> uses DNS for getting public IP public_ip_host="http://example.com/ip" -> uses wget/curl for getting public IP --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 7393fbf9..093fc030 100755 --- a/neofetch +++ b/neofetch @@ -3807,12 +3807,12 @@ get_local_ip() { } get_public_ip() { - if type -p dig >/dev/null; then + if [[ ! -n "$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 fi - if [[ -z "$public_ip" ]] && type -p drill >/dev/null; then + if [[ ! -n "$public_ip_host" ]] && [[ -z "$public_ip" ]] && type -p drill >/dev/null; then public_ip="$(drill myip.opendns.com @resolver1.opendns.com | \ awk '/^myip\./ && $3 == "IN" {print $5}')" fi