suppor Ali doh and dnspod doh.
This commit is contained in:
neil 2021-05-03 16:35:42 +08:00
parent ae40445dba
commit e65144a105

62
acme.sh
View File

@ -102,6 +102,8 @@ DEBUG_LEVEL_NONE=0
DOH_CLOUDFLARE=1 DOH_CLOUDFLARE=1
DOH_GOOGLE=2 DOH_GOOGLE=2
DOH_ALI=3
DOH_DP=4
HIDDEN_VALUE="[hidden](please add '--output-insecure' to see this value)" HIDDEN_VALUE="[hidden](please add '--output-insecure' to see this value)"
@ -3916,7 +3918,15 @@ _ns_purge_cf() {
#checks if cf server is available #checks if cf server is available
_ns_is_available_cf() { _ns_is_available_cf() {
if _get "https://cloudflare-dns.com" >/dev/null 2>&1; then if _get "https://cloudflare-dns.com" "" 1 >/dev/null 2>&1; then
return 0
else
return 1
fi
}
_ns_is_available_google() {
if _get "https://dns.google" "" 1 >/dev/null 2>&1; then
return 0 return 0
else else
return 1 return 1
@ -3931,6 +3941,38 @@ _ns_lookup_google() {
_ns_lookup_impl "$_cf_ep" "$_cf_ld" "$_cf_ld_type" _ns_lookup_impl "$_cf_ep" "$_cf_ld" "$_cf_ld_type"
} }
_ns_is_available_ali() {
if _get "https://dns.alidns.com" "" 1 >/dev/null 2>&1; then
return 0
else
return 1
fi
}
#domain, type
_ns_lookup_ali() {
_cf_ld="$1"
_cf_ld_type="$2"
_cf_ep="https://dns.alidns.com/resolve"
_ns_lookup_impl "$_cf_ep" "$_cf_ld" "$_cf_ld_type"
}
_ns_is_available_dp() {
if _get "https://dns.alidns.com" "" 1 >/dev/null 2>&1; then
return 0
else
return 1
fi
}
#dnspod
_ns_lookup_dp() {
_cf_ld="$1"
_cf_ld_type="$2"
_cf_ep="https://doh.pub/dns-query"
_ns_lookup_impl "$_cf_ep" "$_cf_ld" "$_cf_ld_type"
}
#domain, type #domain, type
_ns_lookup() { _ns_lookup() {
if [ -z "$DOH_USE" ]; then if [ -z "$DOH_USE" ]; then
@ -3938,16 +3980,28 @@ _ns_lookup() {
if _ns_is_available_cf; then if _ns_is_available_cf; then
_debug "Use cloudflare doh server" _debug "Use cloudflare doh server"
export DOH_USE=$DOH_CLOUDFLARE export DOH_USE=$DOH_CLOUDFLARE
else elif _ns_is_available_google; then
_debug "Use google doh server" _debug "Use google doh server"
export DOH_USE=$DOH_GOOGLE export DOH_USE=$DOH_GOOGLE
elif _ns_is_available_ali; then
_debug "Use aliyun doh server"
export DOH_USE=$DOH_ALI
else _ns_is_available_dp;
_debug "Use dns pod doh server"
export DOH_USE=$DOH_DP
fi fi
fi fi
if [ "$DOH_USE" = "$DOH_CLOUDFLARE" ] || [ -z "$DOH_USE" ]; then if [ "$DOH_USE" = "$DOH_CLOUDFLARE" ] || [ -z "$DOH_USE" ]; then
_ns_lookup_cf "$@" _ns_lookup_cf "$@"
else elif [ "$DOH_USE" = "$DOH_GOOGLE" ]; then
_ns_lookup_google "$@" _ns_lookup_google "$@"
elif [ "$DOH_USE" = "$DOH_ALI" ]; then
_ns_lookup_ali "$@"
elif [ "$DOH_USE" = "$DOH_DP" ]; then
_ns_lookup_dp "$@"
else
_err "Unknown doh provider: DOH_USE=$DOH_USE"
fi fi
} }
@ -3972,7 +4026,7 @@ __purge_txt() {
if [ "$DOH_USE" = "$DOH_CLOUDFLARE" ] || [ -z "$DOH_USE" ]; then if [ "$DOH_USE" = "$DOH_CLOUDFLARE" ] || [ -z "$DOH_USE" ]; then
_ns_purge_cf "$_p_txtdomain" "TXT" _ns_purge_cf "$_p_txtdomain" "TXT"
else else
_debug "no purge api for google dns api, just sleep 5 secs" _debug "no purge api for this doh api, just sleep 5 secs"
_sleep 5 _sleep 5
fi fi