Skip to content

Commit

Permalink
Refine DB config handling (no longer ignores port)
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzmbrzl committed Aug 20, 2024
1 parent f6ab1b6 commit 21adde2
Showing 1 changed file with 39 additions and 13 deletions.
52 changes: 39 additions & 13 deletions src/murmur/Meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,14 +731,30 @@ const ::mumble::db::ConnectionParameter &Meta::getConnectionParameter() {
}

if (isSQLite) {
if (Meta::mp.iSQLiteWAL == 1) {
qFatal("SQLite WAL = 1 option no longer supported. Either enable fully (WAL = 2) or disable (WAL = 0)");
}
#ifdef MUMBLE_DISABLE_SQLITE
qFatal("Your version of the Mumble server has been compiled without support for SQLite - choose a different DB "
"backend");
#endif

if (Meta::mp.iSQLiteWAL == 1) {
qFatal("SQLite WAL = 1 option no longer supported. Either enable fully (WAL = 2) or disable (WAL = 0)");
}
if (Meta::mp.iSQLiteWAL > 2) {
qFatal("Invalid value for sqlite_wal option. Allowed values are 0 or 2.");
}
if (!Meta::mp.qsDBUserName.isEmpty()) {
qFatal("When using a SQLite database, specifying a username doesn't make sense");
}
if (!Meta::mp.qsDBPassword.isEmpty()) {
qFatal("When using a SQLite database, specifying a password doesn't make sense");
}
if (!Meta::mp.qsDBHostName.isEmpty()) {
qFatal("When using a SQLite database, specifying a host doesn't make sense");
}
if (Meta::mp.iDBPort > 0) {
qFatal("When using a SQLite database, specifying a port doesn't make sense");
}

static ::mumble::db::SQLiteConnectionParameter sqliteConnection(Meta::mp.qsDatabase.toStdString(),
Meta::mp.iSQLiteWAL > 0);

Expand All @@ -749,19 +765,24 @@ const ::mumble::db::ConnectionParameter &Meta::getConnectionParameter() {
qFatal("Your version of the Mumble server has been compiled without support for MySQL - choose a different DB "
"backend");
#endif
static ::mumble::db::MySQLConnectionParameter mysqlConnection(Meta::mp.qsDatabase.toStdString());

if (!Meta::mp.qsDBHostName.isEmpty()) {
mysqlConnection.host = Meta::mp.qsDBHostName.toStdString();
if (Meta::mp.qsDatabase.isEmpty()) {
qFatal("When using a MySQL database, a database name must be specified");
}

static ::mumble::db::MySQLConnectionParameter mysqlConnection(Meta::mp.qsDatabase.toStdString());

if (!Meta::mp.qsDBUserName.isEmpty()) {
mysqlConnection.userName = Meta::mp.qsDBUserName.toStdString();
}

if (!Meta::mp.qsDBPassword.isEmpty()) {
mysqlConnection.password = Meta::mp.qsDBPassword.toStdString();
}
if (!Meta::mp.qsDBHostName.isEmpty()) {
mysqlConnection.host = Meta::mp.qsDBHostName.toStdString();
}
if (Meta::mp.iDBPort > 0) {
mysqlConnection.port = std::to_string(Meta::mp.iDBPort);
}

return mysqlConnection;
} else if (boost::iequals(Meta::mp.qsDBDriver.toStdString(), "qpsql")
Expand All @@ -771,19 +792,24 @@ const ::mumble::db::ConnectionParameter &Meta::getConnectionParameter() {
qFatal("Your version of the Mumble server has been compiled without support for PostgreSQL - choose a "
"different DB backend");
#endif
static ::mumble::db::PostgreSQLConnectionParameter postgresqlConnection(Meta::mp.qsDatabase.toStdString());

if (!Meta::mp.qsDBHostName.isEmpty()) {
postgresqlConnection.host = Meta::mp.qsDBHostName.toStdString();
if (Meta::mp.qsDatabase.isEmpty()) {
qFatal("When using a PostgreSQL database, a database name must be specified");
}

static ::mumble::db::PostgreSQLConnectionParameter postgresqlConnection(Meta::mp.qsDatabase.toStdString());

if (!Meta::mp.qsDBUserName.isEmpty()) {
postgresqlConnection.userName = Meta::mp.qsDBUserName.toStdString();
}

if (!Meta::mp.qsDBPassword.isEmpty()) {
postgresqlConnection.password = Meta::mp.qsDBPassword.toStdString();
}
if (!Meta::mp.qsDBHostName.isEmpty()) {
postgresqlConnection.host = Meta::mp.qsDBHostName.toStdString();
}
if (Meta::mp.iDBPort > 0) {
postgresqlConnection.port = std::to_string(Meta::mp.iDBPort);
}

return postgresqlConnection;
} else {
Expand Down

0 comments on commit 21adde2

Please sign in to comment.