From 8ae32f50f28d7d5d8f1968349ee1e28c644ee94f Mon Sep 17 00:00:00 2001 From: David Cowden Date: Wed, 13 May 2020 05:04:49 -0700 Subject: [PATCH] acme: Fix comment style to appease linter The linter likes comments on public functions to start with their name, for some reason... --- acme/authority.go | 10 ++++++++-- acme/challenge.go | 1 + acme/common.go | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/acme/authority.go b/acme/authority.go index 61b6b08c..cc1a6daa 100644 --- a/acme/authority.go +++ b/acme/authority.go @@ -273,6 +273,8 @@ func (a *Authority) GetAuthz(p provisioner.Interface, accID, authzID string) (*A return az.toACME(a.db, a.dir, p) } +// ValidateChallenge ... +// // The challenge validation state machine looks like: // // * https://tools.ietf.org/html/rfc8555#section-7.1.6 @@ -296,7 +298,8 @@ func (a *Authority) GetAuthz(p provisioner.Interface, accID, authzID string) (*A // // It's possible that another request to re-attempt the challenge comes in while a retry attempt is // pending from a previous request. In general, these old attempts will see that Retry.NextAttempt -// is in the future and drop their task. But this also might have happened on another instance, etc. +// is in the future and drop their task. Because another instance may have taken ownership, old attempts +// would also see a different ordinal than their own. // // 4. When the retry timer fires, check to make sure the retry should still process. // (a) Refresh the challenge from the DB. @@ -383,6 +386,9 @@ func (a *Authority) validate(ch challenge, jwk *jose.JSONWebKey) (challenge, err const retryInterval = 12 * time.Second +// RetryChallenge behaves similar to ValidateChallenge, but simply attempts to perform a validation and +// write update the challenge record in the db if the challenge has remaining retry attempts. +// // see: ValidateChallenge func (a *Authority) RetryChallenge(chID string) { ch, err := getChallenge(a.db, chID) @@ -422,7 +428,7 @@ func (a *Authority) RetryChallenge(chID string) { // Update the db so that other retries simply drop when their timer fires. up := ch.clone() up.Retry.NextAttempt = now.Add(retryInterval).UTC().Format(time.RFC3339) - up.Retry.NumAttempts += 1 + up.Retry.NumAttempts++ err = up.save(a.db, ch) if err != nil { return diff --git a/acme/challenge.go b/acme/challenge.go index 92572328..b87f4ee2 100644 --- a/acme/challenge.go +++ b/acme/challenge.go @@ -316,6 +316,7 @@ type Retry struct { NextAttempt string `json:"nextattempt"` } +// Active returns a boolean indicating whether a Retry struct has remaining attempts or not. func (r *Retry) Active() bool { return r.NumAttempts < r.MaxAttempts } diff --git a/acme/common.go b/acme/common.go index 8b6b2e82..936574e3 100644 --- a/acme/common.go +++ b/acme/common.go @@ -29,7 +29,7 @@ var ( StatusInvalid = "invalid" // StatusPending -- pending; e.g. an Order that is not ready to be finalized. StatusPending = "pending" - // processing -- e.g. a Challenge that is in the process of being validated. + // StatusProcessing -- processing e.g. a Challenge that is in the process of being validated. StatusProcessing = "processing" // StatusDeactivated -- deactivated; e.g. for an Account that is not longer valid. StatusDeactivated = "deactivated"