improve ip check logic

This commit is contained in:
Molly Lau 2023-04-05 21:22:49 +09:00 committed by GitHub
parent bd4311b5fa
commit 23a4e61579
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,13 +82,9 @@ if [[ `echo "$IPv6" | grep -i '[[:xdigit:]]' | grep ':'` ]] && [[ "$IP6_Hex_Num"
IP6_Check="isIPv6"
fi
if [[ "${IP6_Check}" != "isIPv6" ]] && [[ -z ${IPv6} ]]; then
IPv6="N/A"
fi
[[ "${IP6_Check}" != "isIPv6" ]] && IPv6="N/A"
if [[ "${IP_Check}" != "isIPv4" ]] && [[ -z ${IPv4} ]]; then
IPv4="N/A"
fi
[[ "${IP_Check}" != "isIPv4" ]] && IPv4="N/A"
if [[ "${localip}" == "${IPv4}" ]] || [[ "${localip}" == "${IPv6}" ]]; then
# localip=`ip -o a show | grep -w "lo" | grep -w "inet" | cut -d ' ' -f7 | awk '{split($1, a, "/"); print $2 "" a[1]}'`