mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-15 03:49:20 +02:00
Prefer ipv4 to resolve hostnames
This commit is contained in:
@@ -121,22 +121,22 @@ _resolve_hostname() {
|
|||||||
local -a ipv4_candidates=()
|
local -a ipv4_candidates=()
|
||||||
local -a ipv6_candidates=()
|
local -a ipv6_candidates=()
|
||||||
|
|
||||||
# Resolve hostname to IPv6
|
|
||||||
mapfile -t ipv6_candidates < <(getent ahostsv6 "${hostname}" | awk '{print $1}' | uniq)
|
|
||||||
|
|
||||||
# Resolve hostname to IPv4
|
# Resolve hostname to IPv4
|
||||||
mapfile -t ipv4_candidates < <(getent ahostsv4 "${hostname}" | awk '{print $1}' | uniq)
|
mapfile -t ipv4_candidates < <(getent ahostsv4 "${hostname}" | awk '{print $1}' | uniq)
|
||||||
|
|
||||||
if [ ${#ipv6_candidates[@]} -gt 0 ]; then
|
# Resolve hostname to IPv6
|
||||||
bashio::log.debug "Resolved ${hostname} to ${ipv6_candidates[@]}"
|
mapfile -t ipv6_candidates < <(getent ahostsv6 "${hostname}" | awk '{print $1}' | uniq)
|
||||||
ips+=("${ipv6_candidates[@]}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${#ipv4_candidates[@]} -gt 0 ]; then
|
if [ ${#ipv4_candidates[@]} -gt 0 ]; then
|
||||||
bashio::log.debug "Resolved ${hostname} to ${ipv4_candidates[@]}"
|
bashio::log.debug "Resolved ${hostname} to ${ipv4_candidates[@]}"
|
||||||
ips+=("${ipv4_candidates[@]}")
|
ips+=("${ipv4_candidates[@]}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ${#ipv6_candidates[@]} -gt 0 ]; then
|
||||||
|
bashio::log.debug "Resolved ${hostname} to ${ipv6_candidates[@]}"
|
||||||
|
ips+=("${ipv6_candidates[@]}")
|
||||||
|
fi
|
||||||
|
|
||||||
echo "${ips[@]}"
|
echo "${ips[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user