aboutsummaryrefslogtreecommitdiff
path: root/net/ddns-scripts/files/usr/lib
diff options
context:
space:
mode:
authorGlen Huang <heyhgl@gmail.com>2022-01-09 13:02:58 +0800
committerGlen Huang <heyhgl@gmail.com>2022-01-10 20:44:40 +0800
commit78ef7d7379eb0fb6f4065b2087a8b45aeac0ce9a (patch)
tree11c809aa6b3caaa1ae01d9bb64e429038022823a /net/ddns-scripts/files/usr/lib
parente7547d980d21646009a3492b09c57ea62ffe0f22 (diff)
ddns-scripts-cloudflare: allow explicit zone_id
When zone id is explicitly provided, there is no need for the API token to have read permission. Inspired by acme.sh's cloudflare logic. Signed-off-by: Glen Huang <heyhgl@gmail.com>
Diffstat (limited to 'net/ddns-scripts/files/usr/lib')
-rw-r--r--net/ddns-scripts/files/usr/lib/ddns/update_cloudflare_com_v4.sh24
1 files changed, 14 insertions, 10 deletions
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 c5bbe1799..82ea417da 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
@@ -15,7 +15,7 @@
# option password - cloudflare api key, you can get it from cloudflare.com/my-account/
# option domain - "hostname@yourdomain.TLD" # syntax changed to remove split_FQDN() function and tld_names.dat.gz
#
-# The proxy status would not be changed by this script. Please change it in Cloudflare dashboard manually.
+# The proxy status would not be changed by this script. Please change it in Cloudflare dashboard manually.
#
# variable __IP already defined with the ip-address to use for update
#
@@ -134,15 +134,19 @@ else
fi
__PRGBASE="$__PRGBASE --header 'Content-Type: application/json' "
-# read zone id for registered domain.TLD
-__RUNPROG="$__PRGBASE --request GET '$__URLBASE/zones?name=$__DOMAIN'"
-cloudflare_transfer || return 1
-# extract zone id
-__ZONEID=$(grep -o '"id":\s*"[^"]*' $DATFILE | grep -o '[^"]*$' | head -1)
-[ -z "$__ZONEID" ] && {
- write_log 4 "Could not detect 'zone id' for domain.tld: '$__DOMAIN'"
- return 127
-}
+if [ -n "$zone_id"]; then
+ __ZONEID="$zone_id"
+else
+ # read zone id for registered domain.TLD
+ __RUNPROG="$__PRGBASE --request GET '$__URLBASE/zones?name=$__DOMAIN'"
+ cloudflare_transfer || return 1
+ # extract zone id
+ __ZONEID=$(grep -o '"id":\s*"[^"]*' $DATFILE | grep -o '[^"]*$' | head -1)
+ [ -z "$__ZONEID" ] && {
+ write_log 4 "Could not detect 'zone id' for domain.tld: '$__DOMAIN'"
+ return 127
+ }
+fi
# 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'"