ddns-scripts: fixes for nslookup and khost
authorChristian Schoenebeck <christian.schoenebeck@gmail.com>
Wed, 11 Jan 2017 21:08:42 +0000 (22:08 +0100)
committerChristian Schoenebeck <christian.schoenebeck@gmail.com>
Wed, 11 Jan 2017 21:08:42 +0000 (22:08 +0100)
- fix ip extraction if knot host is used together with glue records
- fix ip extraction from nslookup if reverse dns record has ip with dot reported at http://forum.lede-project.org/t/ddns-scripts-error/909

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
net/ddns-scripts/Makefile
net/ddns-scripts/files/dynamic_dns_functions.sh

index 1c5031d3b710a27300ddb4af4eb061f0e297256e..c57c9f326f855bc64f74e46cdc070edda54eeba1 100755 (executable)
@@ -12,7 +12,7 @@ PKG_NAME:=ddns-scripts
 PKG_VERSION:=2.7.6
 # Release == build
 # increase on changes of services files or tld_names.dat
-PKG_RELEASE:=10
+PKG_RELEASE:=11
 
 PKG_LICENSE:=GPL-2.0
 PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com>
index a8bd543fab1781db7e1d11154d67a2c2423834fb..001dfa4e634e6cb9972f2184ca82a4392ef42e70 100755 (executable)
@@ -1121,20 +1121,18 @@ get_registered_ip() {
                        write_log 3 "$__PROG error: '$__ERR'"
                        write_log 7 "$(cat $ERRFILE)"
                else
-                       if [ -n "$BIND_HOST" ]; then
+                       if [ -n "$BIND_HOST" -o -n "$KNOT_HOST" ]; then
                                if [ $is_glue -eq 1 ]; then
                                        __DATA=$(cat $DATFILE | grep "^$lookup_host" | grep -om1 "$__REGEX" )
                                else
                                        __DATA=$(cat $DATFILE | awk -F "address " '/has/ {print $2; exit}' )
                                fi
-                       elif [ -n "$KNOT_HOST" ]; then
-                               __DATA=$(cat $DATFILE | awk -F "address " '/has/ {print $2; exit}' )
                        elif [ -n "$DRILL" ]; then
                                __DATA=$(cat $DATFILE | awk '/^'"$lookup_host"'/ {print $5; exit}' )
                        elif [ -n "$HOSTIP" ]; then
                                __DATA=$(cat $DATFILE | grep -om1 "$__REGEX")
                        elif [ -n "$NSLOOKUP" ]; then
-                               __DATA=$(cat $DATFILE | sed -e '1,/Name:/d' | grep -om1 "$__REGEX" )
+                               __DATA=$(cat $DATFILE | sed -ne "/^Name:/,\$ { s/^Address[0-9 ]\{0,\}: \($__REGEX\).*$/\\1/p }" )
                        fi
                        [ -n "$__DATA" ] && {
                                write_log 7 "Registered IP '$__DATA' detected"