limitrank - draft with return false always
This commit is contained in:
@@ -1427,13 +1427,18 @@ ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr<SessionData> sessio
|
|||||||
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_NOT_INVITED);
|
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_NOT_INVITED);
|
||||||
} else if (!game->CheckPassword(password)) {
|
} else if (!game->CheckPassword(password)) {
|
||||||
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_INVALID_PASSWORD);
|
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_INVALID_PASSWORD);
|
||||||
} else if (tmpData.gameType == GAME_TYPE_RANKING
|
} else if (tmpData.gameType == GAME_TYPE_RANKING) {
|
||||||
&& !joinGame.spectateonly()
|
if(!joinGame.spectateonly()
|
||||||
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR
|
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR
|
||||||
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4V6
|
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4V6
|
||||||
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4
|
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4
|
||||||
&& game->IsClientAddressConnected(session->GetClientAddr())) {
|
&& game->IsClientAddressConnected(session->GetClientAddr())) {
|
||||||
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
|
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
|
||||||
|
}else if (!session->IsPlayerAllowedToJoinLimitRank(session->GetPlayerData()->GetUniqueId())) {
|
||||||
|
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MoveSessionToGame(game, session, joinGame.autoleave(), false);
|
MoveSessionToGame(game, session, joinGame.autoleave(), false);
|
||||||
|
|||||||
@@ -38,6 +38,8 @@
|
|||||||
#include <net/websocketdata.h>
|
#include <net/websocketdata.h>
|
||||||
#include <gsasl.h>
|
#include <gsasl.h>
|
||||||
|
|
||||||
|
// #include <ctime> // @TODO: remove if really not necessary
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using boost::asio::ip::tcp;
|
using boost::asio::ip::tcp;
|
||||||
|
|
||||||
@@ -398,6 +400,20 @@ SessionData::GetPlayerData()
|
|||||||
return m_playerData;
|
return m_playerData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SessionData::SetPlayerLastGames(std::array<std::time_t> lastGames)
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||||
|
m_lastGames = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::array<std::time_t>
|
||||||
|
SessionData::GetPlayerLastGames()
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||||
|
return m_lastGames;
|
||||||
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
SessionData::GetRemoteIPAddressFromSocket() const
|
SessionData::GetRemoteIPAddressFromSocket() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,9 +34,13 @@
|
|||||||
#include <net/serverexception.h>
|
#include <net/serverexception.h>
|
||||||
#include <net/socket_msg.h>
|
#include <net/socket_msg.h>
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define SERVER_MAX_GUEST_USERS_LOBBY 50 // LG: Maximum number of guests users in lobby allowed
|
#define SERVER_MAX_GUEST_USERS_LOBBY 50 // LG: Maximum number of guests users in lobby allowed
|
||||||
|
#define SERVER_ALLOWED_RANKING_GAMES_PER_MINUTES 5
|
||||||
|
#define SERVER_ALLOWED_RANKING_GAMES_MINUTES 60
|
||||||
|
|
||||||
SessionManager::SessionManager()
|
SessionManager::SessionManager()
|
||||||
{
|
{
|
||||||
@@ -229,6 +233,41 @@ SessionManager::IsPlayerConnected(unsigned uniqueId) const
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SessionManager::IsPlayerAllowedToJoinLimitRank(const string &playerName) const
|
||||||
|
{
|
||||||
|
bool retVal = false;
|
||||||
|
|
||||||
|
// boost::shared_ptr<SessionData> tmpSession = GetSessionByPlayerName(playerName);
|
||||||
|
|
||||||
|
// if (tmpSession){
|
||||||
|
// std::array<std::time_t> lastGames = tmpSession->GetPlayerLastGames();
|
||||||
|
// std::time_t now = std::time(nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
// retVal = true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SessionManager::IsPlayerAllowedToJoinLimitRank(unsigned uniqueId) const
|
||||||
|
{
|
||||||
|
bool retVal = false;
|
||||||
|
|
||||||
|
// boost::shared_ptr<SessionData> tmpSession = GetSessionByUniquePlayerId(uniqueId);
|
||||||
|
|
||||||
|
// if (tmpSession){
|
||||||
|
// std::array<std::time_t> lastGames = tmpSession->GetPlayerLastGames();
|
||||||
|
// std::time_t now = std::time(nullptr);
|
||||||
|
|
||||||
|
// retVal = true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SessionManager::IsClientAddressConnected(const std::string &clientAddress) const
|
SessionManager::IsClientAddressConnected(const std::string &clientAddress) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -126,6 +126,9 @@ public:
|
|||||||
void SetPlayerData(boost::shared_ptr<PlayerData> player);
|
void SetPlayerData(boost::shared_ptr<PlayerData> player);
|
||||||
boost::shared_ptr<PlayerData> GetPlayerData();
|
boost::shared_ptr<PlayerData> GetPlayerData();
|
||||||
|
|
||||||
|
void SetPlayerLastGames(std::array<std::time_t> lastGames);
|
||||||
|
std::array<std::time_t> GetPlayerLastGames();
|
||||||
|
|
||||||
std::string GetRemoteIPAddressFromSocket() const;
|
std::string GetRemoteIPAddressFromSocket() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -159,6 +162,8 @@ private:
|
|||||||
std::string m_password;
|
std::string m_password;
|
||||||
boost::shared_ptr<PlayerData> m_playerData;
|
boost::shared_ptr<PlayerData> m_playerData;
|
||||||
|
|
||||||
|
std::array<std::time_t> m_lastGames;
|
||||||
|
|
||||||
mutable boost::mutex m_dataMutex;
|
mutable boost::mutex m_dataMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ public:
|
|||||||
bool IsPlayerConnected(unsigned uniqueId) const;
|
bool IsPlayerConnected(unsigned uniqueId) const;
|
||||||
bool IsClientAddressConnected(const std::string &clientAddress) const;
|
bool IsClientAddressConnected(const std::string &clientAddress) const;
|
||||||
bool IsGuestAllowedToConnect(const std::string &clientAddress) const;
|
bool IsGuestAllowedToConnect(const std::string &clientAddress) const;
|
||||||
|
bool IsPlayerAllowedToJoinLimitRank(const std::string &playerName) const;
|
||||||
|
bool IsPlayerAllowedToJoinLimitRank(unsigned uniqueId) const;
|
||||||
|
|
||||||
void ForEach(boost::function<void (boost::shared_ptr<SessionData>)> func);
|
void ForEach(boost::function<void (boost::shared_ptr<SessionData>)> func);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user