mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 05:06:24 +00:00
98 lines
2.4 KiB
C++
98 lines
2.4 KiB
C++
/*
|
|
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
|
|
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
*/
|
|
|
|
#ifndef _AUTHSOCKET_H
|
|
#define _AUTHSOCKET_H
|
|
|
|
#include "Common.h"
|
|
#include "CryptoHash.h"
|
|
#include "Optional.h"
|
|
#include "RealmSocket.h"
|
|
#include "SRP6.h"
|
|
#include <mutex>
|
|
|
|
class ACE_INET_Addr;
|
|
class Field;
|
|
struct Realm;
|
|
|
|
enum eStatus
|
|
{
|
|
STATUS_CHALLENGE,
|
|
STATUS_LOGON_PROOF,
|
|
STATUS_RECON_PROOF,
|
|
STATUS_PATCH, // unused
|
|
STATUS_AUTHED,
|
|
STATUS_CLOSED
|
|
};
|
|
|
|
struct AccountInfo
|
|
{
|
|
void LoadResult(Field* fields);
|
|
|
|
uint32 Id = 0;
|
|
std::string Login;
|
|
bool IsLockedToIP = false;
|
|
std::string LockCountry;
|
|
std::string LastIP;
|
|
uint32 FailedLogins = 0;
|
|
bool IsBanned = false;
|
|
bool IsPermanentlyBanned = false;
|
|
AccountTypes SecurityLevel = SEC_PLAYER;
|
|
};
|
|
|
|
// Handle login commands
|
|
class AuthSocket: public RealmSocket::Session
|
|
{
|
|
public:
|
|
const static int s_BYTE_SIZE = 32;
|
|
|
|
AuthSocket(RealmSocket& socket);
|
|
~AuthSocket() override;
|
|
|
|
void OnRead() override;
|
|
void OnAccept() override;
|
|
void OnClose() override;
|
|
|
|
static ACE_INET_Addr const& GetAddressForClient(Realm const& realm, ACE_INET_Addr const& clientAddr);
|
|
|
|
bool _HandleLogonChallenge();
|
|
bool _HandleLogonProof();
|
|
bool _HandleReconnectChallenge();
|
|
bool _HandleReconnectProof();
|
|
bool _HandleRealmList();
|
|
|
|
//data transfer handle for patch
|
|
bool _HandleXferResume();
|
|
bool _HandleXferCancel();
|
|
bool _HandleXferAccept();
|
|
|
|
FILE* pPatch;
|
|
std::mutex patcherLock;
|
|
|
|
private:
|
|
RealmSocket& socket_;
|
|
RealmSocket& socket() { return socket_; }
|
|
|
|
std::optional<Acore::Crypto::SRP6> _srp6;
|
|
SessionKey _sessionKey = {};
|
|
std::array<uint8, 16> _reconnectProof = {};
|
|
|
|
eStatus _status;
|
|
|
|
AccountInfo _accountInfo;
|
|
Optional<std::vector<uint8>> _totpSecret;
|
|
|
|
// Since GetLocaleByName() is _NOT_ bijective, we have to store the locale as a string. Otherwise we can't differ
|
|
// between enUS and enGB, which is important for the patch system
|
|
std::string _localizationName;
|
|
std::string _os;
|
|
std::string _ipCountry;
|
|
uint16 _build;
|
|
uint8 _expversion;
|
|
};
|
|
|
|
#endif
|