Make dns-validation-retry-interval and dns-validation-timeout as parameters to _check_dns_entries per Neilpang code review request

pull/6244/head
Joel Bion 2 weeks ago
parent 7a9c3b6689
commit 23e1cba940

@ -56,6 +56,12 @@ DEFAULT_USER_AGENT="$PROJECT_NAME/$VER ($PROJECT)"
DEFAULT_ACCOUNT_KEY_LENGTH=ec-256 DEFAULT_ACCOUNT_KEY_LENGTH=ec-256
DEFAULT_DOMAIN_KEY_LENGTH=ec-256 DEFAULT_DOMAIN_KEY_LENGTH=ec-256
# These values are in seconds. They were hard-coded to these values in previous
# versions of this script that existed before the DNS validation timers could
# be configured on script invocation via the command line.
DEFAULT_DNS_VALIDATION_TIMEOUT="1200"
DEFAULT_DNS_VALIDATION_RETRY_INTERVAL="10"
DEFAULT_OPENSSL_BIN="openssl" DEFAULT_OPENSSL_BIN="openssl"
VTYPE_HTTP="http-01" VTYPE_HTTP="http-01"
@ -4197,31 +4203,49 @@ __purge_txt() {
} }
#wait and check each dns entries #wait and check each dns entries
#
# _check_dns_entries takes two parameters:
#
# $1 is the dnsvalidationtimeout parameter. Which is the maximum time to
# wait for DNS validation.
#
# $2 is the dnsvalidationretryinterval parameter. Which is the amount of
# time to wait between attempts to check to see if the appropriate DNS
# TXT records have been added.
#
_check_dns_entries() { _check_dns_entries() {
_success_txt="," _success_txt=","
_end_time="$(_time)"
# Use default values for DNS timeout (1200 seconds/20 minutes) and DNS retry # Use default values for DNS timeout and DNS retry interval, unless specified
# interval (10 seconds), unless configured at script invocation to be # at script invocation to be something else.
# something else. _cdnsevalidationtimeout="$DEFAULT_DNS_VALIDATION_TIMEOUT"
_dnstimeout=1200 #default timeout is 20 minutes _cdnsevalidationretryinterval="$DEFAULT_DNS_VALIDATION_RETRY_INTERVAL"
if [ -n "$Le_DNSValidateTimeout" ]; then
# Some warning and status messages should only be printed during the first
# pass.
_cdnsefirstpass="1"
if [ -n "$1" ]; then
# Use configured DNS validation timeout # Use configured DNS validation timeout
_dnstimeout="$Le_DNSValidateTimeout" _cdnsevalidationtimeout="$1"
_savedomainconf "Le_DNSValidateTimeout" "$Le_DNSValidateTimeout" _savedomainconf "Le_DNSValidationTimeout" "$1"
fi fi
_dnsinterval=10 #default interval between retries is 10 seconds if [ -n "$2" ]; then
if [ -n "$Le_DNSValidateInterval" ]; then
# Use configured DNS validation retry interval # Use configured DNS validation retry interval
_dnsinterval="$Le_DNSValidateInterval" _cdnsevalidationretryinterval="$2"
_savedomainconf "Le_DNSValidateInterval" "$Le_DNSValidateInterval" _savedomainconf "Le_DNSValidationRetryInterval" "$2"
fi fi
_end_time="$(_math "$_end_time" + "$_dnstimeout")" #let's check no longer than this #determine when to stop checking
_end_time="$(_time)"
_end_time="$(_math "$_end_time" + "$_cdnsevalidationtimeout")"
while [ "$(_time)" -le "$_end_time" ]; do while [ "$(_time)" -le "$_end_time" ]; do
_info "You can use '--dnssleep' to disable public dns checks." if [ -n "$_cdnsefirstpass" ]; then
_info "See: $_DNSCHECK_WIKI" _info "You can use '--dnssleep' to disable public DNS checks."
_info "See: $_DNSCHECK_WIKI"
_cdnsefirstpass=""
fi
_left="" _left=""
for entry in $dns_entries; do for entry in $dns_entries; do
d=$(_getfield "$entry" 1) d=$(_getfield "$entry" 1)
@ -4256,8 +4280,8 @@ _check_dns_entries() {
_sleep 10 _sleep 10
done done
if [ "$_left" ]; then if [ "$_left" ]; then
_info "Let's wait for "$_dnsinterval" seconds and check again". _info "Let's wait for $_cdnsevalidationretryinterval seconds and check again".
_sleep $_dnsinterval _sleep "$_cdnsevalidationretryinterval"
else else
_info "All checks succeeded" _info "All checks succeeded"
return 0 return 0
@ -4927,7 +4951,7 @@ $_authorizations_map"
if [ -z "$Le_DNSSleep" ]; then if [ -z "$Le_DNSSleep" ]; then
_info "Let's check each DNS record now. Sleeping for 20 seconds first." _info "Let's check each DNS record now. Sleeping for 20 seconds first."
_sleep 20 _sleep 20
if ! _check_dns_entries; then if ! _check_dns_entries "$_dnsvalidationtimeout" "$_dnsvalidationretryinterval"; then
_err "Error checking DNS." _err "Error checking DNS."
_on_issue_err "$_post_hook" _on_issue_err "$_post_hook"
_clearup _clearup
@ -7010,8 +7034,8 @@ Parameters:
--dnssleep <seconds> The time in seconds to wait for all the txt records to propagate in dns api mode. --dnssleep <seconds> The time in seconds to wait for all the txt records to propagate in dns api mode.
It's not necessary to use this by default, $PROJECT_NAME polls dns status by DOH automatically. It's not necessary to use this by default, $PROJECT_NAME polls dns status by DOH automatically.
--dns-validate-interval <seconds> How long to pause between attempts to validate with DNS. Default: 10 seconds. --dns-validation-retry-interval <seconds> How long to pause between attempts to validate with DNS TXT records. Default: $DEFAULT_DNS_VALIDATION_RETRY_INTERVAL seconds.
--dns-validate-timeout <seconds> How much total time to allow DNS for validations before declaring a failure. Default: 1200 seconds (20 minutes). --dns-validation-timeout <seconds> How much total time to allow DNS validation to succeed declaring a failure. Default: $DEFAULT_DNS_VALIDATION_TIMEOUT seconds.
-k, --keylength <bits> Specifies the domain key length: 2048, 3072, 4096, 8192 or ec-256, ec-384, ec-521. -k, --keylength <bits> Specifies the domain key length: 2048, 3072, 4096, 8192 or ec-256, ec-384, ec-521.
-ak, --accountkeylength <bits> Specifies the account key length: 2048, 3072, 4096 -ak, --accountkeylength <bits> Specifies the account key length: 2048, 3072, 4096
--log [file] Specifies the log file. Defaults to \"$DEFAULT_LOG_FILE\" if argument is omitted. --log [file] Specifies the log file. Defaults to \"$DEFAULT_LOG_FILE\" if argument is omitted.
@ -7331,8 +7355,8 @@ _process() {
_httpport="" _httpport=""
_tlsport="" _tlsport=""
_dnssleep="" _dnssleep=""
_dnsvalidateinterval="" _dnsvalidationinterval=""
_dnsvalidatetimeout="" _dnsvalidationtimeout=""
_listraw="" _listraw=""
_stopRenewOnError="" _stopRenewOnError=""
#_insecure="" #_insecure=""
@ -7603,14 +7627,14 @@ _process() {
Le_DNSSleep="$_dnssleep" Le_DNSSleep="$_dnssleep"
shift shift
;; ;;
--dns-validate-interval) --dns-validation-retry-interval)
_dnsvalidateinterval="$2" _dnsvalidationretryinterval="$2"
Le_DNSValidateInterval="$_dnsvalidateinterval" Le_DNSValidationRetryInterval="$_dnsvalidationretryinterval"
shift shift
;; ;;
--dns-validate-timeout) --dns-validation-timeout)
_dnsvalidatetimeout="$2" _dnsvalidationtimeout="$2"
Le_DNSValidateTimeout="$_dnsvalidatetimeout" Le_DNSValidationTimeout="$_dnsvalidationtimeout"
shift shift
;; ;;
--keylength | -k) --keylength | -k)

Loading…
Cancel
Save