Skip to content

Commit

Permalink
improve get-ip for getting failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr.Jos committed Nov 29, 2020
1 parent 3311e9b commit d494df3
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions namesilo_ddns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fi
declare -g IP_ADDR_V4 IP_ADDR_V6 INV_HOSTS RECORDS FUNC_RETURN
declare -g P_IPV4 P_IPV6 P_FORCE_UPDATE P_FORCE_FETCH
declare -g PROJECT COPYRIGHT LICENSE HELP
PROJECT="Namesilo DDNS without dependences v2.3 (2020.11.20)"
PROJECT="Namesilo DDNS without dependences v2.4 (2020.11.29)"
COPYRIGHT="Copyright (c) 2020 Mr.Jos"
LICENSE="MIT License: <https://opensource.org/licenses/MIT>"
HELP="Usage: namesilo_ddns.sh <command> ... [parameters ...]
Expand Down Expand Up @@ -285,16 +285,15 @@ function get_ip()
done
fi

if [[ $ARG == "-4" ]]; then
if [[ ${RES:=NULL} != "NULL" && $RES != ${IP_ADDR_V4:-NULL} ]]; then
echo "IPv4 address changed to {$RES}" >> $LOG
fi
IP_ADDR_V4=$RES
else
if [[ ${RES:=NULL} != "NULL" && $RES != ${IP_ADDR_V6:-NULL} ]]; then
echo "IPv6 address changed to {$RES}" >> $LOG
fi
IP_ADDR_V6=$RES
if [[ ${RES:=NULL} == "NULL" ]]; then
## if ip-getting failed, cached ip will be applicated
return
elif [[ $ARG == "-4" && $RES != ${IP_ADDR_V4:-NULL} ]]; then
echo "IPv4 address changed to {$RES}" >> $LOG
IP_ADDR_V4="$RES"
elif [[ $ARG == "-6" && $RES != ${IP_ADDR_V6:-NULL} ]]; then
echo "IPv6 address changed to {$RES}" >> $LOG
IP_ADDR_V6="$RES"
fi
}

Expand Down

0 comments on commit d494df3

Please sign in to comment.