mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-10 18:05:48 +02:00
feat: set renewal interval of certificates #343
This commit is contained in:
parent
4c7e037b76
commit
e77d37bbaa
5 changed files with 38 additions and 25 deletions
|
@ -50,6 +50,14 @@ const errors: Record<string, Record<string, string>> = inject('errors') as Recor
|
|||
>
|
||||
<AInput v-model:value="data.server.ca_dir" />
|
||||
</AFormItem>
|
||||
<AFormItem :label="$gettext('Certificate Renewal Interval')">
|
||||
<AInputNumber
|
||||
v-model:value="data.server.cert_renewal_interval"
|
||||
:min="7"
|
||||
:max="21"
|
||||
:addon-after="$gettext('Days')"
|
||||
/>
|
||||
</AFormItem>
|
||||
</AForm>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ const data = ref<Settings>({
|
|||
github_proxy: '',
|
||||
ca_dir: '',
|
||||
node_secret: '',
|
||||
cert_renewal_interval: 7,
|
||||
},
|
||||
nginx: {
|
||||
access_log_path: '',
|
||||
|
|
|
@ -10,6 +10,7 @@ export interface Settings {
|
|||
github_proxy: string
|
||||
email: string
|
||||
ca_dir: string
|
||||
cert_renewal_interval: number
|
||||
}
|
||||
nginx: {
|
||||
access_log_path: string
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/0xJacky/Nginx-UI/internal/notification"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
"github.com/pkg/errors"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
@ -59,8 +60,8 @@ func renew(certModel *model.Cert) {
|
|||
notification.Error("Renew Certificate Error", strings.Join(certModel.Domains, ", "))
|
||||
return
|
||||
}
|
||||
if time.Now().Sub(cert.NotBefore).Hours()/24 < 7 {
|
||||
// not between 1 week, ignore this certificate
|
||||
if int(time.Now().Sub(cert.NotBefore).Hours()/24) < settings.ServerSettings.CertRenewalInterval {
|
||||
// not after settings.ServerSettings.CertRenewalInterval, ignore
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -5,19 +5,20 @@ import (
|
|||
)
|
||||
|
||||
type Server struct {
|
||||
HttpHost string `json:"http_host" protected:"true"`
|
||||
HttpPort string `json:"http_port" protected:"true"`
|
||||
RunMode string `json:"run_mode" protected:"true"`
|
||||
JwtSecret string `json:"jwt_secret" protected:"true"`
|
||||
NodeSecret string `json:"node_secret" protected:"true"`
|
||||
HTTPChallengePort string `json:"http_challenge_port"`
|
||||
Email string `json:"email" protected:"true"`
|
||||
Database string `json:"database" protected:"true"`
|
||||
StartCmd string `json:"start_cmd" protected:"true"`
|
||||
CADir string `json:"ca_dir" binding:"omitempty,url"`
|
||||
Demo bool `json:"demo" protected:"true"`
|
||||
PageSize int `json:"page_size" protected:"true"`
|
||||
GithubProxy string `json:"github_proxy" binding:"omitempty,url"`
|
||||
HttpHost string `json:"http_host" protected:"true"`
|
||||
HttpPort string `json:"http_port" protected:"true"`
|
||||
RunMode string `json:"run_mode" protected:"true"`
|
||||
JwtSecret string `json:"jwt_secret" protected:"true"`
|
||||
NodeSecret string `json:"node_secret" protected:"true"`
|
||||
HTTPChallengePort string `json:"http_challenge_port"`
|
||||
Email string `json:"email" protected:"true"`
|
||||
Database string `json:"database" protected:"true"`
|
||||
StartCmd string `json:"start_cmd" protected:"true"`
|
||||
CADir string `json:"ca_dir" binding:"omitempty,url"`
|
||||
Demo bool `json:"demo" protected:"true"`
|
||||
PageSize int `json:"page_size" protected:"true"`
|
||||
GithubProxy string `json:"github_proxy" binding:"omitempty,url"`
|
||||
CertRenewalInterval int `json:"cert_renewal_interval" binging:"min=7,max=21"`
|
||||
}
|
||||
|
||||
func (s *Server) GetCADir() string {
|
||||
|
@ -33,14 +34,15 @@ func (s *Server) GetCADir() string {
|
|||
}
|
||||
|
||||
var ServerSettings = Server{
|
||||
HttpHost: "0.0.0.0",
|
||||
HttpPort: "9000",
|
||||
RunMode: "debug",
|
||||
HTTPChallengePort: "9180",
|
||||
Database: "database",
|
||||
StartCmd: "login",
|
||||
Demo: false,
|
||||
PageSize: 10,
|
||||
CADir: "",
|
||||
GithubProxy: "",
|
||||
HttpHost: "0.0.0.0",
|
||||
HttpPort: "9000",
|
||||
RunMode: "debug",
|
||||
HTTPChallengePort: "9180",
|
||||
Database: "database",
|
||||
StartCmd: "login",
|
||||
Demo: false,
|
||||
PageSize: 10,
|
||||
CADir: "",
|
||||
GithubProxy: "",
|
||||
CertRenewalInterval: 7,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue