Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

feat: add config to enable/disable postgres ssl mode

Vivek R09117426ee77
diff --git a/config.toml.sample b/config.toml.sample
index 12472f7d..1b9f12bf 100644
--- a/config.toml.sample
+++ b/config.toml.sample
@@ -35,7 +35,7 @@ upload_uri = "/uploads"
# Maximum concurrent workers that will attempt to send messages
# simultaneously. This should depend on the number of CPUs the
# machine has and also the number of simultaenous e-mails the
-# mail server will
+# mail server will
concurrency = 100
# The number of errors (eg: SMTP timeouts while e-mailing) a running
@@ -51,6 +51,7 @@ port = 5432
user = "listmonk"
password = ""
database = "listmonk"
+ssl_mode = "disable"
# TQekh4quVgGc3HQ
diff --git a/main.go b/main.go
index 9b2c525f..9ea07780 100644
--- a/main.go
+++ b/main.go
@@ -148,7 +148,8 @@ func main() {
viper.GetInt("db.port"),
viper.GetString("db.user"),
viper.GetString("db.password"),
- viper.GetString("db.database"))
+ viper.GetString("db.database"),
+ viper.GetString("db.ssl_mode"))
if err != nil {
logger.Fatalf("error connecting to DB: %v", err)
}
diff --git a/queries.go b/queries.go
index fa1de54a..b14a508d 100644
--- a/queries.go
+++ b/queries.go
@@ -79,9 +79,9 @@ type Queries struct {
}
// connectDB initializes a database connection.
-func connectDB(host string, port int, user, pwd, dbName string) (*sqlx.DB, error) {
+func connectDB(host string, port int, user, pwd, dbName string, sslMode string) (*sqlx.DB, error) {
db, err := sqlx.Connect("postgres",
- fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s", host, port, user, pwd, dbName))
+ fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s", host, port, user, pwd, dbName, sslMode))
if err != nil {
return nil, err
}