mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2026-08-22 15:53:29 +08:00
This commit is contained in:
@@ -5,14 +5,11 @@ Site: DNSExit.com
|
|||||||
Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi2#dns_dnsexit
|
Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi2#dns_dnsexit
|
||||||
Options:
|
Options:
|
||||||
DNSEXIT_API_KEY API Key
|
DNSEXIT_API_KEY API Key
|
||||||
DNSEXIT_AUTH_USER Username
|
|
||||||
DNSEXIT_AUTH_PASS Password
|
|
||||||
Issues: github.com/acmesh-official/acme.sh/issues/4719
|
Issues: github.com/acmesh-official/acme.sh/issues/4719
|
||||||
Author: Samuel Jimenez
|
Author: Samuel Jimenez
|
||||||
'
|
'
|
||||||
|
|
||||||
DNSEXIT_API_URL="https://api.dnsexit.com/dns/"
|
DNSEXIT_API_URL="https://api.dnsexit.com/dns/"
|
||||||
DNSEXIT_HOSTS_URL="https://update.dnsexit.com/ipupdate/hosts.jsp"
|
|
||||||
|
|
||||||
######## Public functions #####################
|
######## Public functions #####################
|
||||||
#Usage: dns_dnsexit_add _acme-challenge.*.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
|
#Usage: dns_dnsexit_add _acme-challenge.*.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
|
||||||
@@ -28,20 +25,7 @@ dns_dnsexit_add() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_debug 'First detect the root zone'
|
_dnsexit_zone_op add ',"ttl":0,"overwrite":false'
|
||||||
if ! _get_root "$fulldomain"; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_debug _sub_domain "$_sub_domain"
|
|
||||||
_debug _domain "$_domain"
|
|
||||||
|
|
||||||
if ! _dnsexit_rest "{\"domain\":\"$_domain\",\"add\":{\"type\":\"TXT\",\"name\":\"$_sub_domain\",\"content\":\"$txtvalue\",\"ttl\":0,\"overwrite\":false}}"; then
|
|
||||||
_err "$response"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
_debug2 _response "$response"
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#Usage: fulldomain txtvalue
|
#Usage: fulldomain txtvalue
|
||||||
@@ -58,54 +42,43 @@ dns_dnsexit_rm() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_debug 'First detect the root zone'
|
_dnsexit_zone_op delete ''
|
||||||
if ! _get_root "$fulldomain"; then
|
|
||||||
_err "$response"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_debug _sub_domain "$_sub_domain"
|
|
||||||
_debug _domain "$_domain"
|
|
||||||
|
|
||||||
if ! _dnsexit_rest "{\"domain\":\"$_domain\",\"delete\":{\"type\":\"TXT\",\"name\":\"$_sub_domain\",\"content\":\"$txtvalue\"}}"; then
|
|
||||||
_err "$response"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
_debug2 _response "$response"
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#################### Private functions below ##################################
|
#################### Private functions below ##################################
|
||||||
#_acme-challenge.www.domain.com
|
# The legacy zone-detection endpoint (update.dnsexit.com/ipupdate/hosts.jsp)
|
||||||
#returns
|
# was shut down by DNSExit and now returns 503, and the JSON API offers no
|
||||||
# _sub_domain=_acme-challenge.www
|
# zone-list call. So find the root zone by attempting the actual operation at
|
||||||
# _domain=domain.com
|
# each domain level: the API answers "code":0 only when the domain matches a
|
||||||
_get_root() {
|
# zone of the account. https://github.com/acmesh-official/acme.sh/issues/6914
|
||||||
domain=$1
|
#Usage: _dnsexit_zone_op <add|delete> <extra-json-fields>
|
||||||
|
_dnsexit_zone_op() {
|
||||||
|
_op="$1"
|
||||||
|
_extra="$2"
|
||||||
i=1
|
i=1
|
||||||
while true; do
|
while true; do
|
||||||
_domain=$(printf "%s" "$domain" | cut -d . -f "$i"-100)
|
_domain=$(printf "%s" "$fulldomain" | cut -d . -f "$i"-100)
|
||||||
_debug h "$_domain"
|
_debug _domain "$_domain"
|
||||||
if [ -z "$_domain" ]; then
|
if [ -z "$_domain" ]; then
|
||||||
|
_err "Could not find the root zone of $fulldomain in your DNSExit account"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_debug login "$DNSEXIT_AUTH_USER"
|
_sub_domain="$(printf "%s" "$fulldomain" | sed "s/\\.$_domain\$//")"
|
||||||
_debug password "$DNSEXIT_AUTH_PASS"
|
if [ "$_sub_domain" = "$fulldomain" ]; then
|
||||||
_debug domain "$_domain"
|
_sub_domain=""
|
||||||
|
fi
|
||||||
|
_debug _sub_domain "$_sub_domain"
|
||||||
|
|
||||||
_dnsexit_http "login=$DNSEXIT_AUTH_USER&password=$DNSEXIT_AUTH_PASS&domain=$_domain"
|
if _dnsexit_rest "{\"domain\":\"$_domain\",\"$_op\":{\"type\":\"TXT\",\"name\":\"$_sub_domain\",\"content\":\"$txtvalue\"$_extra}}"; then
|
||||||
|
if _contains "$response" "\"code\":0" || _contains "$response" "\"code\": 0"; then
|
||||||
if _contains "$response" "0=$_domain"; then
|
_debug2 _response "$response"
|
||||||
_sub_domain="$(echo "$fulldomain" | sed "s/\\.$_domain\$//")"
|
return 0
|
||||||
return 0
|
fi
|
||||||
else
|
_debug "Zone $_domain was not accepted, trying the next level" "$response"
|
||||||
_debug "Go to next level of $_domain"
|
|
||||||
fi
|
fi
|
||||||
i=$(_math "$i" + 1)
|
i=$(_math "$i" + 1)
|
||||||
done
|
done
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_dnsexit_rest() {
|
_dnsexit_rest() {
|
||||||
@@ -136,27 +109,7 @@ _dnsexit_rest() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
_dnsexit_http() {
|
|
||||||
m=GET
|
|
||||||
param="$1"
|
|
||||||
_debug param "$param"
|
|
||||||
_debug get "$DNSEXIT_HOSTS_URL?$param"
|
|
||||||
|
|
||||||
response="$(_get "$DNSEXIT_HOSTS_URL?$param")"
|
|
||||||
|
|
||||||
_debug response "$response"
|
|
||||||
|
|
||||||
if [ "$?" != "0" ]; then
|
|
||||||
_err "Error $param"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
_debug2 response "$response"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
get_account_info() {
|
get_account_info() {
|
||||||
|
|
||||||
DNSEXIT_API_KEY="${DNSEXIT_API_KEY:-$(_readaccountconf_mutable DNSEXIT_API_KEY)}"
|
DNSEXIT_API_KEY="${DNSEXIT_API_KEY:-$(_readaccountconf_mutable DNSEXIT_API_KEY)}"
|
||||||
if test -z "$DNSEXIT_API_KEY"; then
|
if test -z "$DNSEXIT_API_KEY"; then
|
||||||
DNSEXIT_API_KEY=''
|
DNSEXIT_API_KEY=''
|
||||||
@@ -166,23 +119,5 @@ get_account_info() {
|
|||||||
|
|
||||||
_saveaccountconf_mutable DNSEXIT_API_KEY "$DNSEXIT_API_KEY"
|
_saveaccountconf_mutable DNSEXIT_API_KEY "$DNSEXIT_API_KEY"
|
||||||
|
|
||||||
DNSEXIT_AUTH_USER="${DNSEXIT_AUTH_USER:-$(_readaccountconf_mutable DNSEXIT_AUTH_USER)}"
|
|
||||||
if test -z "$DNSEXIT_AUTH_USER"; then
|
|
||||||
DNSEXIT_AUTH_USER=""
|
|
||||||
_err 'DNSEXIT_AUTH_USER was not exported'
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
_saveaccountconf_mutable DNSEXIT_AUTH_USER "$DNSEXIT_AUTH_USER"
|
|
||||||
|
|
||||||
DNSEXIT_AUTH_PASS="${DNSEXIT_AUTH_PASS:-$(_readaccountconf_mutable DNSEXIT_AUTH_PASS)}"
|
|
||||||
if test -z "$DNSEXIT_AUTH_PASS"; then
|
|
||||||
DNSEXIT_AUTH_PASS=""
|
|
||||||
_err 'DNSEXIT_AUTH_PASS was not exported'
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
_saveaccountconf_mutable DNSEXIT_AUTH_PASS "$DNSEXIT_AUTH_PASS"
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user