mirror of
https://github.com/go-acme/lego.git
synced 2025-07-05 06:50:19 +02:00
fix(ari): avoid Int63n panic in ShouldRenewAt() (#2246)
This commit is contained in:
@ -41,9 +41,11 @@ func (r *RenewalInfoResponse) ShouldRenewAt(now time.Time, willingToSleep time.D
|
|||||||
end := r.SuggestedWindow.End.UTC()
|
end := r.SuggestedWindow.End.UTC()
|
||||||
|
|
||||||
// Select a uniform random time within the suggested window.
|
// Select a uniform random time within the suggested window.
|
||||||
window := end.Sub(start)
|
rt := start
|
||||||
|
if window := end.Sub(start); window > 0 {
|
||||||
randomDuration := time.Duration(rand.Int63n(int64(window)))
|
randomDuration := time.Duration(rand.Int63n(int64(window)))
|
||||||
rt := start.Add(randomDuration)
|
rt = rt.Add(randomDuration)
|
||||||
|
}
|
||||||
|
|
||||||
// If the selected time is in the past, attempt renewal immediately.
|
// If the selected time is in the past, attempt renewal immediately.
|
||||||
if rt.Before(now) {
|
if rt.Before(now) {
|
||||||
|
Reference in New Issue
Block a user