Two-step login system works perfectly; can't shut the server down

I've also removed a large amount of commented and uncommented code from
in_world.cpp, simply because so much code was dummied out. I can readd
this code as I reimeplement various features.
This commit is contained in:
Kayne Ruse
2014-11-26 10:14:26 +11:00
parent 584b6ea303
commit e5abd51f76
4 changed files with 119 additions and 375 deletions
+1 -1
View File
@@ -167,7 +167,7 @@ void ServerApplication::Proc() {
while(running) {
//suck in the waiting packets & process them
while(UDPNetworkUtility::GetSingleton().Receive(packetBuffer)) {
while(network.Receive(packetBuffer)) {
try {
HandlePacket(packetBuffer);
}
+24 -2
View File
@@ -123,8 +123,18 @@ void ServerApplication::HandleLoginRequest(ClientPacket* const argPacket) {
void ServerApplication::HandleLogoutRequest(ClientPacket* const argPacket) {
//get the account and client data
AccountData* accountData = accountMgr.Get(argPacket->accountIndex);
ClientData* clientData = clientMgr.Get(accountData->GetClientIndex());
if (!accountData) {
return;
}
ClientData* clientData = clientMgr.Get(accountData->GetClientIndex());
if (!clientData) {
std::ostringstream msg;
msg << "No client found for an account: " << accountData->GetUserName();
throw(std::logic_error(msg.str()));
}
//check for fraud
if (clientData->GetAddress() != argPacket->srcAddress) {
std::cerr << "Falsified logout detected targeting: " << accountData->GetUsername() << std::endl;
return;
@@ -133,7 +143,6 @@ void ServerApplication::HandleLogoutRequest(ClientPacket* const argPacket) {
//send the logout response
ClientPacket newPacket;
newPacket.type = SerialPacketType::LOGOUT_RESPONSE;
newPacket.clientIndex = accountData->GetClientIndex();
newPacket.accountIndex = argPacket->accountIndex;
network.SendTo(clientData->GetAddress(), static_cast<SerialPacket*>(&newPacket));
@@ -158,7 +167,11 @@ void ServerApplication::HandleLogoutRequest(ClientPacket* const argPacket) {
void ServerApplication::HandleDisconnectRequest(ClientPacket* const argPacket) {
//get the client data
ClientData* clientData = clientMgr.Get(argPacket->clientIndex);
if (!clientData) {
return;
}
//check for fraud
if (clientData->GetAddress() != argPacket->srcAddress) {
std::cerr << "Falsified disconnection detected targeting: " << argPacket->clientIndex << std::endl;
return;
@@ -206,8 +219,17 @@ void ServerApplication::HandleDisconnectRequest(ClientPacket* const argPacket) {
void ServerApplication::HandleShutdownRequest(ClientPacket* const argPacket) {
//get the account and client data
AccountData* accountData = accountMgr.Get(argPacket->accountIndex);
if (!accountData) {
return;
}
ClientData* clientData = clientMgr.Get(accountData->GetClientIndex());
if (!clientData) {
std::ostringstream msg;
msg << "No client found for an account: " << accountData->GetUserName();
throw(std::logic_error(msg.str()));
}
//check for fraud
if (clientData->GetAddress() != argPacket->srcAddress || accountData->GetAdministrator() != true) {
std::cerr << "Falsified server shutdown detected from: " << accountData->GetUsername() << std::endl;
return;