Supplying of both -6 and --ip=one results in picking an IPv6 address

... previously it depended on the order of DNS replies otherwise. This was
one outcome of discussion in #1026 where it seemed more logical
to pick an IPv6 address as opposed to an abitrary (v4/v6) address.
This commit is contained in:
Dirk
2018-08-16 12:03:56 +02:00
parent efa56a34f2
commit 5837e82c85
4 changed files with 15 additions and 12 deletions

View File

@ -16023,9 +16023,12 @@ determine_ip_addresses() {
if [[ -n "$CMDLINE_IP" ]]; then
# command line has supplied an IP address or "one"
if [[ "$CMDLINE_IP" == one ]]; then
# use first IPv4 or IPv6 address
CMDLINE_IP="$(head -1 <<< "$ip4")"
[[ -z "$CMDLINE_IP" ]] && CMDLINE_IP="$(head -1 <<< "$ip6")"
# use first IPv6 or IPv4 address
if "$HAS_IPv6" && [[ -n "$ip6" ]]; then
CMDLINE_IP="$(head -1 <<< "$ip6")"
else
CMDLINE_IP="$(head -1 <<< "$ip4")"
fi
fi
NODEIP="$CMDLINE_IP"
if is_ipv4addr "$NODEIP"; then
@ -16382,14 +16385,14 @@ display_rdns_etc() {
outln "$(out_row_aligned_max_width "$further_ip_addrs" " $CORRECT_SPACES" $TERM_WIDTH)"
fi
if "$LOCAL_A"; then
outln " A record via $CORRECT_SPACES /etc/hosts "
outln " A record via: $CORRECT_SPACES /etc/hosts "
elif "$LOCAL_AAAA"; then
outln " AAAA record via $CORRECT_SPACES /etc/hosts "
outln " AAAA record via: $CORRECT_SPACES /etc/hosts "
elif [[ -n "$CMDLINE_IP" ]]; then
if is_ipv6addr $"$CMDLINE_IP"; then
outln " AAAA record via $CORRECT_SPACES supplied IP \"$CMDLINE_IP\""
outln " AAAA record via: $CORRECT_SPACES supplied IP \"$CMDLINE_IP\""
else
outln " A record via $CORRECT_SPACES supplied IP \"$CMDLINE_IP\""
outln " A record via: $CORRECT_SPACES supplied IP \"$CMDLINE_IP\""
fi
fi
if [[ "$rDNS" =~ instructed ]]; then