Browse Source

ddns-scripts: fixes for cloudflare v4

- update_cloudflare_com_v4.sh: enclose urls in single quotes
- dynamic_dns_functions.sh: force to return only one ip, if using nslookup to get registered ip

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
lilik-openwrt-22.03
Christian Schoenebeck 8 years ago
parent
commit
b6377ba8db
3 changed files with 7 additions and 7 deletions
  1. +1
    -1
      net/ddns-scripts/Makefile
  2. +3
    -3
      net/ddns-scripts/files/dynamic_dns_functions.sh
  3. +3
    -3
      net/ddns-scripts/files/update_cloudflare_com_v4.sh

+ 1
- 1
net/ddns-scripts/Makefile View File

@ -12,7 +12,7 @@ PKG_NAME:=ddns-scripts
PKG_VERSION:=2.7.6 PKG_VERSION:=2.7.6
# Release == build # Release == build
# increase on changes of services files or tld_names.dat # increase on changes of services files or tld_names.dat
PKG_RELEASE:=5
PKG_RELEASE:=6
PKG_LICENSE:=GPL-2.0 PKG_LICENSE:=GPL-2.0
PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com> PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com>


+ 3
- 3
net/ddns-scripts/files/dynamic_dns_functions.sh View File

@ -1123,7 +1123,7 @@ get_registered_ip() {
else else
if [ -n "$BIND_HOST" ]; then if [ -n "$BIND_HOST" ]; then
if [ $is_glue -eq 1 ]; then if [ $is_glue -eq 1 ]; then
__DATA=$(cat $DATFILE | grep "^$lookup_host" | grep -m 1 -o "$__REGEX" )
__DATA=$(cat $DATFILE | grep "^$lookup_host" | grep -om1 "$__REGEX" )
else else
__DATA=$(cat $DATFILE | awk -F "address " '/has/ {print $2; exit}' ) __DATA=$(cat $DATFILE | awk -F "address " '/has/ {print $2; exit}' )
fi fi
@ -1132,9 +1132,9 @@ get_registered_ip() {
elif [ -n "$DRILL" ]; then elif [ -n "$DRILL" ]; then
__DATA=$(cat $DATFILE | awk '/^'"$lookup_host"'/ {print $5; exit}' ) __DATA=$(cat $DATFILE | awk '/^'"$lookup_host"'/ {print $5; exit}' )
elif [ -n "$HOSTIP" ]; then elif [ -n "$HOSTIP" ]; then
__DATA=$(cat $DATFILE | grep -m 1 -o "$__REGEX")
__DATA=$(cat $DATFILE | grep -om1 "$__REGEX")
elif [ -n "$NSLOOKUP" ]; then elif [ -n "$NSLOOKUP" ]; then
__DATA=$(cat $DATFILE | sed -ne "/^Name:/,\$ { s/^Address[0-9 ]\{0,\}: \($__REGEX\).*$/\\1/p }" )
__DATA=$(cat $DATFILE | sed -e '1,/Name:/d' | grep -om1 "$__REGEX" )
fi fi
[ -n "$__DATA" ] && { [ -n "$__DATA" ] && {
write_log 7 "Registered IP '$__DATA' detected" write_log 7 "Registered IP '$__DATA' detected"


+ 3
- 3
net/ddns-scripts/files/update_cloudflare_com_v4.sh View File

@ -118,7 +118,7 @@ __PRGBASE="$__PRGBASE --header 'Content-Type: application/json' "
# __PRGBASE="$__PRGBASE --header 'Accept: application/json' " # __PRGBASE="$__PRGBASE --header 'Accept: application/json' "
# read zone id for registered domain.TLD # read zone id for registered domain.TLD
__RUNPROG="$__PRGBASE --request GET $__URLBASE/zones?name=$__DOMAIN"
__RUNPROG="$__PRGBASE --request GET '$__URLBASE/zones?name=$__DOMAIN'"
cloudflare_transfer || return 1 cloudflare_transfer || return 1
# extract zone id # extract zone id
__ZONEID=$(grep -o '"id":"[^"]*' $DATFILE | grep -o '[^"]*$' | head -1) __ZONEID=$(grep -o '"id":"[^"]*' $DATFILE | grep -o '[^"]*$' | head -1)
@ -128,7 +128,7 @@ __ZONEID=$(grep -o '"id":"[^"]*' $DATFILE | grep -o '[^"]*$' | head -1)
} }
# read record id for A or AAAA record of host.domain.TLD # read record id for A or AAAA record of host.domain.TLD
__RUNPROG="$__PRGBASE --request GET $__URLBASE/zones/$__ZONEID/dns_records?name=$__HOST&type=$__TYPE"
__RUNPROG="$__PRGBASE --request GET '$__URLBASE/zones/$__ZONEID/dns_records?name=$__HOST&type=$__TYPE'"
cloudflare_transfer || return 1 cloudflare_transfer || return 1
# extract record id # extract record id
__RECID=$(grep -o '"id":"[^"]*' $DATFILE | grep -o '[^"]*$' | head -1) __RECID=$(grep -o '"id":"[^"]*' $DATFILE | grep -o '[^"]*$' | head -1)
@ -171,7 +171,7 @@ cat > $DATFILE << EOF
EOF EOF
# let's complete transfer command # let's complete transfer command
__RUNPROG="$__PRGBASE --request PUT --data @$DATFILE $__URLBASE/zones/$__ZONEID/dns_records/$__RECID"
__RUNPROG="$__PRGBASE --request PUT --data @$DATFILE '$__URLBASE/zones/$__ZONEID/dns_records/$__RECID'"
cloudflare_transfer || return 1 cloudflare_transfer || return 1
return 0 return 0


Loading…
Cancel
Save