mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15: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" />
|
<AInput v-model:value="data.server.ca_dir" />
|
||||||
</AFormItem>
|
</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>
|
</AForm>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ const data = ref<Settings>({
|
||||||
github_proxy: '',
|
github_proxy: '',
|
||||||
ca_dir: '',
|
ca_dir: '',
|
||||||
node_secret: '',
|
node_secret: '',
|
||||||
|
cert_renewal_interval: 7,
|
||||||
},
|
},
|
||||||
nginx: {
|
nginx: {
|
||||||
access_log_path: '',
|
access_log_path: '',
|
||||||
|
|
|
@ -10,6 +10,7 @@ export interface Settings {
|
||||||
github_proxy: string
|
github_proxy: string
|
||||||
email: string
|
email: string
|
||||||
ca_dir: string
|
ca_dir: string
|
||||||
|
cert_renewal_interval: number
|
||||||
}
|
}
|
||||||
nginx: {
|
nginx: {
|
||||||
access_log_path: string
|
access_log_path: string
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||||
"github.com/0xJacky/Nginx-UI/internal/notification"
|
"github.com/0xJacky/Nginx-UI/internal/notification"
|
||||||
"github.com/0xJacky/Nginx-UI/model"
|
"github.com/0xJacky/Nginx-UI/model"
|
||||||
|
"github.com/0xJacky/Nginx-UI/settings"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -59,8 +60,8 @@ func renew(certModel *model.Cert) {
|
||||||
notification.Error("Renew Certificate Error", strings.Join(certModel.Domains, ", "))
|
notification.Error("Renew Certificate Error", strings.Join(certModel.Domains, ", "))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if time.Now().Sub(cert.NotBefore).Hours()/24 < 7 {
|
if int(time.Now().Sub(cert.NotBefore).Hours()/24) < settings.ServerSettings.CertRenewalInterval {
|
||||||
// not between 1 week, ignore this certificate
|
// not after settings.ServerSettings.CertRenewalInterval, ignore
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,19 +5,20 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
HttpHost string `json:"http_host" protected:"true"`
|
HttpHost string `json:"http_host" protected:"true"`
|
||||||
HttpPort string `json:"http_port" protected:"true"`
|
HttpPort string `json:"http_port" protected:"true"`
|
||||||
RunMode string `json:"run_mode" protected:"true"`
|
RunMode string `json:"run_mode" protected:"true"`
|
||||||
JwtSecret string `json:"jwt_secret" protected:"true"`
|
JwtSecret string `json:"jwt_secret" protected:"true"`
|
||||||
NodeSecret string `json:"node_secret" protected:"true"`
|
NodeSecret string `json:"node_secret" protected:"true"`
|
||||||
HTTPChallengePort string `json:"http_challenge_port"`
|
HTTPChallengePort string `json:"http_challenge_port"`
|
||||||
Email string `json:"email" protected:"true"`
|
Email string `json:"email" protected:"true"`
|
||||||
Database string `json:"database" protected:"true"`
|
Database string `json:"database" protected:"true"`
|
||||||
StartCmd string `json:"start_cmd" protected:"true"`
|
StartCmd string `json:"start_cmd" protected:"true"`
|
||||||
CADir string `json:"ca_dir" binding:"omitempty,url"`
|
CADir string `json:"ca_dir" binding:"omitempty,url"`
|
||||||
Demo bool `json:"demo" protected:"true"`
|
Demo bool `json:"demo" protected:"true"`
|
||||||
PageSize int `json:"page_size" protected:"true"`
|
PageSize int `json:"page_size" protected:"true"`
|
||||||
GithubProxy string `json:"github_proxy" binding:"omitempty,url"`
|
GithubProxy string `json:"github_proxy" binding:"omitempty,url"`
|
||||||
|
CertRenewalInterval int `json:"cert_renewal_interval" binging:"min=7,max=21"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) GetCADir() string {
|
func (s *Server) GetCADir() string {
|
||||||
|
@ -33,14 +34,15 @@ func (s *Server) GetCADir() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var ServerSettings = Server{
|
var ServerSettings = Server{
|
||||||
HttpHost: "0.0.0.0",
|
HttpHost: "0.0.0.0",
|
||||||
HttpPort: "9000",
|
HttpPort: "9000",
|
||||||
RunMode: "debug",
|
RunMode: "debug",
|
||||||
HTTPChallengePort: "9180",
|
HTTPChallengePort: "9180",
|
||||||
Database: "database",
|
Database: "database",
|
||||||
StartCmd: "login",
|
StartCmd: "login",
|
||||||
Demo: false,
|
Demo: false,
|
||||||
PageSize: 10,
|
PageSize: 10,
|
||||||
CADir: "",
|
CADir: "",
|
||||||
GithubProxy: "",
|
GithubProxy: "",
|
||||||
|
CertRenewalInterval: 7,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue