Integrating authentication - now all authentication attempts fail (still work in progress).
This commit is contained in:
@@ -46,7 +46,7 @@
|
|||||||
// "2. Can I use OpenSSL with GPL software?"
|
// "2. Can I use OpenSSL with GPL software?"
|
||||||
// http://www.openssl.org/support/faq.html#LEGAL2
|
// http://www.openssl.org/support/faq.html#LEGAL2
|
||||||
//
|
//
|
||||||
#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
|
#if defined (_WIN32) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
|
||||||
#define HAVE_OPENSSL
|
#define HAVE_OPENSSL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -674,11 +674,14 @@ ClientStateStartSession::Enter(boost::shared_ptr<ClientThread> client)
|
|||||||
InitMessage_t *netInit = &init->GetMsg()->choice.initMessage;
|
InitMessage_t *netInit = &init->GetMsg()->choice.initMessage;
|
||||||
netInit->requestedVersion.major = NET_VERSION_MAJOR;
|
netInit->requestedVersion.major = NET_VERSION_MAJOR;
|
||||||
netInit->requestedVersion.minor = NET_VERSION_MINOR;
|
netInit->requestedVersion.minor = NET_VERSION_MINOR;
|
||||||
netInit->login.present = login_PR_anonymousLogin;
|
netInit->login.present = login_PR_authenticatedLogin;
|
||||||
AnonymousLogin_t *anonLogin = &netInit->login.choice.anonymousLogin;
|
AuthenticatedLogin_t *authLogin = &netInit->login.choice.authenticatedLogin;
|
||||||
OCTET_STRING_fromBuf(&anonLogin->playerName,
|
OCTET_STRING_fromBuf(&authLogin->playerName,
|
||||||
context.GetPlayerName().c_str(),
|
context.GetPlayerName().c_str(),
|
||||||
context.GetPlayerName().length());
|
context.GetPlayerName().length());
|
||||||
|
OCTET_STRING_fromBuf(&authLogin->password,
|
||||||
|
context.GetPassword().c_str(),
|
||||||
|
context.GetPassword().length());
|
||||||
//context.GetPassword();
|
//context.GetPassword();
|
||||||
string avatarFile = client->GetQtToolsInterface().stringFromUtf8(context.GetAvatarFile());
|
string avatarFile = client->GetQtToolsInterface().stringFromUtf8(context.GetAvatarFile());
|
||||||
if (!avatarFile.empty())
|
if (!avatarFile.empty())
|
||||||
@@ -687,7 +690,7 @@ ClientStateStartSession::Enter(boost::shared_ptr<ClientThread> client)
|
|||||||
if (client->GetAvatarManager().GetHashForAvatar(avatarFile, tmpMD5))
|
if (client->GetAvatarManager().GetHashForAvatar(avatarFile, tmpMD5))
|
||||||
{
|
{
|
||||||
// TODO: use sha1.
|
// TODO: use sha1.
|
||||||
anonLogin->avatar =
|
authLogin->avatar =
|
||||||
OCTET_STRING_new_fromBuf(
|
OCTET_STRING_new_fromBuf(
|
||||||
&asn_DEF_OCTET_STRING,
|
&asn_DEF_OCTET_STRING,
|
||||||
(const char *)tmpMD5.data,
|
(const char *)tmpMD5.data,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ ServerAcceptHelper::~ServerAcceptHelper()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerAcceptHelper::Listen(unsigned serverPort, bool ipv6, bool sctp, const string &pwd, const string &logDir, boost::shared_ptr<ServerLobbyThread> lobbyThread)
|
ServerAcceptHelper::Listen(unsigned serverPort, bool ipv6, bool sctp, const string &/*logDir*/, boost::shared_ptr<ServerLobbyThread> lobbyThread)
|
||||||
{
|
{
|
||||||
m_lobbyThread = lobbyThread;
|
m_lobbyThread = lobbyThread;
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ ServerAcceptHelper::Listen(unsigned serverPort, bool ipv6, bool sctp, const stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerAcceptHelper::InternalListen(unsigned serverPort, bool ipv6, bool sctp)
|
ServerAcceptHelper::InternalListen(unsigned serverPort, bool ipv6, bool /*sctp*/)
|
||||||
{
|
{
|
||||||
if (serverPort < 1024)
|
if (serverPort < 1024)
|
||||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_INVALID_PORT, 0);
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_INVALID_PORT, 0);
|
||||||
|
|||||||
@@ -883,7 +883,7 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage
|
|||||||
memcpy(avatarMD5.data, authLogin->avatar->buf, MD5_DATA_SIZE);
|
memcpy(avatarMD5.data, authLogin->avatar->buf, MD5_DATA_SIZE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SessionError(session, ERR_NET_INVALID_PASSWORD); // TODO not yet supported
|
SessionError(session, ERR_NET_INVALID_PASSWORD);
|
||||||
|
|
||||||
// Check the server password.
|
// Check the server password.
|
||||||
/* if (!CheckPassword(initData.password))
|
/* if (!CheckPassword(initData.password))
|
||||||
@@ -1268,6 +1268,7 @@ ServerLobbyThread::AuthenticationSuccess(unsigned playerId, db_id dbPlayerId)
|
|||||||
void
|
void
|
||||||
ServerLobbyThread::AuthenticationFailure(unsigned playerId)
|
ServerLobbyThread::AuthenticationFailure(unsigned playerId)
|
||||||
{
|
{
|
||||||
|
SessionError(m_sessionManager.GetSessionByUniquePlayerId(playerId, true), ERR_NET_INVALID_PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1578,7 +1579,7 @@ ServerLobbyThread::InternalCheckSessionTimeouts(SessionWrapper session)
|
|||||||
void
|
void
|
||||||
ServerLobbyThread::SessionError(SessionWrapper session, int errorCode)
|
ServerLobbyThread::SessionError(SessionWrapper session, int errorCode)
|
||||||
{
|
{
|
||||||
if (session.sessionData.get())
|
if (session.sessionData)
|
||||||
{
|
{
|
||||||
SendError(session.sessionData, errorCode);
|
SendError(session.sessionData, errorCode);
|
||||||
CloseSession(session);
|
CloseSession(session);
|
||||||
|
|||||||
@@ -55,13 +55,13 @@ ServerManager::Init(unsigned serverPort, bool ipv6, ServerNetworkMode mode, cons
|
|||||||
if (mode & NETWORK_MODE_TCP)
|
if (mode & NETWORK_MODE_TCP)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<ServerAcceptHelper> tcpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
|
boost::shared_ptr<ServerAcceptHelper> tcpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
|
||||||
tcpAcceptHelper->Listen(serverPort, ipv6, false, pwd, logDir, m_lobbyThread);
|
tcpAcceptHelper->Listen(serverPort, ipv6, false, logDir, m_lobbyThread);
|
||||||
m_acceptHelperPool.push_back(tcpAcceptHelper);
|
m_acceptHelperPool.push_back(tcpAcceptHelper);
|
||||||
}
|
}
|
||||||
/* if (mode & NETWORK_MODE_SCTP)
|
/* if (mode & NETWORK_MODE_SCTP)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<ServerAcceptHelper> sctpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
|
boost::shared_ptr<ServerAcceptHelper> sctpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService));
|
||||||
sctpAcceptHelper->Listen(serverPort, ipv6, true, pwd, logDir, m_lobbyThread);
|
sctpAcceptHelper->Listen(serverPort, ipv6, true, logDir, m_lobbyThread);
|
||||||
m_acceptHelperPool.push_back(sctpAcceptHelper);
|
m_acceptHelperPool.push_back(sctpAcceptHelper);
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ SessionManager::GetSessionByPlayerName(const string playerName) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
SessionWrapper
|
SessionWrapper
|
||||||
SessionManager::GetSessionByUniquePlayerId(unsigned uniqueId) const
|
SessionManager::GetSessionByUniquePlayerId(unsigned uniqueId, bool preInitSessions) const
|
||||||
{
|
{
|
||||||
SessionWrapper tmpSession;
|
SessionWrapper tmpSession;
|
||||||
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
|
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
|
||||||
@@ -132,7 +132,7 @@ SessionManager::GetSessionByUniquePlayerId(unsigned uniqueId) const
|
|||||||
while (session_i != session_end)
|
while (session_i != session_end)
|
||||||
{
|
{
|
||||||
// Check all players which are fully connected.
|
// Check all players which are fully connected.
|
||||||
if (session_i->second.sessionData->GetState() != SessionData::Init)
|
if (preInitSessions || session_i->second.sessionData->GetState() != SessionData::Init)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<PlayerData> tmpPlayer(session_i->second.playerData);
|
boost::shared_ptr<PlayerData> tmpPlayer(session_i->second.playerData);
|
||||||
if (!tmpPlayer.get())
|
if (!tmpPlayer.get())
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
virtual ~ServerAcceptHelper();
|
virtual ~ServerAcceptHelper();
|
||||||
|
|
||||||
// Set the parameters.
|
// Set the parameters.
|
||||||
void Listen(unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd, const std::string &logDir,
|
void Listen(unsigned serverPort, bool ipv6, bool sctp, const std::string &logDir,
|
||||||
boost::shared_ptr<ServerLobbyThread> lobbyThread);
|
boost::shared_ptr<ServerLobbyThread> lobbyThread);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
|
|
||||||
SessionWrapper GetSessionById(SessionId id) const;
|
SessionWrapper GetSessionById(SessionId id) const;
|
||||||
SessionWrapper GetSessionByPlayerName(const std::string playerName) const;
|
SessionWrapper GetSessionByPlayerName(const std::string playerName) const;
|
||||||
SessionWrapper GetSessionByUniquePlayerId(unsigned uniqueId) const;
|
SessionWrapper GetSessionByUniquePlayerId(unsigned uniqueId, bool preInitSessions = false) const;
|
||||||
|
|
||||||
PlayerDataList GetPlayerDataList() const;
|
PlayerDataList GetPlayerDataList() const;
|
||||||
PlayerIdList GetPlayerIdList(SessionData::State state) const;
|
PlayerIdList GetPlayerIdList(SessionData::State state) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user