Merge pull request #734 from gotify/panic-bool
fix: panic when setting bool via envvar
This commit is contained in:
commit
cc7da2ace3
|
|
@ -16,15 +16,15 @@ type Configuration struct {
|
|||
Port int `default:"80"`
|
||||
|
||||
SSL struct {
|
||||
Enabled *bool `default:"false"`
|
||||
RedirectToHTTPS *bool `default:"true"`
|
||||
Enabled bool `default:"false"`
|
||||
RedirectToHTTPS bool `default:"true"`
|
||||
ListenAddr string `default:""`
|
||||
Port int `default:"443"`
|
||||
CertFile string `default:""`
|
||||
CertKey string `default:""`
|
||||
LetsEncrypt struct {
|
||||
Enabled *bool `default:"false"`
|
||||
AcceptTOS *bool `default:"false"`
|
||||
Enabled bool `default:"false"`
|
||||
AcceptTOS bool `default:"false"`
|
||||
Cache string `default:"data/certs"`
|
||||
Hosts []string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ func Create(db *database.GormDatabase, vInfo *model.VersionInfo, conf *config.Co
|
|||
g.Use(gin.LoggerWithFormatter(logFormatter), gin.Recovery(), gerror.Handler(), location.Default())
|
||||
g.NoRoute(gerror.NotFound())
|
||||
|
||||
if conf.Server.SSL.Enabled != nil && conf.Server.SSL.RedirectToHTTPS != nil && *conf.Server.SSL.Enabled && *conf.Server.SSL.RedirectToHTTPS {
|
||||
if conf.Server.SSL.Enabled && conf.Server.SSL.RedirectToHTTPS {
|
||||
g.Use(func(ctx *gin.Context) {
|
||||
if ctx.Request.TLS != nil {
|
||||
ctx.Next()
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ func Run(router http.Handler, conf *config.Configuration) error {
|
|||
defer httpListener.Close()
|
||||
|
||||
s := &http.Server{Handler: router}
|
||||
if *conf.Server.SSL.Enabled {
|
||||
if *conf.Server.SSL.LetsEncrypt.Enabled {
|
||||
if conf.Server.SSL.Enabled {
|
||||
if conf.Server.SSL.LetsEncrypt.Enabled {
|
||||
applyLetsEncrypt(s, conf)
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ func getNetworkAndAddr(listenAddr string, port int) (string, string) {
|
|||
|
||||
func applyLetsEncrypt(s *http.Server, conf *config.Configuration) {
|
||||
certManager := autocert.Manager{
|
||||
Prompt: func(tosURL string) bool { return *conf.Server.SSL.LetsEncrypt.AcceptTOS },
|
||||
Prompt: func(tosURL string) bool { return conf.Server.SSL.LetsEncrypt.AcceptTOS },
|
||||
HostPolicy: autocert.HostWhitelist(conf.Server.SSL.LetsEncrypt.Hosts...),
|
||||
Cache: autocert.DirCache(conf.Server.SSL.LetsEncrypt.Cache),
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue