mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-07-01 07:12:45 +00:00
fix: do not depend on _acme-challenge
prefix
No need to check record name when adding records. Remove only `TXT` records that match both `txtdomain` and `txtvalue`.
This commit is contained in:
parent
f1b678290c
commit
19042f696e
@ -26,16 +26,14 @@ dns_mydevil_add() {
|
|||||||
_info "Using mydevil"
|
_info "Using mydevil"
|
||||||
|
|
||||||
domain=$(mydevil_get_domain "$fulldomain")
|
domain=$(mydevil_get_domain "$fulldomain")
|
||||||
if ! mydevil_check_record "$fulldomain"; then
|
|
||||||
_err "Invalid record name: does not start with '_acme-challenge'."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$domain" ]; then
|
if [ -z "$domain" ]; then
|
||||||
_err "Invalid domain name: could not find root domain of $fulldomain."
|
_err "Invalid domain name: could not find root domain of $fulldomain."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# No need to check if record name exists, `devil` always adds new record.
|
||||||
|
# In worst case scenario, we end up with multiple identical records.
|
||||||
|
|
||||||
_info "Adding $fulldomain record for domain $domain"
|
_info "Adding $fulldomain record for domain $domain"
|
||||||
if devil dns add "$domain" "$fulldomain" TXT "$txtvalue"; then
|
if devil dns add "$domain" "$fulldomain" TXT "$txtvalue"; then
|
||||||
_info "Successfully added TXT record, ready for validation."
|
_info "Successfully added TXT record, ready for validation."
|
||||||
@ -61,17 +59,20 @@ dns_mydevil_rm() {
|
|||||||
_info "Using mydevil"
|
_info "Using mydevil"
|
||||||
|
|
||||||
domain=$(mydevil_get_domain "$fulldomain")
|
domain=$(mydevil_get_domain "$fulldomain")
|
||||||
if ! mydevil_check_record "$fulldomain"; then
|
|
||||||
_err "Invalid record name: does not start with '_acme-challenge'."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$domain" ]; then
|
if [ -z "$domain" ]; then
|
||||||
_err "Invalid domain name: could not find root domain of $fulldomain."
|
_err "Invalid domain name: could not find root domain of $fulldomain."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for id in $(devil dns list "$domain" | grep "$fulldomain" | cut -w -s -f 1); do
|
# catch one or more numbers
|
||||||
|
num='[0-9][0-9]*'
|
||||||
|
# catch one or more whitespace
|
||||||
|
w=$(printf '[\t ][\t ]*')
|
||||||
|
# catch anything, except newline
|
||||||
|
any='.*'
|
||||||
|
# filter to make sure we do not delete other records
|
||||||
|
validRecords="^${num}${w}${fulldomain}${w}TXT${w}${any}${txtvalue}$"
|
||||||
|
for id in $(devil dns list "$domain" | tail -n+2 | grep "${validRecords}" | cut -w -s -f 1); do
|
||||||
_info "Removing record $id from domain $domain"
|
_info "Removing record $id from domain $domain"
|
||||||
devil dns del "$domain" "$id" || _err "Could not remove DNS record."
|
devil dns del "$domain" "$id" || _err "Could not remove DNS record."
|
||||||
done
|
done
|
||||||
@ -79,18 +80,6 @@ dns_mydevil_rm() {
|
|||||||
|
|
||||||
#################### Private functions below ##################################
|
#################### Private functions below ##################################
|
||||||
|
|
||||||
# Usage: mydevil_check_record "_acme-challenge.www.domain.com" || _err "Invalid record name"
|
|
||||||
mydevil_check_record() {
|
|
||||||
case "$1" in
|
|
||||||
"_acme-challenge."*)
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# Usage: domain=$(mydevil_get_domain "_acme-challenge.www.domain.com" || _err "Invalid domain name")
|
# Usage: domain=$(mydevil_get_domain "_acme-challenge.www.domain.com" || _err "Invalid domain name")
|
||||||
# echo $domain
|
# echo $domain
|
||||||
mydevil_get_domain() {
|
mydevil_get_domain() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user