From c19244ddca910dbfc566a61772296cb59fa28d80 Mon Sep 17 00:00:00 2001 From: Chuck Miller Date: Wed, 7 Oct 2009 13:39:24 -0400 Subject: Adds server auth, also adds the "net_password" configure option --- src/game-server/accountconnection.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/game-server/accountconnection.cpp') diff --git a/src/game-server/accountconnection.cpp b/src/game-server/accountconnection.cpp index 41f7162..13c924a 100644 --- a/src/game-server/accountconnection.cpp +++ b/src/game-server/accountconnection.cpp @@ -67,11 +67,14 @@ bool AccountConnection::start() Configuration::getValue("net_gameServerAddress", "localhost"); const int gameServerPort = Configuration::getValue("net_gameServerPort", DEFAULT_SERVER_PORT + 3); + const std::string password = + Configuration::getValue("net_password", "P@s$w0rd"); // Register with the account server and send the list of maps we handle MessageOut msg(GAMSG_REGISTER); msg.writeString(gameServerAddress); msg.writeShort(gameServerPort); + msg.writeString(password); msg.writeLong(ItemManager::GetDatabaseVersion()); const MapManager::Maps &m = MapManager::getMaps(); for (MapManager::Maps::const_iterator i = m.begin(), i_end = m.end(); @@ -113,6 +116,12 @@ void AccountConnection::processMessage(MessageIn &msg) { LOG_DEBUG("Local item database is in sync with account server."); } + if (msg.readShort() != PASSWORD_OK) + { + LOG_ERROR("This game server sent a invaild password"); + stop(); + exit(1); + } } break; case AGMSG_PLAYER_ENTER: -- cgit