Skip to content

Commit 6b3ff77

Browse files
committed
fix: panic when setting bool via envvar
$ docker run -e GOTIFY_SERVER_SSL_ENABLED=true --rm gotify/server:2.6.0 Starting Gotify version 2.6.0@2024-11-15-19:19:19 panic: reflect.Set: value of type bool is not assignable to type *bool goroutine 1 [running]: reflect.Value.assignTo({0xf5e000?, 0x1c375a8?, 0x19?}, {0x108809b, 0xb}, 0xf42960, 0x0) /usr/local/go/src/reflect/value.go:3358 +0x299 reflect.Value.Set({0xf42960?, 0xc0000cd200?, 0x4?}, {0xf5e000?, 0x1c375a8?, 0xf42960?}) /usr/local/go/src/reflect/value.go:2313 +0xe6 github.com/jinzhu/configor.(*Configor).processTags(0xc0002f0270, {0xc0002eecc0?, 0xc0000cd200?}, {0xc0002ef0c0, 0x3, 0x4}) /go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:307 +0xc11 github.com/jinzhu/configor.(*Configor).processTags(0xc0002f0270, {0xc0002eec80?, 0xc0000cd1e0?}, {0xc0002ad880, 0x2, 0x2}) /go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:330 +0xe79 github.com/jinzhu/configor.(*Configor).processTags(0xc0002f0270, {0xf41420?, 0xc0000cd1e0?}, {0xc0002f0610, 0x1, 0x1}) /go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:330 +0xe79 github.com/jinzhu/configor.(*Configor).load(0xc0002f0270, {0xf41420, 0xc0000cd1e0}, 0x0, {0xc0002ad7a0?, 0x1c7c000?, 0xc0002ad7a0?}) /go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:415 +0x3f8 github.com/jinzhu/configor.(*Configor).Load(0xc0002f0270, {0xf41420, 0xc0000cd1e0}, {0xc0002ad7a0, 0x2, 0x2}) /go/pkg/mod/github.com/jinzhu/[email protected]/configor.go:92 +0x13c github.com/gotify/server/v2/config.Get() /src/gotify/config/config.go:69 +0xf3 main.main() /src/gotify/app.go:34 +0x1e5
1 parent 8639316 commit 6b3ff77

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Diff for: config/config.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ type Configuration struct {
1616
Port int `default:"80"`
1717

1818
SSL struct {
19-
Enabled *bool `default:"false"`
20-
RedirectToHTTPS *bool `default:"true"`
19+
Enabled bool `default:"false"`
20+
RedirectToHTTPS bool `default:"true"`
2121
ListenAddr string `default:""`
2222
Port int `default:"443"`
2323
CertFile string `default:""`
2424
CertKey string `default:""`
2525
LetsEncrypt struct {
26-
Enabled *bool `default:"false"`
27-
AcceptTOS *bool `default:"false"`
26+
Enabled bool `default:"false"`
27+
AcceptTOS bool `default:"false"`
2828
Cache string `default:"data/certs"`
2929
Hosts []string
3030
}

Diff for: router/router.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func Create(db *database.GormDatabase, vInfo *model.VersionInfo, conf *config.Co
4141
g.Use(gin.LoggerWithFormatter(logFormatter), gin.Recovery(), gerror.Handler(), location.Default())
4242
g.NoRoute(gerror.NotFound())
4343

44-
if conf.Server.SSL.Enabled != nil && conf.Server.SSL.RedirectToHTTPS != nil && *conf.Server.SSL.Enabled && *conf.Server.SSL.RedirectToHTTPS {
44+
if conf.Server.SSL.Enabled && conf.Server.SSL.RedirectToHTTPS {
4545
g.Use(func(ctx *gin.Context) {
4646
if ctx.Request.TLS != nil {
4747
ctx.Next()

Diff for: runner/runner.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ func Run(router http.Handler, conf *config.Configuration) error {
2828
defer httpListener.Close()
2929

3030
s := &http.Server{Handler: router}
31-
if *conf.Server.SSL.Enabled {
32-
if *conf.Server.SSL.LetsEncrypt.Enabled {
31+
if conf.Server.SSL.Enabled {
32+
if conf.Server.SSL.LetsEncrypt.Enabled {
3333
applyLetsEncrypt(s, conf)
3434
}
3535

@@ -93,7 +93,7 @@ func getNetworkAndAddr(listenAddr string, port int) (string, string) {
9393

9494
func applyLetsEncrypt(s *http.Server, conf *config.Configuration) {
9595
certManager := autocert.Manager{
96-
Prompt: func(tosURL string) bool { return *conf.Server.SSL.LetsEncrypt.AcceptTOS },
96+
Prompt: func(tosURL string) bool { return conf.Server.SSL.LetsEncrypt.AcceptTOS },
9797
HostPolicy: autocert.HostWhitelist(conf.Server.SSL.LetsEncrypt.Hosts...),
9898
Cache: autocert.DirCache(conf.Server.SSL.LetsEncrypt.Cache),
9999
}

0 commit comments

Comments
 (0)