Merge pull request #205 from dylanaraps/publicip
Changes to the public ip function
This commit is contained in:
commit
88decbda2e
4
1.6.md
4
1.6.md
|
@ -104,6 +104,10 @@ This is much faster than the default method.
|
||||||
**Birthday**<br \>
|
**Birthday**<br \>
|
||||||
- Fix stray `+` sign in output.
|
- Fix stray `+` sign in output.
|
||||||
|
|
||||||
|
**Public IP**<br \>
|
||||||
|
- Each source now has a timeout to avoid a hang.
|
||||||
|
- If the IP detection fails we try another method.
|
||||||
|
|
||||||
|
|
||||||
### Image
|
### Image
|
||||||
|
|
||||||
|
|
12
neofetch
12
neofetch
|
@ -1629,13 +1629,15 @@ getlocalip () {
|
||||||
|
|
||||||
getpublicip () {
|
getpublicip () {
|
||||||
if type -p dig >/dev/null 2>&1; then
|
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
|
if [ -z "$publicip" ] && type -p curl >/dev/null 2>&1; then
|
||||||
publicip="$(curl -w '\n' "$public_ip_host")"
|
publicip="$(curl --max-time 10 -w '\n' "$public_ip_host" 2>/dev/null)"
|
||||||
|
fi
|
||||||
|
|
||||||
elif type -p wget >/dev/null 2>&1; then
|
if [ -z "$publicip" ] && type -p wget >/dev/null 2>&1; then
|
||||||
publicip="$(wget -qO- "$public_ip_host"; printf "%s")"
|
publicip="$(wget -T 10 -qO- "$public_ip_host" 2>/dev/null; printf "%s")"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue