mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-12-24 03:52:10 +08:00
Merge branch 'dev' into dns_efficientip
This commit is contained in:
44
acme.sh
44
acme.sh
@@ -1897,6 +1897,11 @@ _inithttp() {
|
|||||||
|
|
||||||
if [ -z "$_ACME_CURL" ] && _exists "curl"; then
|
if [ -z "$_ACME_CURL" ] && _exists "curl"; then
|
||||||
_ACME_CURL="curl --silent --dump-header $HTTP_HEADER "
|
_ACME_CURL="curl --silent --dump-header $HTTP_HEADER "
|
||||||
|
if [ "$ACME_USE_IPV6_REQUESTS" ]; then
|
||||||
|
_ACME_CURL="$_ACME_CURL --ipv6 "
|
||||||
|
elif [ "$ACME_USE_IPV4_REQUESTS" ]; then
|
||||||
|
_ACME_CURL="$_ACME_CURL --ipv4 "
|
||||||
|
fi
|
||||||
if [ -z "$ACME_HTTP_NO_REDIRECTS" ]; then
|
if [ -z "$ACME_HTTP_NO_REDIRECTS" ]; then
|
||||||
_ACME_CURL="$_ACME_CURL -L "
|
_ACME_CURL="$_ACME_CURL -L "
|
||||||
fi
|
fi
|
||||||
@@ -1924,6 +1929,11 @@ _inithttp() {
|
|||||||
|
|
||||||
if [ -z "$_ACME_WGET" ] && _exists "wget"; then
|
if [ -z "$_ACME_WGET" ] && _exists "wget"; then
|
||||||
_ACME_WGET="wget -q"
|
_ACME_WGET="wget -q"
|
||||||
|
if [ "$ACME_USE_IPV6_REQUESTS" ]; then
|
||||||
|
_ACME_WGET="$_ACME_WGET --inet6-only "
|
||||||
|
elif [ "$ACME_USE_IPV4_REQUESTS" ]; then
|
||||||
|
_ACME_WGET="$_ACME_WGET --inet4-only "
|
||||||
|
fi
|
||||||
if [ "$ACME_HTTP_NO_REDIRECTS" ]; then
|
if [ "$ACME_HTTP_NO_REDIRECTS" ]; then
|
||||||
_ACME_WGET="$_ACME_WGET --max-redirect 0 "
|
_ACME_WGET="$_ACME_WGET --max-redirect 0 "
|
||||||
fi
|
fi
|
||||||
@@ -7137,6 +7147,8 @@ Parameters:
|
|||||||
--auto-upgrade [0|1] Valid for '--upgrade' command, indicating whether to upgrade automatically in future. Defaults to 1 if argument is omitted.
|
--auto-upgrade [0|1] Valid for '--upgrade' command, indicating whether to upgrade automatically in future. Defaults to 1 if argument is omitted.
|
||||||
--listen-v4 Force standalone/tls server to listen at ipv4.
|
--listen-v4 Force standalone/tls server to listen at ipv4.
|
||||||
--listen-v6 Force standalone/tls server to listen at ipv6.
|
--listen-v6 Force standalone/tls server to listen at ipv6.
|
||||||
|
--request-v4 Force client requests to use ipv4 to connect to the CA server.
|
||||||
|
--request-v6 Force client requests to use ipv6 to connect to the CA server.
|
||||||
--openssl-bin <file> Specifies a custom openssl bin location.
|
--openssl-bin <file> Specifies a custom openssl bin location.
|
||||||
--use-wget Force to use wget, if you have both curl and wget installed.
|
--use-wget Force to use wget, if you have both curl and wget installed.
|
||||||
--yes-I-know-dns-manual-mode-enough-go-ahead-please Force use of dns manual mode.
|
--yes-I-know-dns-manual-mode-enough-go-ahead-please Force use of dns manual mode.
|
||||||
@@ -7255,6 +7267,24 @@ _processAccountConf() {
|
|||||||
_saveaccountconf "ACME_USE_WGET" "$ACME_USE_WGET"
|
_saveaccountconf "ACME_USE_WGET" "$ACME_USE_WGET"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$_request_v6" ]; then
|
||||||
|
_saveaccountconf "ACME_USE_IPV6_REQUESTS" "$_request_v6"
|
||||||
|
_clearaccountconf "ACME_USE_IPV4_REQUESTS"
|
||||||
|
ACME_USE_IPV4_REQUESTS=
|
||||||
|
elif [ "$_request_v4" ]; then
|
||||||
|
_saveaccountconf "ACME_USE_IPV4_REQUESTS" "$_request_v4"
|
||||||
|
_clearaccountconf "ACME_USE_IPV6_REQUESTS"
|
||||||
|
ACME_USE_IPV6_REQUESTS=
|
||||||
|
elif [ "$ACME_USE_IPV6_REQUESTS" ]; then
|
||||||
|
_saveaccountconf "ACME_USE_IPV6_REQUESTS" "$ACME_USE_IPV6_REQUESTS"
|
||||||
|
_clearaccountconf "ACME_USE_IPV4_REQUESTS"
|
||||||
|
ACME_USE_IPV4_REQUESTS=
|
||||||
|
elif [ "$ACME_USE_IPV4_REQUESTS" ]; then
|
||||||
|
_saveaccountconf "ACME_USE_IPV4_REQUESTS" "$ACME_USE_IPV4_REQUESTS"
|
||||||
|
_clearaccountconf "ACME_USE_IPV6_REQUESTS"
|
||||||
|
ACME_USE_IPV6_REQUESTS=
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_checkSudo() {
|
_checkSudo() {
|
||||||
@@ -7420,6 +7450,8 @@ _process() {
|
|||||||
_local_address=""
|
_local_address=""
|
||||||
_log_level=""
|
_log_level=""
|
||||||
_auto_upgrade=""
|
_auto_upgrade=""
|
||||||
|
_request_v4=""
|
||||||
|
_request_v6=""
|
||||||
_listen_v4=""
|
_listen_v4=""
|
||||||
_listen_v6=""
|
_listen_v6=""
|
||||||
_openssl_bin=""
|
_openssl_bin=""
|
||||||
@@ -7885,6 +7917,18 @@ _process() {
|
|||||||
fi
|
fi
|
||||||
AUTO_UPGRADE="$_auto_upgrade"
|
AUTO_UPGRADE="$_auto_upgrade"
|
||||||
;;
|
;;
|
||||||
|
--request-v4)
|
||||||
|
_request_v4="1"
|
||||||
|
ACME_USE_IPV4_REQUESTS="1"
|
||||||
|
_request_v6=""
|
||||||
|
ACME_USE_IPV6_REQUESTS=""
|
||||||
|
;;
|
||||||
|
--request-v6)
|
||||||
|
_request_v6="1"
|
||||||
|
ACME_USE_IPV6_REQUESTS="1"
|
||||||
|
_request_v4=""
|
||||||
|
ACME_USE_IPV4_REQUESTS=""
|
||||||
|
;;
|
||||||
--listen-v4)
|
--listen-v4)
|
||||||
_listen_v4="1"
|
_listen_v4="1"
|
||||||
Le_Listen_V4="$_listen_v4"
|
Le_Listen_V4="$_listen_v4"
|
||||||
|
|||||||
@@ -27,8 +27,16 @@ dns_nanelo_add() {
|
|||||||
fi
|
fi
|
||||||
_saveaccountconf_mutable NANELO_TOKEN "$NANELO_TOKEN"
|
_saveaccountconf_mutable NANELO_TOKEN "$NANELO_TOKEN"
|
||||||
|
|
||||||
|
_debug "First detect the root zone"
|
||||||
|
if ! _get_root "$fulldomain"; then
|
||||||
|
_err "invalid domain"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
_debug _sub_domain "$_sub_domain"
|
||||||
|
_debug _domain "$_domain"
|
||||||
|
|
||||||
_info "Adding TXT record to ${fulldomain}"
|
_info "Adding TXT record to ${fulldomain}"
|
||||||
response="$(_get "$NANELO_API$NANELO_TOKEN/dns/addrecord?type=TXT&ttl=60&name=${fulldomain}&value=${txtvalue}")"
|
response="$(_post "" "$NANELO_API$NANELO_TOKEN/dns/addrecord?domain=${_domain}&type=TXT&ttl=60&name=${_sub_domain}&value=${txtvalue}" "" "" "")"
|
||||||
if _contains "${response}" 'success'; then
|
if _contains "${response}" 'success'; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -51,8 +59,16 @@ dns_nanelo_rm() {
|
|||||||
fi
|
fi
|
||||||
_saveaccountconf_mutable NANELO_TOKEN "$NANELO_TOKEN"
|
_saveaccountconf_mutable NANELO_TOKEN "$NANELO_TOKEN"
|
||||||
|
|
||||||
|
_debug "First, let's detect the root zone:"
|
||||||
|
if ! _get_root "$fulldomain"; then
|
||||||
|
_err "invalid domain"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
_debug _sub_domain "$_sub_domain"
|
||||||
|
_debug _domain "$_domain"
|
||||||
|
|
||||||
_info "Deleting resource record $fulldomain"
|
_info "Deleting resource record $fulldomain"
|
||||||
response="$(_get "$NANELO_API$NANELO_TOKEN/dns/deleterecord?type=TXT&ttl=60&name=${fulldomain}&value=${txtvalue}")"
|
response="$(_post "" "$NANELO_API$NANELO_TOKEN/dns/deleterecord?domain=${_domain}&type=TXT&ttl=60&name=${_sub_domain}&value=${txtvalue}" "" "" "")"
|
||||||
if _contains "${response}" 'success'; then
|
if _contains "${response}" 'success'; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -60,3 +76,45 @@ dns_nanelo_rm() {
|
|||||||
_err "${response}"
|
_err "${response}"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#################### Private functions below ##################################
|
||||||
|
#_acme-challenge.www.domain.com
|
||||||
|
#returns
|
||||||
|
# _sub_domain=_acme-challenge.www
|
||||||
|
# _domain=domain.com
|
||||||
|
|
||||||
|
_get_root() {
|
||||||
|
fulldomain=$1
|
||||||
|
|
||||||
|
# Fetch all zones from Nanelo
|
||||||
|
response="$(_get "$NANELO_API$NANELO_TOKEN/dns/getzones")" || return 1
|
||||||
|
|
||||||
|
# Extract "zones" array into space-separated list
|
||||||
|
zones=$(echo "$response" |
|
||||||
|
tr -d ' \n' |
|
||||||
|
sed -n 's/.*"zones":\[\([^]]*\)\].*/\1/p' |
|
||||||
|
tr -d '"' |
|
||||||
|
tr , ' ')
|
||||||
|
_debug zones "$zones"
|
||||||
|
|
||||||
|
bestzone=""
|
||||||
|
for z in $zones; do
|
||||||
|
case "$fulldomain" in
|
||||||
|
*."$z" | "$z")
|
||||||
|
if [ ${#z} -gt ${#bestzone} ]; then
|
||||||
|
bestzone=$z
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$bestzone" ]; then
|
||||||
|
_err "No matching zone found for $fulldomain"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_domain="$bestzone"
|
||||||
|
_sub_domain=$(printf "%s" "$fulldomain" | sed "s/\\.$_domain\$//")
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user