Changes to the public ip function

This commit is contained in:
Dylan 2016-03-31 19:37:18 +11:00
parent 7672ba168f
commit 4da69c6f40

View file

@ -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")"
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"; printf "%s")"
fi fi
} }