From d494df33ebd524964cc96a34d930ef6526826093 Mon Sep 17 00:00:00 2001 From: "Mr.Jos" Date: Sun, 29 Nov 2020 10:40:12 +0800 Subject: [PATCH] improve get-ip for getting failed --- namesilo_ddns.sh | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/namesilo_ddns.sh b/namesilo_ddns.sh index 1f977d8..bda20cd 100644 --- a/namesilo_ddns.sh +++ b/namesilo_ddns.sh @@ -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: " HELP="Usage: namesilo_ddns.sh ... [parameters ...] @@ -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 }