Change DBssl to string
This commit is contained in:
parent
99e33181b2
commit
72b9803a08
2 changed files with 9 additions and 4 deletions
9
app.go
9
app.go
|
@ -11,6 +11,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
@ -127,8 +128,12 @@ func NewHeadscale(cfg *Config) (*Headscale, error) {
|
||||||
cfg.DBuser,
|
cfg.DBuser,
|
||||||
)
|
)
|
||||||
|
|
||||||
if !cfg.DBssl {
|
if s, err := strconv.ParseBool(cfg.DBssl); err == nil {
|
||||||
dbString += " sslmode=disable"
|
if !s {
|
||||||
|
dbString += " sslmode=disable"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dbString += fmt.Sprintf(" sslmode=%s", cfg.DBssl)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.DBport != 0 {
|
if cfg.DBport != 0 {
|
||||||
|
|
|
@ -51,7 +51,7 @@ type Config struct {
|
||||||
DBname string
|
DBname string
|
||||||
DBuser string
|
DBuser string
|
||||||
DBpass string
|
DBpass string
|
||||||
DBssl bool
|
DBssl string
|
||||||
|
|
||||||
TLS TLSConfig
|
TLS TLSConfig
|
||||||
|
|
||||||
|
@ -545,7 +545,7 @@ func GetHeadscaleConfig() (*Config, error) {
|
||||||
DBname: viper.GetString("db_name"),
|
DBname: viper.GetString("db_name"),
|
||||||
DBuser: viper.GetString("db_user"),
|
DBuser: viper.GetString("db_user"),
|
||||||
DBpass: viper.GetString("db_pass"),
|
DBpass: viper.GetString("db_pass"),
|
||||||
DBssl: viper.GetBool("db_ssl"),
|
DBssl: viper.GetString("db_ssl"),
|
||||||
|
|
||||||
TLS: GetTLSConfig(),
|
TLS: GetTLSConfig(),
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue