diff options
author | Chuck Miller <shadowmil@gmail.com> | 2009-10-07 13:39:24 -0400 |
---|---|---|
committer | Chuck Miller <shadowmil@gmail.com> | 2009-10-07 13:39:24 -0400 |
commit | c19244ddca910dbfc566a61772296cb59fa28d80 (patch) | |
tree | 5771c2d385487e311959f48e3f0de47e264712ff /src/account-server/serverhandler.cpp | |
parent | 9a35609facf9fbb511467d607f83ecd1f4d1ee1b (diff) | |
download | manaserv-c19244ddca910dbfc566a61772296cb59fa28d80.tar.gz manaserv-c19244ddca910dbfc566a61772296cb59fa28d80.tar.bz2 manaserv-c19244ddca910dbfc566a61772296cb59fa28d80.tar.xz manaserv-c19244ddca910dbfc566a61772296cb59fa28d80.zip |
Adds server auth, also adds the "net_password" configure option
Diffstat (limited to 'src/account-server/serverhandler.cpp')
-rw-r--r-- | src/account-server/serverhandler.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp index 5bfa6a57..ff523b49 100644 --- a/src/account-server/serverhandler.cpp +++ b/src/account-server/serverhandler.cpp @@ -31,6 +31,7 @@ #include "account-server/dalstorage.hpp" #include "chat-server/post.hpp" #include "common/transaction.hpp" +#include "common/configuration.hpp" #include "net/connectionhandler.hpp" #include "net/messageout.hpp" #include "net/netcomputer.hpp" @@ -176,6 +177,7 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) // TODO: check the credentials of the game server server->address = msg.readString(); server->port = msg.readShort(); + const std::string password = msg.readString(); // checks the version of the remote item database with our local copy unsigned int dbversion = msg.readLong(); @@ -194,7 +196,18 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) LOG_DEBUG("Item database of game server has a wrong version"); outMsg.writeShort(DATA_VERSION_OUTDATED); } - comp->send(outMsg); + if (password == Configuration::getValue("net_password", "P@s$w0rd")) + { + outMsg.writeShort(PASSWORD_OK); + comp->send(outMsg); + } + else + { + LOG_INFO("The password given by " << server->address << ':' << server->port << " was bad."); + outMsg.writeShort(PASSWORD_BAD); + comp->disconnect(outMsg); + break; + } LOG_INFO("Game server " << server->address << ':' << server->port << " wants to register " << (msg.getUnreadLength() / 2) |