From 4da69c6f400ba65c48643cc4442b227952a04f54 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 31 Mar 2016 19:37:18 +1100 Subject: [PATCH 1/3] Changes to the public ip function --- neofetch | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index 1040f515..0e40cd18 100755 --- a/neofetch +++ b/neofetch @@ -1629,13 +1629,15 @@ getlocalip () { getpublicip () { if type -p dig >/dev/null 2>&1; then - publicip="$(dig +short myip.opendns.com @resolver1.opendns.com)" + publicip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2>/dev/null)" + fi - elif type -p curl >/dev/null 2>&1; then - publicip="$(curl -w '\n' "$public_ip_host")" + if [ -z "$publicip" ] && type -p curl >/dev/null 2>&1; then + publicip="$(curl --max-time 10 -w '\n' "$public_ip_host")" + fi - elif type -p wget >/dev/null 2>&1; then - publicip="$(wget -qO- "$public_ip_host"; printf "%s")" + if [ -z "$publicip" ] && type -p wget >/dev/null 2>&1; then + publicip="$(wget -T 10 -qO- "$public_ip_host"; printf "%s")" fi } From 2d9764baffb226e2145d3f140d5117b725254056 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 31 Mar 2016 19:43:11 +1100 Subject: [PATCH 2/3] Suppress errors in output --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 0e40cd18..ede5f7e5 100755 --- a/neofetch +++ b/neofetch @@ -1633,11 +1633,11 @@ getpublicip () { fi if [ -z "$publicip" ] && type -p curl >/dev/null 2>&1; then - publicip="$(curl --max-time 10 -w '\n' "$public_ip_host")" + publicip="$(curl --max-time 10 -w '\n' "$public_ip_host" 2>/dev/null)" fi if [ -z "$publicip" ] && type -p wget >/dev/null 2>&1; then - publicip="$(wget -T 10 -qO- "$public_ip_host"; printf "%s")" + publicip="$(wget -T 10 -qO- "$public_ip_host" 2>/dev/null; printf "%s")" fi } From 44b9e5186b4f1bfc365e5f0550b837c95908cecb Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 31 Mar 2016 19:44:32 +1100 Subject: [PATCH 3/3] Changelog --- 1.6.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/1.6.md b/1.6.md index f33826e0..f7dbdb61 100644 --- a/1.6.md +++ b/1.6.md @@ -104,6 +104,10 @@ This is much faster than the default method. **Birthday**
- Fix stray `+` sign in output. +**Public IP**
+- Each source now has a timeout to avoid a hang. +- If the IP detection fails we try another method. + ### Image