From 0a98b6d0eddb81b1997572f47deaaebb63a4c796 Mon Sep 17 00:00:00 2001 From: Gedalya Nie Date: Thu, 9 Jan 2025 05:58:02 +0800 Subject: [PATCH] ddns-scripts: cloudflare: use PATCH method, minimize changes Using the PUT method recreates the DNS record with and only with the newly provided data. This seems unnecessary. In particular, we don't need to hardcode a TTL of 120. Any existing comment would be lost too. The only detail we need to change is the IP address. Leave everything else as it was. Signed-off-by: Gedalya Nie --- net/ddns-scripts/Makefile | 2 +- .../files/usr/lib/ddns/update_cloudflare_com_v4.sh | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/net/ddns-scripts/Makefile b/net/ddns-scripts/Makefile index ccbddd7624..55db7fb635 100644 --- a/net/ddns-scripts/Makefile +++ b/net/ddns-scripts/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ddns-scripts PKG_VERSION:=2.8.2 -PKG_RELEASE:=55 +PKG_RELEASE:=56 PKG_LICENSE:=GPL-2.0 diff --git a/net/ddns-scripts/files/usr/lib/ddns/update_cloudflare_com_v4.sh b/net/ddns-scripts/files/usr/lib/ddns/update_cloudflare_com_v4.sh index 4fb3a0dd6b..f9f6876a1e 100644 --- a/net/ddns-scripts/files/usr/lib/ddns/update_cloudflare_com_v4.sh +++ b/net/ddns-scripts/files/usr/lib/ddns/update_cloudflare_com_v4.sh @@ -27,9 +27,8 @@ [ $use_https -eq 0 ] && use_https=1 # force HTTPS # used variables -local __HOST __DOMAIN __TYPE __URLBASE __PRGBASE __RUNPROG __DATA __IPV6 __ZONEID __RECID __PROXIED +local __HOST __DOMAIN __TYPE __URLBASE __PRGBASE __RUNPROG __DATA __IPV6 __ZONEID __RECID local __URLBASE="https://api.cloudflare.com/client/v4" -local __TTL=120 # split __HOST __DOMAIN from $domain # given data: @@ -186,16 +185,14 @@ __DATA=$(grep -o '"content":\s*"[^"]*' $DATFILE | grep -o '[^"]*$' | head -1) # update is needed # let's build data to send -# set proxied parameter -__PROXIED=$(grep -o '"proxied":\s*[^",]*' $DATFILE | grep -o '[^:]*$') # use file to work around " needed for json cat > $DATFILE << EOF -{"id":"$__ZONEID","type":"$__TYPE","name":"$__HOST","content":"$__IP","ttl":$__TTL,"proxied":$__PROXIED} +{"content":"$__IP"} EOF # let's complete transfer command -__RUNPROG="$__PRGBASE --request PUT --data @$DATFILE '$__URLBASE/zones/$__ZONEID/dns_records/$__RECID'" +__RUNPROG="$__PRGBASE --request PATCH --data @$DATFILE '$__URLBASE/zones/$__ZONEID/dns_records/$__RECID'" cloudflare_transfer || return 1 return 0 -- 2.30.2