Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddns-scripts: Update dnspod.cn-v3 #25748

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion net/ddns-scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=ddns-scripts
PKG_VERSION:=2.8.2
PKG_RELEASE:=56
PKG_RELEASE:=58

PKG_LICENSE:=GPL-2.0

Expand Down
28 changes: 18 additions & 10 deletions net/ddns-scripts/files/usr/lib/ddns/update_dnspod_cn_v3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
# - at: net/ddns-scripts/files/usr/lib/ddns/update_cloudflare_com_v4.sh
# - github.com/nixonli/ddns-scripts_dnspod for "update_dnspod_cn.sh"
#
# v1.2.0:
# - Migrate retry_count to retry_max_count
# - Fix signature expiration during retries
# v1.1.0: Publish script
#
# 2024 FriesI23 <[email protected]>
#
# API documentation at https://cloud.tencent.com/document/api/1427/84627
Expand Down Expand Up @@ -42,6 +47,11 @@ local __URLHOST="dnspod.tencentcloudapi.com"
local __URLBASE="https://$__URLHOST"
local __METHOD="POST"
local __CONTENT_TYPE="application/json"
local __RETRY_COUNT=${retry_count:-$retry_max_count}

# Build base command to use
local __PRGBASE="$CURL -RsS -o $DATFILE --stderr $ERRFILE"
local __PRGEXTA=""

# split __HOST __DOMAIN from $domain
# given data:
Expand All @@ -58,6 +68,7 @@ tencentcloud_transfer() {
local __ERR __CODE

while :; do
__RUNPROG="$__PRGBASE $($__PRGEXTA)"
write_log 7 "#> $__RUNPROG"
eval "$__RUNPROG"
__ERR=$? # save communication error
Expand All @@ -83,11 +94,11 @@ tencentcloud_transfer() {
}

__CNT=$(($__CNT + 1)) # increment error counter
# if error count > retry_count leave here
[ $retry_count -gt 0 -a $__CNT -gt $retry_count ] &&
write_log 14 "Transfer failed after $retry_count retries"
# if error count > __RETRY_COUNT leave here
[ $__RETRY_COUNT -gt 0 -a $__CNT -gt $__RETRY_COUNT ] &&
write_log 14 "Transfer failed after $__RETRY_COUNT retries"

write_log 4 "Transfer failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
write_log 4 "Transfer failed - retry $__CNT/$__RETRY_COUNT in $RETRY_SECONDS seconds"
sleep $RETRY_SECONDS &
PID_SLEEP=$!
wait $PID_SLEEP # enable trap-handler
Expand All @@ -106,9 +117,6 @@ tencentcloud_transfer() {
return 0
}

# Build base command to use
__PRGBASE="$CURL -RsS -o $DATFILE --stderr $ERRFILE"

# force network/interface-device to use for communication
if [ -n "$bind_network" ]; then
local __DEVICE
Expand Down Expand Up @@ -298,7 +306,7 @@ if [ -n "$record_id" ]; then
__RECID="$record_id"
else
# read record id for A or AAAA record of host.domain.TLD
__RUNPROG="$__PRGBASE $(build_describe_record_list_request_param)"
__PRGEXTA="build_describe_record_list_request_param"
# extract zone id
tencentcloud_transfer || return 1
__RECID=$(grep -o '"RecordId":[[:space:]]*[0-9]*' $DATFILE | grep -o '[0-9]*' | head -1)
Expand Down Expand Up @@ -335,11 +343,11 @@ __DATA=$(grep -o '"Value":\s*"[^"]*' $DATFILE | grep -o '[^"]*$' | head -1)

if [ -z "$__RECID" ]; then
# create new record if record id not found
__RUNPROG="$__PRGBASE $(build_create_record_request_param $__IP $__RECLINE)"
__PRGEXTA="build_create_record_request_param $__IP $__RECLINE"
tencentcloud_transfer || return 1
return 0
fi

__RUNPROG="$__PRGBASE $(build_modify_record_request_param $__IP $__RECLINE $__RECID)"
__PRGEXTA="build_modify_record_request_param $__IP $__RECLINE $__RECID"
tencentcloud_transfer || return 1
return
Loading