diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index 926168a3..1c73fd22 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -157,10 +157,16 @@ int main(int argc, char** argv) { auto* masterLookupStatement = Database::CreatePreppedStmt("SELECT id FROM `servers` WHERE `name` = 'master'"); auto* result = masterLookupStatement->executeQuery(); + auto master_server_ip = config.GetValue("master_ip"); + + if (master_server_ip == "") { + master_server_ip = Game::server->GetIP(); + } + //If we found a server, update it's IP and port to the current one. if (result->next()) { auto* updateStatement = Database::CreatePreppedStmt("UPDATE `servers` SET `ip` = ?, `port` = ? WHERE `id` = ?"); - updateStatement->setString(1, Game::server->GetIP()); + updateStatement->setString(1, master_server_ip); updateStatement->setInt(2, Game::server->GetPort()); updateStatement->setInt(3, result->getInt("id")); updateStatement->execute(); @@ -169,7 +175,7 @@ int main(int argc, char** argv) { else { //If we didn't find a server, create one. auto* insertStatement = Database::CreatePreppedStmt("INSERT INTO `servers` (`name`, `ip`, `port`, `state`, `version`) VALUES ('master', ?, ?, 0, 171023)"); - insertStatement->setString(1, Game::server->GetIP()); + insertStatement->setString(1, master_server_ip); insertStatement->setInt(2, Game::server->GetPort()); insertStatement->execute(); delete insertStatement; diff --git a/docker-compose.yml b/docker-compose.yml index eb7bb8a1..7446748e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,8 +30,10 @@ services: - database:/var/lib/mysql networks: - darkflame - ports: - - 3306:3306 # (optional) ports only exposed so that DB management tools can connect + # (optional) ports only exposed so that DB management tools can connect + # Remove the # of the next two lines to expose your database + # ports: + # - 3306:3306 darkflame: container_name: DarkflameServer diff --git a/docker/setup.sh b/docker/setup.sh index 98a92515..14d0951f 100755 --- a/docker/setup.sh +++ b/docker/setup.sh @@ -31,6 +31,9 @@ function update_ini_values() { update_ini worldconfig.ini chat_server_port $CHAT_SERVER_PORT update_ini worldconfig.ini max_clients $MAX_CLIENTS + # always use the internal docker hostname + update_ini masterconfig.ini master_ip "darkflame" + update_database_ini_values_for masterconfig.ini update_database_ini_values_for authconfig.ini update_database_ini_values_for chatconfig.ini diff --git a/resources/masterconfig.ini b/resources/masterconfig.ini index 120a3743..531234b6 100644 --- a/resources/masterconfig.ini +++ b/resources/masterconfig.ini @@ -7,6 +7,9 @@ mysql_password= # The public facing IP address. Can be 'localhost' for locally hosted servers external_ip=localhost +# The internal ip of the master server +master_ip=localhost + # Port number port=2000