@@ -22385,24 +22385,20 @@ determine_ip_addresses() {
2238522385
2238622386 # first, try to get IP addresses from /etc/hosts
2238722387 # Local_A[AAA] is for our UI
22388+
2238822389 ip4=$(get_local_a "$NODE")
22390+ ip6=$(get_local_aaaa "$NODE")
22391+
2238922392 if [[ -n "$ip4" ]]; then
2239022393 LOCAL_A=true
2239122394 else
2239222395 ip4="$(get_a_record "$NODE")"
2239322396 fi
22394- ip6=$(get_local_aaaa "$NODE")
2239522397 if [[ -n "$ip6" ]]; then
2239622398 LOCAL_AAAA=true
2239722399 else
2239822400 ip6=$(get_aaaa_record "$NODE")
2239922401 fi
22400- IPADDRs2SHOW=$(newline_to_spaces "$ip4 $ip6")
22401-
22402- if [[ -n "$ip6" ]]; then
22403- # sets IPv6_OK
22404- shouldwedo_ipv6 $(head -1 <<< "$ip6")
22405- fi
2240622402
2240722403 if [[ -n "$CMDLINE_IP" ]]; then
2240822404 # command line has supplied an IP address or "one"
@@ -22436,6 +22432,13 @@ determine_ip_addresses() {
2243622432 fi
2243722433 IPADDRs2SHOW=$(newline_to_spaces "$ip4 $ip6")
2243822434
22435+ # If $ip4 was empty, remove the leading blank
22436+ [[ ${IPADDRs2SHOW:0:1} == \ ]] && IPADDRs2SHOW=${IPADDRs2SHOW:1}
22437+ if [[ -n "$ip6" ]]; then
22438+ # sets IPv6_OK
22439+ shouldwedo_ipv6 $(head -1 <<< "$ip6")
22440+ fi
22441+
2243922442 if "$do_ipv4_only"; then
2244022443 if [[ -z "$ip4" ]]; then
2244122444 fatal_cmd_line "No IPv4 addresses available, but IPv4-only scan requested" $ERR_CMDLINE
@@ -22456,13 +22459,29 @@ determine_ip_addresses() {
2245622459 [[ -z $IPADDRs2CHECK ]] && IPADDRs2CHECK="${addr}" || IPADDRs2CHECK="${IPADDRs2CHECK} ${addr}"
2245722460 done
2245822461 fi
22459- # If scanning IPV6 doesn't work, put the address to show in round brackets to
22462+ # If scanning IPv6 doesn't work, put the address to show in round brackets to
2246022463 # signal the user / UI that those won't be scanned. We don't do that for IPv4, yet
2246122464 for addr in $IPADDRs2SHOW; do
2246222465 if is_ipv6addr $addr && ! "$IPv6_OK" ; then
2246322466 IPADDRs2SHOW=${IPADDRs2SHOW/$addr/($addr)}
2246422467 fi
2246522468 done
22469+ if [[ -z "$IPADDRs2CHECK" ]]; then
22470+ fatal_cmd_line "No IP address can be used" $ERR_RESOURCE
22471+ fi
22472+
22473+ # (Loose) check whether we have IPv6/IPv4 addresses to check and set the do_* variables correctly
22474+ # so that the output "Testing all IP** addresses" is correct
22475+ if [[ "$IPADDRs2CHECK" =~ ^([0-9a-fA-F]{1,4}:){1,7}[0-9a-fA-F]{1,4} ]]; then
22476+ if ! [[ "$IPADDRs2CHECK" =~ ^[0-9]{1,3}.[0-9]{1,3}.[0-9].{1,3}[0-9]{1,3}$ ]]; then
22477+ do_ipv6_only=true
22478+ fi
22479+ elif [[ "$IPADDRs2CHECK" =~ ^[0-9]{1,3}.[0-9]{1,3}.[0-9].{1,3}[0-9]{1,3}$ ]]; then
22480+ if ! [[ "$IPADDRs2CHECK" =~ ([0-9a-fA-F]{1,4}:){1,7}[0-9a-fA-F]{1,4} ]]; then
22481+ do_ipv4_only=true
22482+ fi
22483+ fi
22484+
2246622485 return 0
2246722486}
2246822487
0 commit comments