From 72b9803a0833dcfd5c85b71ccbbbb0b41816e76f Mon Sep 17 00:00:00 2001 From: "Orville Q. Song" Date: Fri, 4 Nov 2022 01:11:22 +0800 Subject: [PATCH] Change DBssl to string --- app.go | 9 +++++++-- config.go | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app.go b/app.go index 26a88ca7..b8a8c9c6 100644 --- a/app.go +++ b/app.go @@ -11,6 +11,7 @@ import ( "os" "os/signal" "sort" + "strconv" "strings" "sync" "syscall" @@ -127,8 +128,12 @@ func NewHeadscale(cfg *Config) (*Headscale, error) { cfg.DBuser, ) - if !cfg.DBssl { - dbString += " sslmode=disable" + if s, err := strconv.ParseBool(cfg.DBssl); err == nil { + if !s { + dbString += " sslmode=disable" + } + } else { + dbString += fmt.Sprintf(" sslmode=%s", cfg.DBssl) } if cfg.DBport != 0 { diff --git a/config.go b/config.go index b4cad5be..11883565 100644 --- a/config.go +++ b/config.go @@ -51,7 +51,7 @@ type Config struct { DBname string DBuser string DBpass string - DBssl bool + DBssl string TLS TLSConfig @@ -545,7 +545,7 @@ func GetHeadscaleConfig() (*Config, error) { DBname: viper.GetString("db_name"), DBuser: viper.GetString("db_user"), DBpass: viper.GetString("db_pass"), - DBssl: viper.GetBool("db_ssl"), + DBssl: viper.GetString("db_ssl"), TLS: GetTLSConfig(),