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:
Paróczai Olivér 2021-06-11 06:55:35 +02:00 committed by GitHub
parent cd6c4334db
commit d8b58a10b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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