limted guest login - guest playerrights check done

This commit is contained in:
Kai Philipp
2016-06-18 15:42:38 +02:00
parent 935ec2ad92
commit cf280f0478
2 changed files with 13 additions and 14 deletions
+4 -4
View File
@@ -1008,9 +1008,9 @@ ServerLobbyThread::HandleNetPacketInit(boost::shared_ptr<SessionData> session, c
LOG_VERBOSE("Received init for session #" << session->GetId() << ".");
// @XXX: debug tests
if(m_sessionManager.IsGuestConnectedMultiple(session->GetClientAddr())){
LOG_ERROR("Guest with IP " << session->GetClientAddr() << " already connected! Should be declined!");
}
//if(m_sessionManager.IsGuestConnectedMultiple(session->GetClientAddr())){
// LOG_ERROR("Guest with IP " << session->GetClientAddr() << " already connected! Should be declined!");
//}
// @XXX: end debug tests
// Before any other processing, perform some denial of service and
@@ -1065,7 +1065,7 @@ ServerLobbyThread::HandleNetPacketInit(boost::shared_ptr<SessionData> session, c
}
// @XXX: check if a guest session with same ip is already connected - decline if true
if(m_sessionManager.IsGuestConnectedMultiple(session->GetClientAddr())){
LOG_ERROR("Guest with IP " << session->GetClientAddr() << " already connected! Decline!");
//LOG_ERROR("Guest with IP " << session->GetClientAddr() << " already connected! Decline!");
validGuest = false;
}
}
+9 -10
View File
@@ -256,19 +256,18 @@ SessionManager::IsGuestConnectedMultiple(const std::string &clientAddress) const
SessionMap::const_iterator i = m_sessionMap.begin();
SessionMap::const_iterator end = m_sessionMap.end();
int j = 0;
while (i != end) {
// @XXX: comparing PlayerRights does not yet work (e.g. throws an exception)
//if ((*i).second->GetClientAddr() == clientAddress && (*i).second->GetPlayerData()->GetRights() == PLAYER_RIGHTS_GUEST) {
if ((*i).second->GetClientAddr() == clientAddress) {
j++;
}
boost::shared_ptr<PlayerData> tmpPlayer(i->second->GetPlayerData());
// @XXX: productive:
//if(tmpPlayer && tmpPlayer->GetRights() == PLAYER_RIGHTS_GUEST && i->second->GetClientAddr() == clientAddress){
// @XXX: debug:
// if(tmpPlayer && tmpPlayer->GetRights() == PLAYER_RIGHTS_NORMAL && i->second->GetClientAddr() == clientAddress){
if(tmpPlayer && tmpPlayer->GetRights() == PLAYER_RIGHTS_GUEST && i->second->GetClientAddr() == clientAddress){
retVal = true;
break;
}
++i;
}
if (j > 1) {
retVal = true;
}
return retVal;
}