Skip to content

Commit

Permalink
refactor(ali): set API endpoint for each action
Browse files Browse the repository at this point in the history
  • Loading branch information
PMExtra committed Sep 19, 2024
1 parent fca6e9b commit 610bb2b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions deploy/ali_cdn.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env sh
# shellcheck disable=SC2034,SC2154

# Script to create certificate to Alibaba Cloud CDN
#
Expand All @@ -23,8 +24,7 @@ if ! . "$dnsapi_ali"; then
return 1
fi

# shellcheck disable=SC2034
Ali_API="https://cdn.aliyuncs.com/"
Ali_CDN_API="https://cdn.aliyuncs.com/"

ali_cdn_deploy() {
_cdomain="$1"
Expand Down Expand Up @@ -66,9 +66,9 @@ ali_cdn_deploy() {
return 0
}

# shellcheck disable=SC2154
# domain pub pri
_set_cdn_domain_ssl_certificate_query() {
endpoint=$Ali_CDN_API
query=''
query=$query'AccessKeyId='$Ali_Key
query=$query'&Action=SetCdnDomainSSLCertificate'
Expand Down
8 changes: 6 additions & 2 deletions dnsapi/dns_ali.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Options:
# https://github.com/acmesh-official/acme.sh/pull/5205#issuecomment-2357867276
# Be careful when modifying this file, especially when making breaking changes for common functions

Ali_API="https://alidns.aliyuncs.com/"
Ali_DNS_API="https://alidns.aliyuncs.com/"

#Usage: dns_ali_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_ali_add() {
Expand Down Expand Up @@ -71,7 +71,7 @@ _ali_rest() {

signature=$(printf "%s" "$mtd&%2F&$(printf "%s" "$query" | _url_encode upper-hex)" | _hmac "sha1" "$(printf "%s" "$Ali_Secret&" | _hex_dump | tr -d " ")" | _base64)
signature=$(printf "%s" "$signature" | _url_encode upper-hex)
url="$Ali_API?Signature=$signature"
url="$endpoint?Signature=$signature"

if [ "$mtd" = "GET" ]; then
url="$url&$query"
Expand Down Expand Up @@ -140,6 +140,7 @@ _get_root() {
_check_exist_query() {
_qdomain="$1"
_qsubdomain="$2"
endpoint=$Ali_DNS_API
query=''
query=$query'AccessKeyId='$Ali_Key
query=$query'&Action=DescribeDomainRecords'
Expand All @@ -155,6 +156,7 @@ _check_exist_query() {
}

_add_record_query() {
endpoint=$Ali_DNS_API
query=''
query=$query'AccessKeyId='$Ali_Key
query=$query'&Action=AddDomainRecord'
Expand All @@ -171,6 +173,7 @@ _add_record_query() {
}

_delete_record_query() {
endpoint=$Ali_DNS_API
query=''
query=$query'AccessKeyId='$Ali_Key
query=$query'&Action=DeleteDomainRecord'
Expand All @@ -184,6 +187,7 @@ _delete_record_query() {
}

_describe_records_query() {
endpoint=$Ali_DNS_API
query=''
query=$query'AccessKeyId='$Ali_Key
query=$query'&Action=DescribeDomainRecords'
Expand Down

0 comments on commit 610bb2b

Please sign in to comment.