mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-23 18:15:26 +00:00
feat: add support for TLS with Postgres
This commit is contained in:
parent
193b4213b3
commit
4c7f54020b
5
app.go
5
app.go
@ -129,13 +129,16 @@ func NewHeadscale(cfg *Config) (*Headscale, error) {
|
|||||||
switch cfg.DBtype {
|
switch cfg.DBtype {
|
||||||
case Postgres:
|
case Postgres:
|
||||||
dbString = fmt.Sprintf(
|
dbString = fmt.Sprintf(
|
||||||
"host=%s port=%d dbname=%s user=%s password=%s sslmode=disable",
|
"host=%s port=%d dbname=%s user=%s password=%s",
|
||||||
cfg.DBhost,
|
cfg.DBhost,
|
||||||
cfg.DBport,
|
cfg.DBport,
|
||||||
cfg.DBname,
|
cfg.DBname,
|
||||||
cfg.DBuser,
|
cfg.DBuser,
|
||||||
cfg.DBpass,
|
cfg.DBpass,
|
||||||
)
|
)
|
||||||
|
if !cfg.DBssl {
|
||||||
|
dbString = dbString + " sslmode=disable"
|
||||||
|
}
|
||||||
case Sqlite:
|
case Sqlite:
|
||||||
dbString = cfg.DBpath
|
dbString = cfg.DBpath
|
||||||
default:
|
default:
|
||||||
|
@ -47,6 +47,7 @@ type Config struct {
|
|||||||
DBname string
|
DBname string
|
||||||
DBuser string
|
DBuser string
|
||||||
DBpass string
|
DBpass string
|
||||||
|
DBssl bool
|
||||||
|
|
||||||
TLS TLSConfig
|
TLS TLSConfig
|
||||||
|
|
||||||
@ -506,6 +507,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"),
|
||||||
|
|
||||||
TLS: GetTLSConfig(),
|
TLS: GetTLSConfig(),
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user