Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PgSQL SSL and PgSQL dsn hostname. #437 #438

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ func ConnectString(dbName string) (string, error) {
var dsn string
driver := config.Setting.DBDriver
addr := strings.Split(config.Setting.DBAddr, ":")
if len(addr) != 2 {
return "", fmt.Errorf("wrong database connection format: %v, it should be localhost:3306", config.Setting.DBAddr)
}
//if len(addr) != 2 {
// return "", fmt.Errorf("wrong database connection format: %v, it should be localhost:3306", config.Setting.DBAddr)
//}
if (addr[1] == "3306" && driver == "postgres") ||
addr[1] == "5432" && driver == "mysql" {
return "", fmt.Errorf("don't use port: %s, for db driver: %s", addr[1], driver)
Expand All @@ -107,12 +107,14 @@ func ConnectString(dbName string) (string, error) {
addr[0] = addr[1]
addr[1] = "''"
}
dsn = "sslmode=disable connect_timeout=4" +
sslmode = config.Setting.DBSSLMode or "disable"
dsn = "connect_timeout=4" +
" host=" + addr[0] +
" port=" + addr[1] +
" dbname=" + dbName +
" user=" + config.Setting.DBUser +
" password=" + config.Setting.DBPass
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing + on the end

" sslmode=" + sslmode
}
return dsn, nil
}
Expand Down
1 change: 1 addition & 0 deletions example/homer7_config/heplify-server.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ DBUser = "postgres"
DBPass = ""
DBDataTable = "homer_data"
DBConfTable = "homer_config"
DBSSLMode = "disable"
DBBulk = 200
DBTimer = 4
DBBuffer = 400000
Expand Down