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
This commit is contained in:
parent
cd6c4334db
commit
d8b58a10b9
4
neofetch
4
neofetch
|
@ -3807,12 +3807,12 @@ get_local_ip() {
|
||||||
}
|
}
|
||||||
|
|
||||||
get_public_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="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com)"
|
||||||
[[ "$public_ip" =~ ^\; ]] && unset public_ip
|
[[ "$public_ip" =~ ^\; ]] && unset public_ip
|
||||||
fi
|
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 | \
|
public_ip="$(drill myip.opendns.com @resolver1.opendns.com | \
|
||||||
awk '/^myip\./ && $3 == "IN" {print $5}')"
|
awk '/^myip\./ && $3 == "IN" {print $5}')"
|
||||||
fi
|
fi
|
||||||
|
|
Reference in New Issue