mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-24 14:11:42 +00:00
Merge pull request #1291 from ClouDNS/master
Update dns api to support v2 wildcard cert #1261
This commit is contained in:
commit
f92fae7625
@ -26,30 +26,18 @@ dns_cloudns_add() {
|
|||||||
|
|
||||||
host="$(echo "$1" | sed "s/\.$zone\$//")"
|
host="$(echo "$1" | sed "s/\.$zone\$//")"
|
||||||
record=$2
|
record=$2
|
||||||
record_id=$(_dns_cloudns_get_record_id "$zone" "$host")
|
|
||||||
|
|
||||||
_debug zone "$zone"
|
_debug zone "$zone"
|
||||||
_debug host "$host"
|
_debug host "$host"
|
||||||
_debug record "$record"
|
_debug record "$record"
|
||||||
_debug record_id "$record_id"
|
|
||||||
|
|
||||||
if [ -z "$record_id" ]; then
|
_info "Adding the TXT record for $1"
|
||||||
_info "Adding the TXT record for $1"
|
_dns_cloudns_http_api_call "dns/add-record.json" "domain-name=$zone&record-type=TXT&host=$host&record=$record&ttl=60"
|
||||||
_dns_cloudns_http_api_call "dns/add-record.json" "domain-name=$zone&record-type=TXT&host=$host&record=$record&ttl=60"
|
if ! _contains "$response" "\"status\":\"Success\""; then
|
||||||
if ! _contains "$response" "\"status\":\"Success\""; then
|
_err "Record cannot be added."
|
||||||
_err "Record cannot be added."
|
return 1
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_info "Added."
|
|
||||||
else
|
|
||||||
_info "Updating the TXT record for $1"
|
|
||||||
_dns_cloudns_http_api_call "dns/mod-record.json" "domain-name=$zone&record-id=$record_id&record-type=TXT&host=$host&record=$record&ttl=60"
|
|
||||||
if ! _contains "$response" "\"status\":\"Success\""; then
|
|
||||||
_err "The TXT record for $1 cannot be updated."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_info "Updated."
|
|
||||||
fi
|
fi
|
||||||
|
_info "Added."
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -72,22 +60,32 @@ dns_cloudns_rm() {
|
|||||||
|
|
||||||
host="$(echo "$1" | sed "s/\.$zone\$//")"
|
host="$(echo "$1" | sed "s/\.$zone\$//")"
|
||||||
record=$2
|
record=$2
|
||||||
record_id=$(_dns_cloudns_get_record_id "$zone" "$host")
|
|
||||||
|
|
||||||
_debug zone "$zone"
|
_dns_cloudns_http_api_call "dns/records.json" "domain-name=$zone&host=$host&type=TXT"
|
||||||
_debug host "$host"
|
if ! _contains "$response" "\"id\":"; then
|
||||||
_debug record "$record"
|
return 1
|
||||||
_debug record_id "$record_id"
|
|
||||||
|
|
||||||
if [ ! -z "$record_id" ]; then
|
|
||||||
_info "Deleting the TXT record for $1"
|
|
||||||
_dns_cloudns_http_api_call "dns/delete-record.json" "domain-name=$zone&record-id=$record_id"
|
|
||||||
if ! _contains "$response" "\"status\":\"Success\""; then
|
|
||||||
_err "The TXT record for $1 cannot be deleted."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_info "Deleted."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for i in $(echo "$response" | tr '{' "\n" | grep "$record"); do
|
||||||
|
record_id=$(echo "$i" | tr ',' "\n" | grep -E '^"id"' | sed -re 's/^\"id\"\:\"([0-9]+)\"$/\1/g')
|
||||||
|
|
||||||
|
if [ ! -z "$record_id" ]; then
|
||||||
|
_debug zone "$zone"
|
||||||
|
_debug host "$host"
|
||||||
|
_debug record "$record"
|
||||||
|
_debug record_id "$record_id"
|
||||||
|
|
||||||
|
_info "Deleting the TXT record for $1"
|
||||||
|
_dns_cloudns_http_api_call "dns/delete-record.json" "domain-name=$zone&record-id=$record_id"
|
||||||
|
|
||||||
|
if ! _contains "$response" "\"status\":\"Success\""; then
|
||||||
|
_err "The TXT record for $1 cannot be deleted."
|
||||||
|
else
|
||||||
|
_info "Deleted."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +124,7 @@ _dns_cloudns_init_check() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#save the api id and password to the account conf file.
|
# save the api id and password to the account conf file.
|
||||||
_saveaccountconf_mutable CLOUDNS_AUTH_ID "$CLOUDNS_AUTH_ID"
|
_saveaccountconf_mutable CLOUDNS_AUTH_ID "$CLOUDNS_AUTH_ID"
|
||||||
_saveaccountconf_mutable CLOUDNS_SUB_AUTH_ID "$CLOUDNS_SUB_AUTH_ID"
|
_saveaccountconf_mutable CLOUDNS_SUB_AUTH_ID "$CLOUDNS_SUB_AUTH_ID"
|
||||||
_saveaccountconf_mutable CLOUDNS_AUTH_PASSWORD "$CLOUDNS_AUTH_PASSWORD"
|
_saveaccountconf_mutable CLOUDNS_AUTH_PASSWORD "$CLOUDNS_AUTH_PASSWORD"
|
||||||
@ -159,15 +157,6 @@ _dns_cloudns_get_zone_name() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
_dns_cloudns_get_record_id() {
|
|
||||||
_dns_cloudns_http_api_call "dns/records.json" "domain-name=$1&host=$2&type=TXT"
|
|
||||||
if _contains "$response" "\"id\":"; then
|
|
||||||
echo "$response" | cut -d '"' -f 2
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
_dns_cloudns_http_api_call() {
|
_dns_cloudns_http_api_call() {
|
||||||
method=$1
|
method=$1
|
||||||
|
|
||||||
@ -189,7 +178,7 @@ _dns_cloudns_http_api_call() {
|
|||||||
|
|
||||||
response="$(_get "$CLOUDNS_API/$method?$data")"
|
response="$(_get "$CLOUDNS_API/$method?$data")"
|
||||||
|
|
||||||
_debug2 response "$response"
|
_debug response "$response"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user