mirror of
https://github.com/idanoo/autobrr
synced 2025-07-24 01:09:13 +00:00
feat(database): postgres set ssl mode (#1245)
* feat(database): postgres set ssl mode * feat(database): postgres set extra params
This commit is contained in:
parent
8c89481d88
commit
73e76c4214
3 changed files with 43 additions and 36 deletions
|
@ -199,6 +199,8 @@ func (c *AppConfig) defaults() {
|
||||||
PostgresDatabase: "",
|
PostgresDatabase: "",
|
||||||
PostgresUser: "",
|
PostgresUser: "",
|
||||||
PostgresPass: "",
|
PostgresPass: "",
|
||||||
|
PostgresSSLMode: "disable",
|
||||||
|
PostgresExtraParams: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,10 @@ func NewDB(cfg *domain.Config, log logger.Logger) (*DB, error) {
|
||||||
if cfg.PostgresHost == "" || cfg.PostgresPort == 0 || cfg.PostgresDatabase == "" {
|
if cfg.PostgresHost == "" || cfg.PostgresPort == 0 || cfg.PostgresDatabase == "" {
|
||||||
return nil, errors.New("postgres: bad variables")
|
return nil, errors.New("postgres: bad variables")
|
||||||
}
|
}
|
||||||
db.DSN = fmt.Sprintf("postgres://%v:%v@%v:%d/%v?sslmode=disable", cfg.PostgresUser, cfg.PostgresPass, cfg.PostgresHost, cfg.PostgresPort, cfg.PostgresDatabase)
|
db.DSN = fmt.Sprintf("postgres://%v:%v@%v:%d/%v?sslmode=%v", cfg.PostgresUser, cfg.PostgresPass, cfg.PostgresHost, cfg.PostgresPort, cfg.PostgresDatabase, cfg.PostgresSSLMode)
|
||||||
|
if cfg.PostgresExtraParams != "" {
|
||||||
|
db.DSN = fmt.Sprintf("%s&%s", db.DSN, cfg.PostgresExtraParams)
|
||||||
|
}
|
||||||
db.Driver = "postgres"
|
db.Driver = "postgres"
|
||||||
databaseDriver = "postgres"
|
databaseDriver = "postgres"
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -22,6 +22,8 @@ type Config struct {
|
||||||
PostgresDatabase string `toml:"postgresDatabase"`
|
PostgresDatabase string `toml:"postgresDatabase"`
|
||||||
PostgresUser string `toml:"postgresUser"`
|
PostgresUser string `toml:"postgresUser"`
|
||||||
PostgresPass string `toml:"postgresPass"`
|
PostgresPass string `toml:"postgresPass"`
|
||||||
|
PostgresSSLMode string `toml:"postgresSSLMode"`
|
||||||
|
PostgresExtraParams string `toml:"PostgresExtraParams"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigUpdate struct {
|
type ConfigUpdate struct {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue