enhance: limit cert renewal interval between 7 to 21 days

This commit is contained in:
Jacky 2024-04-30 17:19:19 +08:00
parent 49b41d6eb7
commit e3876cffaf
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
2 changed files with 11 additions and 1 deletions

View file

@ -60,7 +60,7 @@ func renew(certModel *model.Cert) {
notification.Error("Renew Certificate Error", strings.Join(certModel.Domains, ", "))
return
}
if int(time.Now().Sub(cert.NotBefore).Hours()/24) < settings.ServerSettings.CertRenewalInterval {
if int(time.Now().Sub(cert.NotBefore).Hours()/24) < settings.ServerSettings.GetCertRenewalInterval() {
// not after settings.ServerSettings.CertRenewalInterval, ignore
return
}

View file

@ -33,6 +33,16 @@ func (s *Server) GetCADir() string {
return lego.LEDirectoryProduction
}
func (s *Server) GetCertRenewalInterval() int {
if s.CertRenewalInterval < 7 {
return 7
}
if s.CertRenewalInterval > 21 {
return 21
}
return s.CertRenewalInterval
}
var ServerSettings = Server{
HttpHost: "0.0.0.0",
HttpPort: "9000",