diff options
| author | Shauren <shauren.trinity@gmail.com> | 2014-10-10 23:19:40 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2014-10-10 23:19:40 +0200 |
| commit | a04393f5542cc02b1af0e4259d98cc40080972d1 (patch) | |
| tree | 76555500c4eb14c764db3d868f3f156779237eda /src/server/authserver/Server | |
| parent | 03732846fe0d38e7ce969b029e63f09395eb1de2 (diff) | |
Core/Auth: Moved battle.net handling to separate project
Diffstat (limited to 'src/server/authserver/Server')
28 files changed, 0 insertions, 3478 deletions
diff --git a/src/server/authserver/Server/BattlenetBitStream.cpp b/src/server/authserver/Server/BattlenetBitStream.cpp deleted file mode 100644 index 712c9e58f08..00000000000 --- a/src/server/authserver/Server/BattlenetBitStream.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "BattlenetBitStream.h" - -template<> -bool Battlenet::BitStream::Read<bool>(uint32 /*bitCount*/) -{ - return Read<uint8>(1) != 0; -} - -template<> -void Battlenet::BitStream::Write<bool>(bool value, uint32 /*bitCount*/) -{ - Write<uint8>(value ? 1 : 0, 1); -} diff --git a/src/server/authserver/Server/BattlenetBitStream.h b/src/server/authserver/Server/BattlenetBitStream.h deleted file mode 100644 index 3601c3b0b0c..00000000000 --- a/src/server/authserver/Server/BattlenetBitStream.h +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __BATTLENETBITSTREAM_H__ -#define __BATTLENETBITSTREAM_H__ - -#include "Common.h" -#include "ByteConverter.h" -#include "MessageBuffer.h" -#include <exception> -#include <vector> -#include <type_traits> -#include <memory> - -namespace Battlenet -{ - class BitStreamPositionException : public std::exception - { - static uint32 const MessageSize = 128; - - public: - BitStreamPositionException(bool read, uint32 operationSize, uint32 position, uint32 streamSize) - { - memset(_message, 0, MessageSize); - snprintf(_message, MessageSize, "Attempted to %s more bits (%u) %s stream than %s (%u)\n", - (read ? "read" : "write"), - operationSize + position, - (read ? "from" : "to"), - (read ? "exist" : "allowed"), - streamSize); - } - - char const* what() const throw() - { - return _message; - } - - private: - char _message[MessageSize]; - }; - - class BitStream - { - public: - static uint32 const MaxSize = 0x4000; - - // length : The maximum number of bytes to read - BitStream(uint32 length) : _writePos(length * 8), _readPos(0) - { - _buffer.resize(length, 0); - } - - BitStream(MessageBuffer&& buffer) : _writePos(buffer.GetActiveSize() * 8), _readPos(0), _buffer(buffer.Move()) - { - } - - BitStream() : _writePos(0), _readPos(0) - { - _buffer.reserve(0x1000); - } - - void AlignToNextByte() - { - _readPos = (_readPos + 7) & ~7; - _writePos = (_writePos + 7) & ~7; - } - - std::string ReadString(uint32 bitCount, int32 baseLength = 0) - { - uint32 len = Read<uint32>(bitCount) + baseLength; - AlignToNextByte(); - std::string str(reinterpret_cast<char*>(&_buffer[_readPos >> 3]), len); - _readPos += len * 8; - return str; - } - - std::unique_ptr<uint8[]> ReadBytes(uint32 count) - { - AlignToNextByte(); - if (_readPos + count * 8 > _writePos) - throw BitStreamPositionException(true, count * 8, _readPos, _writePos); - - std::unique_ptr<uint8[]> buf(new uint8[count]); - memcpy(buf.get(), &_buffer[_readPos >> 3], count); - _readPos += count * 8; - return buf; - } - - float ReadFloat() - { - uint32 val = Read<uint32>(32); - return *reinterpret_cast<float*>(&val); - } - - std::string ReadFourCC() - { - uint32 fcc = Read<uint32>(32); - EndianConvertReverse(fcc); - size_t len = 4; - while (!(fcc & 0xFF)) - { - fcc >>= 8; - --len; - } - - return std::string(reinterpret_cast<char*>(&fcc), len); - } - - template<typename T> - T Read(uint32 bitCount) - { - static_assert(std::is_integral<T>::value || std::is_enum<T>::value, "T must be an integer type"); - - if (_readPos + bitCount > _writePos) - throw BitStreamPositionException(true, bitCount, _readPos, _writePos); - - uint64 ret = 0; - while (bitCount != 0) - { - uint32 bitPos = (_readPos & 7); - uint32 bitsLeftInByte = 8 - bitPos; - if (bitsLeftInByte >= bitCount) - bitsLeftInByte = bitCount; - - bitCount -= bitsLeftInByte; - ret |= (uint64)(_buffer[_readPos >> 3] >> bitPos & (uint32)((uint8)(1 << bitsLeftInByte) - 1)) << bitCount; - _readPos += bitsLeftInByte; - } - - return static_cast<T>(ret); - } - - void WriteString(std::string const& str, uint32 bitCount, int32 baseLength = 0) - { - Write(str.length() + baseLength, bitCount); - WriteBytes(str.c_str(), str.length()); - } - - template<typename T> - void WriteBytes(T* data, uint32 count) - { - AlignToNextByte(); - if (!count || !data) - return; - - if ((_writePos >> 3) + count > MaxSize) - throw BitStreamPositionException(false, count * 8, _writePos, MaxSize * 8); - - _buffer.resize(_buffer.size() + count); - memcpy(&_buffer[_writePos >> 3], data, count); - _writePos += count * 8; - } - - void WriteFloat(float value) - { - uint32 intVal = *reinterpret_cast<uint32*>(&value); - Write(intVal, 32); - } - - void WriteFourCC(std::string const& fcc) - { - uint32 intVal = *(uint32*)fcc.c_str(); - size_t len = fcc.length(); - EndianConvertReverse(intVal); - // Add padding - while (len++ < 4) - intVal >>= 8; - - Write(intVal, 32); - } - - template<typename T> - void Write(T value, uint32 bitCount) - { - static_assert(std::is_integral<T>::value || std::is_enum<T>::value, "T must be an integer type"); - - if (_writePos + bitCount > 8 * MaxSize) - throw BitStreamPositionException(false, bitCount, _writePos, MaxSize * 8); - - while (bitCount != 0) - { - uint32 bitPos = (_writePos & 7); - uint32 bitsLeftInByte = 8 - bitPos; - if (bitsLeftInByte >= bitCount) - bitsLeftInByte = bitCount; - - bitCount -= bitsLeftInByte; - - uint8 firstHalf = (uint8)(~(((uint8)(1 << bitsLeftInByte) - 1) << bitPos)); - uint8 secondHalf = (uint8)((((uint8)(1 << bitsLeftInByte) - 1) & (uint8)(value >> bitCount)) << bitPos); - - if (_buffer.size() > (_writePos >> 3)) - _buffer[_writePos >> 3] = (uint8)((_buffer[_writePos >> 3] & firstHalf) | secondHalf); - else - _buffer.push_back(secondHalf); - - _writePos += bitsLeftInByte; - } - } - - void SetReadPos(uint32 bits) - { - if (bits > _writePos) - throw BitStreamPositionException(true, bits, 0, _writePos); - - _readPos = bits; - } - - bool IsRead() const { return _readPos >= _writePos; } - - uint8* GetBuffer() { return _buffer.data(); } - uint8 const* GetBuffer() const { return _buffer.data(); } - - size_t GetSize() const { return ((_writePos + 7) & ~7) / 8; } - - private: - uint32 _writePos; - uint32 _readPos; - std::vector<uint8> _buffer; - }; - - template<> - bool BitStream::Read<bool>(uint32 bitCount); - - template<> - void BitStream::Write<bool>(bool value, uint32 bitCount); -} - -#endif // __BATTLENETBITSTREAM_H__ diff --git a/src/server/authserver/Server/BattlenetManager.cpp b/src/server/authserver/Server/BattlenetManager.cpp deleted file mode 100644 index f470c365b56..00000000000 --- a/src/server/authserver/Server/BattlenetManager.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "BattlenetManager.h" -#include "DatabaseEnv.h" - -BattlenetMgr::~BattlenetMgr() -{ - for (Battlenet::Component* component : _components) - delete component; - - for (auto const& m : _modules) - delete m.second; -} - -void BattlenetMgr::Load() -{ - LoadComponents(); - LoadModules(); -} - -void BattlenetMgr::LoadComponents() -{ - QueryResult result = LoginDatabase.Query("SELECT Program, Platform, Build FROM battlenet_components"); - if (result) - { - do - { - Field* fields = result->Fetch(); - Battlenet::Component* component = new Battlenet::Component(); - component->Program = fields[0].GetString(); - component->Platform = fields[1].GetString(); - component->Build = fields[2].GetUInt32(); - - _components.insert(component); - _programs.insert(component->Program); - _platforms.insert(component->Platform); - - } while (result->NextRow()); - } -} - -void BattlenetMgr::LoadModules() -{ - QueryResult result = LoginDatabase.Query("SELECT `Hash`, `Name`, `Type`, `System`, `Data` FROM battlenet_modules"); - if (result) - { - do - { - Field* fields = result->Fetch(); - Battlenet::ModuleInfo* module = new Battlenet::ModuleInfo(); - module->Type = fields[2].GetString(); - HexStrToByteArray(fields[0].GetString(), module->ModuleId); - std::string data = fields[4].GetString(); - module->DataSize = data.length() / 2; - if (module->DataSize) - { - module->Data = new uint8[data.length() / 2]; - HexStrToByteArray(data, module->Data); - } - - _modules[{ fields[3].GetString(), fields[1].GetString() }] = module; - } while (result->NextRow()); - } -} - -bool BattlenetMgr::HasComponent(Battlenet::Component const* component) const -{ - for (Battlenet::Component const* c : _components) - if (component->Program == c->Program && component->Platform == c->Platform && component->Build == c->Build) - return true; - - return false; -} - -Battlenet::ModuleInfo* BattlenetMgr::CreateModule(std::string const& os, std::string const& name) const -{ - Battlenet::ModuleKey key { os, name }; - ASSERT(_modules.count(key)); - - return new Battlenet::ModuleInfo(*_modules.at(key)); -} diff --git a/src/server/authserver/Server/BattlenetManager.h b/src/server/authserver/Server/BattlenetManager.h deleted file mode 100644 index bd01619ef06..00000000000 --- a/src/server/authserver/Server/BattlenetManager.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __BATTLENETMANAGER_H__ -#define __BATTLENETMANAGER_H__ - -#include "Define.h" -#include <cstring> -#include <string> -#include <set> -#include <map> - -namespace Battlenet -{ - struct Component - { - std::string Program; - std::string Platform; - uint32 Build; - }; - - struct ModuleKey - { - std::string Platform; - std::string Name; - - bool operator<(ModuleKey const& right) const - { - int32 res = Platform.compare(right.Platform); - if (res < 0) - return true; - else if (res > 0) - return false; - - return Name < right.Name; - } - }; - - struct ModuleInfo - { - ModuleInfo() : Region("EU"), DataSize(0), Data(nullptr) { } - ModuleInfo(ModuleInfo const& right) : Type(right.Type), Region(right.Region), DataSize(right.DataSize), Data(nullptr) - { - memcpy(ModuleId, right.ModuleId, 32); - if (DataSize) - { - Data = new uint8[DataSize]; - memcpy(Data, right.Data, DataSize); - } - } - ~ModuleInfo() - { - delete Data; - } - - std::string Type; - std::string Region; - uint8 ModuleId[32]; - uint32 DataSize; - uint8* Data; - }; - - struct RealmId - { - uint8 Region; - uint8 Battlegroup; - uint32 Index; - uint32 Build; - }; -} - -class BattlenetMgr -{ - BattlenetMgr() { } - ~BattlenetMgr(); - -public: - void Load(); - bool HasComponent(Battlenet::Component const* component) const; - bool HasProgram(std::string const& program) const { return _programs.count(program) != 0; } - bool HasPlatform(std::string const& platform) const { return _platforms.count(platform) != 0; } - Battlenet::ModuleInfo* CreateModule(std::string const& os, std::string const& name) const; - - static BattlenetMgr* instance() - { - static BattlenetMgr instance; - return &instance; - } - -private: - void LoadComponents(); - void LoadModules(); - - std::set<Battlenet::Component*> _components; - std::set<std::string> _programs; - std::set<std::string> _platforms; - std::map<Battlenet::ModuleKey, Battlenet::ModuleInfo*> _modules; -}; - -#define sBattlenetMgr BattlenetMgr::instance() - -#endif // __BATTLENETMANAGER_H__ diff --git a/src/server/authserver/Server/BattlenetPacketCrypt.cpp b/src/server/authserver/Server/BattlenetPacketCrypt.cpp deleted file mode 100644 index de4cf73f71c..00000000000 --- a/src/server/authserver/Server/BattlenetPacketCrypt.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "BattlenetPacketCrypt.h" -#include "Cryptography/HmacHash.h" -#include "Cryptography/BigNumber.h" - -Battlenet::PacketCrypt::PacketCrypt() : ::PacketCrypt(SHA256_DIGEST_LENGTH) -{ -} - -void Battlenet::PacketCrypt::Init(BigNumber* K) -{ - uint8 ServerEncryptionKey[SEED_KEY_SIZE] = { 0x68, 0xE0, 0xC7, 0x2E, 0xDD, 0xD6, 0xD2, 0xF3, 0x1E, 0x5A, 0xB1, 0x55, 0xB1, 0x8B, 0x63, 0x1E }; - uint8 ClientDecryptionKey[SEED_KEY_SIZE] = { 0xDE, 0xA9, 0x65, 0xAE, 0x54, 0x3A, 0x1E, 0x93, 0x9E, 0x69, 0x0C, 0xAA, 0x68, 0xDE, 0x78, 0x39 }; - - HmacSha256 serverEncryptHmac(K->GetNumBytes(), K->AsByteArray().get()); - serverEncryptHmac.UpdateData(ServerEncryptionKey, SEED_KEY_SIZE); - serverEncryptHmac.Finalize(); - - HmacSha256 clientDecryptHmac(K->GetNumBytes(), K->AsByteArray().get()); - clientDecryptHmac.UpdateData(ClientDecryptionKey, SEED_KEY_SIZE); - clientDecryptHmac.Finalize(); - - _clientDecrypt.Init(clientDecryptHmac.GetDigest()); - _serverEncrypt.Init(serverEncryptHmac.GetDigest()); - _initialized = true; -} diff --git a/src/server/authserver/Server/BattlenetPacketCrypt.h b/src/server/authserver/Server/BattlenetPacketCrypt.h deleted file mode 100644 index dde687651d3..00000000000 --- a/src/server/authserver/Server/BattlenetPacketCrypt.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __BATTLENETPACKETCRYPT_H__ -#define __BATTLENETPACKETCRYPT_H__ - -#include "PacketCrypt.h" - -class BigNumber; - -namespace Battlenet -{ - class PacketCrypt : public ::PacketCrypt - { - public: - PacketCrypt(); - - void Init(BigNumber* K) override; - }; -} - -#endif // __BATTLENETPACKETCRYPT_H__ diff --git a/src/server/authserver/Server/BattlenetPacketFactory.h b/src/server/authserver/Server/BattlenetPacketFactory.h deleted file mode 100644 index a0cbd8f5913..00000000000 --- a/src/server/authserver/Server/BattlenetPacketFactory.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef BattlenetPacketFactory_h__ -#define BattlenetPacketFactory_h__ - -#include "BattlenetPackets.h" -#include <map> - -namespace Battlenet -{ - class PacketFactory - { - typedef ClientPacket*(*PacketCreateFn)(PacketHeader const& header, BitStream& stream); - - public: - ClientPacket* Create(PacketHeader const& header, BitStream& stream) - { - auto creator = _creators.find(header); - if (creator == _creators.end()) - return nullptr; - - ClientPacket* packet = creator->second(header, stream); - packet->Read(); - return packet; - } - - static PacketFactory& Instance() - { - static PacketFactory instance; - return instance; - } - - private: - PacketFactory() - { - _creators[PacketHeader(Authentication::CMSG_LOGON_REQUEST, AUTHENTICATION)] = &New<Authentication::LogonRequest>; - _creators[PacketHeader(Authentication::CMSG_RESUME_REQUEST, AUTHENTICATION)] = &New<Authentication::ResumeRequest>; - _creators[PacketHeader(Authentication::CMSG_PROOF_RESPONSE, AUTHENTICATION)] = &New<Authentication::ProofResponse>; - - _creators[PacketHeader(Connection::CMSG_PING, CONNECTION)] = &New<Connection::Ping>; - _creators[PacketHeader(Connection::CMSG_ENABLE_ENCRYPTION, CONNECTION)] = &New<Connection::EnableEncryption>; - _creators[PacketHeader(Connection::CMSG_LOGOUT_REQUEST, CONNECTION)] = &New<Connection::LogoutRequest>; - - _creators[PacketHeader(WoWRealm::CMSG_LIST_SUBSCRIBE_REQUEST, WOWREALM)] = &New<WoWRealm::ListSubscribeRequest>; - _creators[PacketHeader(WoWRealm::CMSG_JOIN_REQUEST_V2, WOWREALM)] = &New<WoWRealm::JoinRequestV2>; - - _creators[PacketHeader(Friends::CMSG_SOCIAL_NETWORK_CHECK_CONNECTED, FRIENDS)] = &New<Friends::SocialnetworkCheckConnected>; - // _creators[PacketHeader(Friends::CMSG_SOCIAL_NETWORK_CONNECT, FRIENDS)] = &New<Friends::SocialnetworkConnect>; - // _creators[PacketHeader(Friends::CMSG_GET_FRIENDS_OF_FRIEND, FRIENDS)] = &New<Friends::GetFriendsOfFriend>; - _creators[PacketHeader(Friends::CMSG_REALID_FRIEND_INVITE, FRIENDS)] = &New<Friends::RealIdFriendInvite>; - - // _creators[PacketHeader(Presence::CMSG_UPDATE_REQUEST, PRESENCE)] = &New<Presence::UpdateRequest>; - // _creators[PacketHeader(Presence::CMSG_STATISTIC_SUBSCRIBE, PRESENCE)] = &New<Presence::StatisticSubscribe>; - } - - template<class PacketType> - static ClientPacket* New(PacketHeader const& header, BitStream& stream) - { - return new PacketType(header, stream); - } - - std::map<PacketHeader, PacketCreateFn> _creators; - }; -} - -#define sBattlenetPacketFactory Battlenet::PacketFactory::Instance() - -#endif // BattlenetPacketFactory_h__ diff --git a/src/server/authserver/Server/BattlenetPackets/AchievementPackets.h b/src/server/authserver/Server/BattlenetPackets/AchievementPackets.h deleted file mode 100644 index 69a03c7e16d..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/AchievementPackets.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef AchievementPackets_h__ -#define AchievementPackets_h__ - -#include "BattlenetPacketsBase.h" - -namespace Battlenet -{ - namespace Achievement - { - enum Opcode - { - CMSG_LISTEN_REQUEST = 0x0, // Not implemented - CMSG_CRITERIA_FLUSH_REQUEST = 0x3, // Not implemented - CMSG_CHANGE_TROPHY_CASE_REQUEST = 0x5, // Not implemented - - SMSG_DATA = 0x2, // Not implemented - SMSG_CRITERIA_FLUSH_RESPONSE = 0x3, // Not implemented - SMSG_ACHIEVEMENT_HANDLE_UPDATE = 0x4, // Not implemented - SMSG_CHANGE_TROPHY_CASE_RESULT = 0x6 // Not implemented - }; - } -} - -#endif // AchievementPackets_h__ - diff --git a/src/server/authserver/Server/BattlenetPackets/AuthenticationPackets.h b/src/server/authserver/Server/BattlenetPackets/AuthenticationPackets.h deleted file mode 100644 index 90dd4a35b1c..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/AuthenticationPackets.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef AuthenticationPackets_h__ -#define AuthenticationPackets_h__ - -#include "BattlenetPacketsBase.h" - -namespace Battlenet -{ - namespace Authentication - { - enum Opcode - { - CMSG_LOGON_REQUEST = 0x0, - CMSG_RESUME_REQUEST = 0x1, - CMSG_PROOF_RESPONSE = 0x2, - - SMSG_LOGON_RESPONSE = 0x0, - SMSG_RESUME_RESPONSE = 0x1, - SMSG_PROOF_REQUEST = 0x2, - SMSG_PATCH = 0x3, // Not implemented - SMSG_AUTHORIZED_LICENSES = 0x4 // Not implemented - }; - - class LogonRequest final : public ClientPacket - { - public: - LogonRequest(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_LOGON_REQUEST, AUTHENTICATION) && "Invalid packet header for LogonRequest"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) const override; - - std::string Program; - std::string Platform; - std::string Locale; - std::vector<Component> Components; - std::string Login; - }; - - class ResumeRequest final : public ClientPacket - { - public: - ResumeRequest(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_RESUME_REQUEST, AUTHENTICATION) && "Invalid packet header for ResumeRequest"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) const override; - - std::string Program; - std::string Platform; - std::string Locale; - std::vector<Component> Components; - std::string Login; - uint8 Region; - std::string GameAccountName; - }; - - class ProofResponse final : public ClientPacket - { - public: - ProofResponse(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_PROOF_RESPONSE, AUTHENTICATION) && "Invalid packet header for ProofResponse"); - } - - ~ProofResponse(); - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) const override; - - std::vector<BitStream*> Modules; - }; - - class ProofRequest final : public ServerPacket - { - public: - ProofRequest() : ServerPacket(PacketHeader(SMSG_PROOF_REQUEST, AUTHENTICATION)) { } - ~ProofRequest(); - - void Write() override; - std::string ToString() const override; - - std::vector<ModuleInfo*> Modules; - }; - - class ResponseFailure - { - public: - enum Result - { - UPDATE = 0, - FAILURE = 1, - VERSION_CHECK_DISCONNECT = 2 - }; - - ResponseFailure() : ResultValue(UPDATE), Error(AUTH_OK), Wait(0) { } - - Result ResultValue; - AuthResult Error; - int32 Wait; - }; - - class Regulator - { - public: - enum Info - { - NONE = 0, - LEAKY_BUCKET = 1 - }; - - Regulator() : Type(LEAKY_BUCKET), Threshold(25000000), Rate(1000) { } - - Info Type; - uint32 Threshold; - uint32 Rate; - }; - - class LogonResponse final : public ServerPacket - { - public: - LogonResponse() : ServerPacket(PacketHeader(SMSG_LOGON_RESPONSE, AUTHENTICATION)), - PingTimeout(120000), FirstName(""), LastName(""), AccountId(0), Region(2), Flags(0), - GameAccountRegion(2), GameAccountName(""), FailedLogins(0) - { - } - - ~LogonResponse(); - - void Write() override; - std::string ToString() const override; - - std::vector<ModuleInfo*> Modules; - void SetAuthResult(AuthResult result); - ResponseFailure Result; - - int32 PingTimeout; - Regulator RegulatorRules; - std::string FirstName; - std::string LastName; - uint32 AccountId; - uint8 Region; - uint64 Flags; - uint8 GameAccountRegion; - std::string GameAccountName; - uint64 GameAccountFlags; - - uint32 FailedLogins; - }; - - class ResumeResponse final : public ServerPacket - { - public: - ResumeResponse() : ServerPacket(PacketHeader(SMSG_RESUME_RESPONSE, AUTHENTICATION)), PingTimeout(120000) - { - } - - ~ResumeResponse(); - - void Write() override; - std::string ToString() const override; - - std::vector<ModuleInfo*> Modules; - void SetAuthResult(AuthResult result); - ResponseFailure Result; - - int32 PingTimeout; - Regulator RegulatorRules; - }; - } -} - -#endif // AuthenticationPackets_h__ diff --git a/src/server/authserver/Server/BattlenetPackets/BattlenetPackets.h b/src/server/authserver/Server/BattlenetPackets/BattlenetPackets.h deleted file mode 100644 index d4cd8600266..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/BattlenetPackets.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef BattlenetPackets_h__ -#define BattlenetPackets_h__ - -#include "AuthenticationPackets.h" -#include "ConnectionPackets.h" -#include "WoWRealmPackets.h" -#include "FriendsPackets.h" -#include "PresencePackets.h" -#include "ChatPackets.h" -#include "SupportPackets.h" -#include "AchievementPackets.h" -#include "CachePackets.h" -#include "ProfilePackets.h" - -#endif // BattlenetPackets_h__ diff --git a/src/server/authserver/Server/BattlenetPackets/BattlenetPacketsBase.cpp b/src/server/authserver/Server/BattlenetPackets/BattlenetPacketsBase.cpp deleted file mode 100644 index 034bb8ba0a4..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/BattlenetPacketsBase.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "BattlenetPackets.h" -#include <sstream> - -std::string Battlenet::PacketHeader::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::PacketHeader opcode: " << Opcode << ", channel: " << Channel; - return stream.str(); -} - -Battlenet::ServerPacket::ServerPacket(PacketHeader const& header) : Packet(header, *new BitStream()) -{ - _stream.Write(header.Opcode, 6); - _stream.Write(1, 1); - _stream.Write(header.Channel, 4); -} - -Battlenet::ServerPacket::~ServerPacket() -{ - delete &_stream; -} diff --git a/src/server/authserver/Server/BattlenetPackets/BattlenetPacketsBase.h b/src/server/authserver/Server/BattlenetPackets/BattlenetPacketsBase.h deleted file mode 100644 index 2aa07314771..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/BattlenetPacketsBase.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef BattlenetPacketsBase_h__ -#define BattlenetPacketsBase_h__ - -#include "AuthCodes.h" -#include "BattlenetBitStream.h" -#include "BattlenetManager.h" -#include "Define.h" -#include "Errors.h" -#include <string> -#include <boost/asio/ip/tcp.hpp> - -using boost::asio::ip::tcp; - -namespace Battlenet -{ - class BitStream; - class Session; - - enum Channel - { - AUTHENTICATION = 0, - CONNECTION = 1, - WOWREALM = 2, - FRIENDS = 3, - PRESENCE = 4, - CHAT = 5, - SUPPORT = 7, - ACHIEVEMENT = 8, - CACHE = 11, - PROFILE = 14 - }; - - struct PacketHeader - { - PacketHeader(uint32 opcode, uint32 channel) : Opcode(opcode), Channel(channel) { } - PacketHeader() : Opcode(0), Channel(AUTHENTICATION) { } - - uint32 Opcode; - int32 Channel; - - bool operator<(PacketHeader const& right) const - { - if (Opcode < right.Opcode) - return true; - if (Opcode > right.Opcode) - return false; - - return Channel < right.Channel; - } - - bool operator==(PacketHeader const& right) const - { - return Opcode == right.Opcode && Channel == right.Channel; - } - - std::string ToString() const; - }; - - class Packet - { - public: - Packet(PacketHeader const& header, BitStream& stream) : _header(header), _stream(stream) { } - virtual ~Packet() { } - - PacketHeader const& GetHeader() const { return _header; } - - virtual void Write() = 0; - virtual void Read() = 0; - - virtual std::string ToString() const = 0; - - protected: - PacketHeader _header; - BitStream& _stream; - - private: - Packet(Packet const& right); - Packet& operator=(Packet const& right); - }; - - class ClientPacket : public Packet - { - public: - ClientPacket(PacketHeader const& header, BitStream& stream) : Packet(header, stream) { } - - void Write() override final { ASSERT(!"Write not implemented for this packet."); } - virtual void CallHandler(Session* session) const = 0; - }; - - class ServerPacket : public Packet - { - public: - ServerPacket(PacketHeader const& header); - ~ServerPacket(); - - void Read() override final { ASSERT(!"Read not implemented for server packets."); } - - uint8* GetData() { return _stream.GetBuffer(); } - uint8 const* GetData() const { return _stream.GetBuffer(); } - size_t GetSize() const { return _stream.GetSize(); } - }; -} - -#endif // BattlenetPacketsBase_h__ diff --git a/src/server/authserver/Server/BattlenetPackets/CachePackets.h b/src/server/authserver/Server/BattlenetPackets/CachePackets.h deleted file mode 100644 index 6354201dc4c..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/CachePackets.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef CachePackets_h__ -#define CachePackets_h__ - -#include "BattlenetPacketsBase.h" - -namespace Battlenet -{ - namespace Cache - { - enum Opcode - { - CMSG_GATEWAY_LOOKUP_REQUEST = 0x2, // Not implemented - CMSG_CONNECT_REQUEST = 0x4, // Not implemented - CMSG_DATA_CHUNK = 0x7, // Not implemented - SMSG_GET_STREAM_ITEMS_REQUEST = 0x9, // Not implemented - - SMSG_GATEWAY_LOOKUP_RESPONSE = 0x3, // Not implemented - SMSG_CONNECT_RESPONSE = 0x4, // Not implemented - SMSG_PUBLISH_LIST_RESPONSE = 0x7, // Not implemented - SMSG_RESULT = 0x8, // Not implemented - SMSG_GET_STREAM_ITEMS_RESPONSE = 0x9 // Not implemented - }; - } -} - -#endif // CachePackets_h__ diff --git a/src/server/authserver/Server/BattlenetPackets/ChatPackets.h b/src/server/authserver/Server/BattlenetPackets/ChatPackets.h deleted file mode 100644 index ee11a1b732e..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/ChatPackets.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef ChatPackets_h__ -#define ChatPackets_h__ - -#include "BattlenetPacketsBase.h" - -namespace Battlenet -{ - namespace Chat - { - enum Opcode - { - CMSG_JOIN_REQUEST_2 = 0x00, // Not implemented - CMSG_LEAVE_REQUEST = 0x02, // Not implemented - CMSG_INVITE_REQUEST = 0x03, // Not implemented - CMSG_CREATE_AND_INVITE_REQUEST = 0x0A, // Not implemented - CMSG_MESSAGE_SEND = 0x0B, // Not implemented - CMSG_DATAGRAM_CONNECTION_UPDATE = 0x0D, // Not implemented - CMSG_REPORT_SPAM_REQUEST = 0x0E, // Not implemented - CMSG_WHISPER_SEND = 0x13, // Not implemented - CMSG_ENUM_CATEGORY_DESCRIPTIONS = 0x15, // Not implemented - CMSG_ENUM_CONFERENCE_DESCRIPTIONS = 0x17, // Not implemented - CMSG_ENUM_CONFERENCE_MEMBER_COUNTS = 0x19, // Not implemented - CMSG_MODIFY_CHANNEL_LIST_REQUEST = 0x1B, // Not implemented - - SMSG_MEMBERSHIP_CHANGE_NOTIFY = 0x01, // Not implemented - SMSG_INVITE_NOTIFY = 0x04, // Not implemented - SMSG_INVITE_CANCELED = 0x07, // Not implemented - SMSG_MESSAGE_RECV = 0x0B, // Not implemented - SMSG_MESSAGE_UNDELIVERABLE = 0x0C, // Not implemented - SMSG_DATAGRAM_CONNECTION_UPDATE = 0x0D, // Not implemented - SMSG_INVITE_FAILURE = 0x0F, // Not implemented - SMSG_SYSTEM_MESSAGE = 0x10, // Not implemented - SMSG_MESSAGE_BLOCKED = 0x12, // Not implemented - SMSG_WHISPER_RECV = 0x13, // Not implemented - SMSG_WHISPER_UNDELIVERABLE = 0x14, // Not implemented - SMSG_CATEGORY_DESCRIPTIONS = 0x16, // Not implemented - SMSG_CONFERENCE_DESCRIPTIONS = 0x18, // Not implemented - SMSG_CONFERENCE_MEMBER_COUNTS = 0x1A, // Not implemented - SMSG_JOIN_NOTIFY_2 = 0x1B, // Not implemented - SMSG_MODIFY_CHANNEL_LIST_RESPONSE = 0x1C, // Not implemented - SMSG_CONFIG_CHANGED = 0x1D // Not implemented - }; - } -} - -#endif // ChatPackets_h__ diff --git a/src/server/authserver/Server/BattlenetPackets/ConnectionPackets.cpp b/src/server/authserver/Server/BattlenetPackets/ConnectionPackets.cpp deleted file mode 100644 index f0c3f3ea5e6..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/ConnectionPackets.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "BattlenetSession.h" -#include "ConnectionPackets.h" - -std::string Battlenet::Connection::Ping::ToString() const -{ - return "Battlenet::Connection::Ping"; -} - -void Battlenet::Connection::Ping::CallHandler(Session* session) const -{ - session->HandlePing(*this); -} - -std::string Battlenet::Connection::EnableEncryption::ToString() const -{ - return "Battlenet::Connection::EnableEncryption"; -} - -void Battlenet::Connection::EnableEncryption::CallHandler(Session* session) const -{ - session->HandleEnableEncryption(*this); -} - -std::string Battlenet::Connection::LogoutRequest::ToString() const -{ - return "Battlenet::Connection::LogoutRequest"; -} - -void Battlenet::Connection::LogoutRequest::CallHandler(Session* session) const -{ - session->HandleLogoutRequest(*this); -} - -std::string Battlenet::Connection::Pong::ToString() const -{ - return "Battlenet::Connection::Pong"; -} diff --git a/src/server/authserver/Server/BattlenetPackets/ConnectionPackets.h b/src/server/authserver/Server/BattlenetPackets/ConnectionPackets.h deleted file mode 100644 index cc25f73f810..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/ConnectionPackets.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef ConnectionPackets_h__ -#define ConnectionPackets_h__ - -#include "BattlenetPacketsBase.h" - -namespace Battlenet -{ - namespace Connection - { - enum Opcode - { - CMSG_PING = 0x0, - CMSG_ENABLE_ENCRYPTION = 0x5, - CMSG_LOGOUT_REQUEST = 0x6, - CMSG_DISCONNECT_REQUEST = 0x7, // Not implemented - CMSG_CONNECTION_CLOSING = 0x9, // Not implemented - - SMSG_PONG = 0x0, - SMSG_BOOM = 0x1, // Not implemented - SMSG_REGULATOR_UPDATE = 0x2, // Not implemented - SMSG_SERVER_VERSION = 0x3, // Not implemented - SMSG_STUN_SERVERS = 0x4 // Not implemented - }; - - class Ping final : public ClientPacket - { - public: - Ping(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_PING, CONNECTION) && "Invalid packet header for Ping"); - } - - void Read() override { } - std::string ToString() const override; - void CallHandler(Session* session) const override; - }; - - class EnableEncryption final : public ClientPacket - { - public: - EnableEncryption(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_ENABLE_ENCRYPTION, CONNECTION) && "Invalid packet header for EnableEncryption"); - } - - void Read() override { } - std::string ToString() const override; - void CallHandler(Session* session) const override; - }; - - class LogoutRequest final : public ClientPacket - { - public: - LogoutRequest(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_LOGOUT_REQUEST, CONNECTION) && "Invalid packet header for LogoutRequest"); - } - - void Read() override { } - std::string ToString() const override; - void CallHandler(Session* session) const override; - }; - - class Pong final : public ServerPacket - { - public: - Pong() : ServerPacket(PacketHeader(SMSG_PONG, CONNECTION)) - { - } - - void Write() override { } - std::string ToString() const override; - }; - } -} - -#endif // ConnectionPackets_h__ diff --git a/src/server/authserver/Server/BattlenetPackets/FriendsPackets.cpp b/src/server/authserver/Server/BattlenetPackets/FriendsPackets.cpp deleted file mode 100644 index 336755acd4c..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/FriendsPackets.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "BattlenetSession.h" -#include "FriendsPackets.h" - -void Battlenet::Friends::SocialnetworkCheckConnected::Read() -{ - SocialNetworkId = _stream.Read<uint32>(32); -} - -std::string Battlenet::Friends::SocialnetworkCheckConnected::ToString() const -{ - return "Battlenet::Friends::SocialnetworkCheckConnected SocialNetworkId " + std::to_string(SocialNetworkId); -} - -void Battlenet::Friends::SocialnetworkCheckConnected::CallHandler(Session* session) const -{ - SocialNetworkCheckConnectedResult* result = new SocialNetworkCheckConnectedResult(SocialNetworkId); - session->AsyncWrite(result); -} - -void Battlenet::Friends::SocialnetworkConnect::Read() -{ - int32 unk1 = _stream.Read<int32>(32); - uint32 size1 = _stream.Read<uint32>(9); - auto data1 = _stream.ReadBytes(size1); - uint32 size2 = _stream.Read<uint32>(7); - auto data2 = _stream.ReadBytes(size2); -} - -std::string Battlenet::Friends::SocialnetworkConnect::ToString() const -{ - return "Battlenet::Friends::SocialnetworkConnect"; -} - -void Battlenet::Friends::SocialnetworkConnect::CallHandler(Session* session) const -{ - -} - -std::string Battlenet::Friends::SocialNetworkConnectResult::ToString() const -{ - return "Battlenet::Friends::SocialNetworkConnectResult"; -} - -void Battlenet::Friends::SocialNetworkConnectResult::Write() -{ - -} - -std::string Battlenet::Friends::SocialNetworkCheckConnectedResult::ToString() const -{ - return "Battlenet::Friends::SocialNetworkCheckConnectedResult"; -} - -void Battlenet::Friends::SocialNetworkCheckConnectedResult::Write() -{ - _stream.Write(0, 23); // Ignored - volatile uint16 res = 0; - _stream.Write(res, 16); // Unknown - _stream.Write(SocialNetworkId, 32); -} - -void Battlenet::Friends::GetFriendsOfFriend::Read() -{ - uint8 unk = _stream.Read<uint8>(2); - uint32 unk1 = _stream.Read<uint32>(32); -} - -std::string Battlenet::Friends::GetFriendsOfFriend::ToString() const -{ - return "Battlenet::Friends::GetFriendsOfFriend"; -} - -void Battlenet::Friends::GetFriendsOfFriend::CallHandler(Session* session) const -{ - -} - -void Battlenet::Friends::RealIdFriendInvite::Read() -{ - _stream.Read<uint32>(32); - uint8 type = _stream.Read<uint8>(3); - - switch (type) - { - case 0: - { - _stream.Read<uint32>(32); // Presence Id? - break; - } - case 1: // GameAccount? - { - _stream.Read<uint8>(8); - _stream.Read<uint32>(32); - _stream.Read<uint32>(32); - uint8 size = _stream.Read<uint8>(7); // Only if *(a1 + 16) <= 0x64 - _stream.ReadBytes(size); - break; - } - case 2: - Email = _stream.ReadString(9, 3); - break; - case 3: - { - _stream.Read<uint32>(32); - break; - } - case 4: - { - _stream.Read<uint64>(64); - _stream.Read<uint32>(32); - break; - } - } - - _stream.Read<uint8>(1); - - if (_stream.Read<uint8>(1)) - Message = _stream.ReadString(9); - - _stream.Read<uint32>(32); -} - -std::string Battlenet::Friends::RealIdFriendInvite::ToString() const -{ - return "Battlenet::Friends::RealIdFriendInvite Mail: " + Email + " Message: " + Message; -} - -void Battlenet::Friends::RealIdFriendInvite::CallHandler(Session* session) const -{ - FriendInviteResult* result = new FriendInviteResult(); - session->AsyncWrite(result); -} - -std::string Battlenet::Friends::FriendInviteResult::ToString() const -{ - return "Battlenet::Friends::RealIdFriendInviteResult"; -} - -void Battlenet::Friends::FriendInviteResult::Write() -{ - bool hasNames = false; - _stream.Write(hasNames, 1); - if (hasNames) - { - _stream.WriteString("Testing1", 8); - _stream.WriteString("Testing2", 8); - } - _stream.Write(5, 32); - - _stream.Write(0, 0xC); // Ignored - - _stream.Write(1, 16); - - bool moreInfo = true; - _stream.Write(moreInfo, 1); - if (moreInfo) - { - _stream.Write(0, 8); - _stream.Write(4, 32); - _stream.Write(3, 32); - _stream.WriteString("Testing3", 7, 2); - } -} diff --git a/src/server/authserver/Server/BattlenetPackets/FriendsPackets.h b/src/server/authserver/Server/BattlenetPackets/FriendsPackets.h deleted file mode 100644 index e58fbdff180..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/FriendsPackets.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef FriendsPackets_h__ -#define FriendsPackets_h__ - -#include "BattlenetPacketsBase.h" - -namespace Battlenet -{ - namespace Friends - { - enum Opcode - { - CMSG_FRIEND_INVITE = 0x01, // Not implemented - CMSG_FRIEND_INVITE_RESPONSE = 0x02, // Not implemented - CMSG_FRIEND_REMOVE = 0x04, // Not implemented - CMSG_FRIEND_NOTE = 0x05, // Not implemented - CMSG_TOONS_OF_FRIEND_REQUEST = 0x06, // Not implemented - CMSG_BLOCK_ADD = 0x08, // Not implemented - CMSG_BLOCK_REMOVE = 0x0A, // Not implemented - CMSG_GET_FRIENDS_OF_FRIEND = 0x0B, // Not implemented - CMSG_GET_SOCIAL_NETWORK_FRIENDS = 0x0D, // Not implemented - CMSG_SOCIAL_NETWORK_CONNECT = 0x0F, // Not implemented - CMSG_SOCIAL_NETWORK_DISCONNECT = 0x11, // Not implemented - CMSG_SOCIAL_NETWORK_CHECK_CONNECTED = 0x13, - CMSG_REALID_FRIEND_INVITE = 0x16, // Not implemented - - SMSG_FRIEND_INVITE_NOTIFY = 0x01, // Not implemented - SMSG_FRIEND_INVITE_RESULT = 0x03, // Not implemented - SMSG_TOONS_OF_FRIEND_NOTIFY = 0x06, // Not implemented - SMSG_BLOCK_INVITE_NOTIFY = 0x07, // Not implemented - SMSG_BLOCK_ADD_FAILURE = 0x09, // Not implemented - SMSG_FRIENDS_OF_FRIEND = 0x0C, // Not implemented - SMSG_SOCIAL_NETWORK_FRIENDS = 0x0E, // Not implemented - SMSG_SOCIAL_NETWORK_CONNECT_RESULT = 0x10, // Not implemented - SMSG_SOCIAL_NETWORK_DISCONNECT_RESULT = 0x12, // Not implemented - SMSG_SOCIAL_NETWORK_CHECK_CONNECTED_RESULT = 0x14, - SMSG_MAX_FRIENDS_NOTIFY = 0x15, // Not implemented - SMSG_FRIENDS_LIST_NOTIFY_3 = 0x18 // Not implemented - }; - - class SocialnetworkConnect final : public ClientPacket - { - public: - SocialnetworkConnect(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_SOCIAL_NETWORK_CONNECT, FRIENDS) && "Invalid packet header for SocialnetworkConnect"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) const override; - }; - - class SocialNetworkConnectResult final : public ServerPacket - { - public: - SocialNetworkConnectResult() : ServerPacket(PacketHeader(SMSG_SOCIAL_NETWORK_CONNECT_RESULT, FRIENDS)) - { - } - - void Write() override; - std::string ToString() const override; - }; - - class SocialnetworkCheckConnected final : public ClientPacket - { - public: - SocialnetworkCheckConnected(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_SOCIAL_NETWORK_CHECK_CONNECTED, FRIENDS) && "Invalid packet header for SocialNetworkCheckConnected"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) const override; - - uint32 SocialNetworkId; - }; - - class SocialNetworkCheckConnectedResult final : public ServerPacket - { - public: - SocialNetworkCheckConnectedResult(uint32 socialNetworkId) : ServerPacket(PacketHeader(SMSG_SOCIAL_NETWORK_CHECK_CONNECTED_RESULT, FRIENDS)), SocialNetworkId(socialNetworkId) - { - } - - void Write() override; - std::string ToString() const override; - - uint32 SocialNetworkId; - }; - - class GetFriendsOfFriend final : public ClientPacket - { - public: - GetFriendsOfFriend(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_GET_FRIENDS_OF_FRIEND, FRIENDS) && "Invalid packet header for GetFriendsOfFriend"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) const override; - }; - - class FriendsOfFriend final : public ServerPacket - { - public: - FriendsOfFriend() : ServerPacket(PacketHeader(SMSG_FRIENDS_OF_FRIEND, FRIENDS)) - { - } - - void Write() override; - std::string ToString() const override; - }; - - class RealIdFriendInvite final : public ClientPacket - { - public: - RealIdFriendInvite(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_REALID_FRIEND_INVITE, FRIENDS) && "Invalid packet header for RealIdFriendInvite"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) const override; - - std::string Email; - std::string Message; - }; - - class FriendInviteResult final : public ServerPacket - { - public: - FriendInviteResult() : ServerPacket(PacketHeader(SMSG_FRIEND_INVITE_RESULT, FRIENDS)) - { - } - - void Write() override; - std::string ToString() const override; - }; - } -} - -#endif // FriendsPackets_h__ diff --git a/src/server/authserver/Server/BattlenetPackets/PresencePackets.cpp b/src/server/authserver/Server/BattlenetPackets/PresencePackets.cpp deleted file mode 100644 index 46ce7fa1b36..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/PresencePackets.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "BattlenetSession.h" -#include "PresencePackets.h" - - -void Battlenet::Presence::UpdateRequest::Read() -{ - -} - -std::string Battlenet::Presence::UpdateRequest::ToString() const -{ - return "Battlenet::Presence::UpdateRequest"; -} - -void Battlenet::Presence::UpdateRequest::CallHandler(Session* session) const -{ - -} - -void Battlenet::Presence::StatisticSubscribe::Read() -{ - -} - -std::string Battlenet::Presence::StatisticSubscribe::ToString() const -{ - return "Battlenet::Presence::StatisticSubscribe"; -} - -void Battlenet::Presence::StatisticSubscribe::CallHandler(Session* session) const -{ - -} diff --git a/src/server/authserver/Server/BattlenetPackets/PresencePackets.h b/src/server/authserver/Server/BattlenetPackets/PresencePackets.h deleted file mode 100644 index 0a934f2c2ca..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/PresencePackets.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef PresencePackets_h__ -#define PresencePackets_h__ - -#include "BattlenetPacketsBase.h" - -namespace Battlenet -{ - namespace Presence - { - enum Opcode - { - CMSG_UPDATE_REQUEST = 0x0, // Not implemented - CMSG_STATISTIC_SUBSCRIBE = 0x2, // Not implemented - - SMSG_UPDATE_NOTIFY = 0x0, // Not implemented - SMSG_FIELD_SPEC_ANNOUNCE = 0x1, // Not implemented - SMSG_STATISTICS_UPDATE = 0x3 // Not implemented - }; - - class UpdateRequest final : public ClientPacket - { - public: - UpdateRequest(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_UPDATE_REQUEST, PRESENCE) && "Invalid packet header for UpdateRequest"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) const override; - }; - - class StatisticSubscribe final : public ClientPacket - { - public: - StatisticSubscribe(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_STATISTIC_SUBSCRIBE, PRESENCE) && "Invalid packet header for StatisticSubscribe"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) const override; - }; - } -} - -#endif // PresencePackets_h__ diff --git a/src/server/authserver/Server/BattlenetPackets/ProfilePackets.h b/src/server/authserver/Server/BattlenetPackets/ProfilePackets.h deleted file mode 100644 index d08fa4883c5..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/ProfilePackets.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef ProfilePackets_h__ -#define ProfilePackets_h__ - -#include "BattlenetPacketsBase.h" - -namespace Battlenet -{ - namespace Profile - { - enum Opcode - { - CMSG_READ_REQUEST = 0x0, // Not implemented - CMSG_ADDRESS_QUERY_REQUEST = 0x1, // Not implemented - CMSG_RESOLVE_TOON_HANDLE_TO_NAME_REQUEST = 0x2, // Not implemented - CMSG_RESOLVE_TOON_NAME_TO_HANDLE_REQUEST = 0x3, // Not implemented - CMSG_CHANGE_SETTINGS = 0x5, // Not implemented - - SMSG_READ_RESPONSE = 0x0, // Not implemented - SMSG_ADDRESS_QUERY_RESPONSE = 0x1, // Not implemented - SMSG_RESOLVE_TOON_HANDLE_TO_NAME_RESPONSE = 0x2, // Not implemented - SMSG_RESOLVE_TOON_NAME_TO_HANDLE_RESPONSE = 0x3, // Not implemented - SMSG_SETTINGS_AVAILABLE = 0x4 // Not implemented - }; - } -} - -#endif // ProfilePackets_h__ diff --git a/src/server/authserver/Server/BattlenetPackets/SupportPackets.h b/src/server/authserver/Server/BattlenetPackets/SupportPackets.h deleted file mode 100644 index 4821ce7caa0..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/SupportPackets.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SupportPackets_h__ -#define SupportPackets_h__ - -#include "BattlenetPacketsBase.h" - -namespace Battlenet -{ - namespace Support - { - enum Opcode - { - CMSG_COMPLAINT_REQUEST = 0x0 // Not implemented - }; - } -} - -#endif // SupportPackets_h__ diff --git a/src/server/authserver/Server/BattlenetPackets/WoWRealmPackets.cpp b/src/server/authserver/Server/BattlenetPackets/WoWRealmPackets.cpp deleted file mode 100644 index 1b20a3a7f85..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/WoWRealmPackets.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "WoWRealmPackets.h" -#include "BattlenetSession.h" -#include <boost/lexical_cast.hpp> -#include <boost/asio/ip/address.hpp> - -std::string Battlenet::WoWRealm::ListSubscribeRequest::ToString() const -{ - return "Battlenet::WoWRealm::ListSubscribeRequest"; -} - -void Battlenet::WoWRealm::ListSubscribeRequest::CallHandler(Session* session) const -{ - session->HandleListSubscribeRequest(*this); -} - -Battlenet::WoWRealm::ListSubscribeResponse::~ListSubscribeResponse() -{ - for (ServerPacket* realmData : RealmData) - delete realmData; -} - -void Battlenet::WoWRealm::ListSubscribeResponse::Write() -{ - _stream.Write(Response, 1); - if (Response == SUCCESS) - { - _stream.Write(CharacterCounts.size(), 7); - for (CharacterCountEntry const& entry : CharacterCounts) - { - _stream.Write(entry.Realm.Battlegroup, 8); - _stream.Write(entry.Realm.Index, 32); - _stream.Write(entry.Realm.Region, 8); - _stream.Write(entry.CharacterCount, 16); - } - - for (ServerPacket* realmData : RealmData) - { - realmData->Write(); - _stream.WriteBytes(realmData->GetData(), realmData->GetSize()); - } - } - else - _stream.Write(ResponseCode, 8); -} - -std::string Battlenet::WoWRealm::ListSubscribeResponse::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::ListSubscribeResponse"; - - if (Response == SUCCESS) - { - stream << " Realms " << CharacterCounts.size(); - - for (CharacterCountEntry const& entry : CharacterCounts) - stream << std::endl << "Region " << uint32(entry.Realm.Region) << " Battlegroup " << uint32(entry.Realm.Region) << " Index " << entry.Realm.Index << " Characters " << entry.CharacterCount; - - for (ServerPacket* realmData : RealmData) - stream << std::endl << realmData->ToString(); - } - else - stream << " Failure"; - - return stream.str().c_str(); -} - -void Battlenet::WoWRealm::ListUpdate::Write() -{ - _stream.Write(UpdateState, 1); - if (UpdateState == UPDATE) - { - _stream.Write(Type + -std::numeric_limits<int32>::min(), 32); - _stream.WriteFloat(Population); - _stream.Write(Flags, 8); - _stream.Write(Lock, 8); - _stream.Write(Timezone, 32); - _stream.Write(!Version.empty(), 1); - if (!Version.empty()) - { - _stream.WriteString(Version, 5); - _stream.Write(Build, 32); - - boost::asio::ip::address_v4::bytes_type ip = Address.address().to_v4().to_bytes(); - uint16 port = Address.port(); - - EndianConvertReverse(ip); - EndianConvertReverse(port); - - _stream.WriteBytes(ip.data(), 4); - _stream.WriteBytes(&port, 2); - } - - _stream.WriteString(Name, 10); - } - - _stream.Write(Battlegroup, 8); - _stream.Write(Index, 32); - _stream.Write(Region, 8); -} - -std::string Battlenet::WoWRealm::ListUpdate::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::ListUpdate Timezone " << Timezone << " Population " << Population << " Lock " << uint32(Lock) << " Type " << Type << " Name " << Name - << " Flags " << uint32(Flags) << " Region " << uint32(Region) << " Battlegroup " << uint32(Battlegroup) << " Index " << Index; - - if (!Version.empty()) - stream << " Version " << Version; - - return stream.str().c_str(); -} - -void Battlenet::WoWRealm::JoinRequestV2::Read() -{ - Realm.Battlegroup = _stream.Read<uint8>(8); - Realm.Index = _stream.Read<uint32>(32); - Realm.Region = _stream.Read<uint8>(8); - ClientSeed = _stream.Read<uint32>(32); -} - -std::string Battlenet::WoWRealm::JoinRequestV2::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::JoinRequestV2 ClientSeed " << ClientSeed << " Region " << uint32(Realm.Region) << " Battlegroup " << uint32(Realm.Battlegroup) << " Index " << Realm.Index; - return stream.str().c_str(); -} - -void Battlenet::WoWRealm::JoinRequestV2::CallHandler(Session* session) const -{ - session->HandleJoinRequestV2(*this); -} - -void Battlenet::WoWRealm::JoinResponseV2::Write() -{ - _stream.Write(0, 27); - _stream.Write(Response, 1); - if (Response == SUCCESS) - { - _stream.Write(ServerSeed, 32); - _stream.Write(IPv6.size(), 5); - for (tcp::endpoint const& addr : IPv6) - { - boost::asio::ip::address_v6::bytes_type ip = addr.address().to_v6().to_bytes(); - uint16 port = addr.port(); - - EndianConvertReverse(port); - - _stream.WriteBytes(ip.data(), 16); - _stream.WriteBytes(&port, 2); - } - - _stream.Write(IPv4.size(), 5); - for (tcp::endpoint const& addr : IPv4) - { - boost::asio::ip::address_v4::bytes_type ip = addr.address().to_v4().to_bytes(); - uint16 port = addr.port(); - - EndianConvertReverse(port); - - _stream.WriteBytes(ip.data(), 4); - _stream.WriteBytes(&port, 2); - } - } - else - _stream.Write(ResponseCode, 8); -} - -std::string Battlenet::WoWRealm::JoinResponseV2::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::JoinResponseV2"; - if (Response == SUCCESS) - { - stream << " ServerSeed " << ServerSeed << " IPv4 Addresses " << IPv4.size() << " IPv6 Addresses " << IPv6.size(); - for (tcp::endpoint const& addr : IPv4) - stream << std::endl << "Battlenet::WoWRealm::JoinResponseV2::Address " << boost::lexical_cast<std::string>(addr); - - for (tcp::endpoint const& addr : IPv6) - stream << std::endl << "Battlenet::WoWRealm::JoinResponseV2::Address " << boost::lexical_cast<std::string>(addr); - } - else - stream << " Failure"; - - return stream.str().c_str(); -} diff --git a/src/server/authserver/Server/BattlenetPackets/WoWRealmPackets.h b/src/server/authserver/Server/BattlenetPackets/WoWRealmPackets.h deleted file mode 100644 index 1e4228cb26a..00000000000 --- a/src/server/authserver/Server/BattlenetPackets/WoWRealmPackets.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef WoWRealmPackets_h__ -#define WoWRealmPackets_h__ - -#include "BattlenetPacketsBase.h" - -namespace Battlenet -{ - namespace WoWRealm - { - enum Opcode - { - CMSG_LIST_SUBSCRIBE_REQUEST = 0x0, - CMSG_LIST_UNSUBSCRIBE = 0x1, // Not implemented - CMSG_JOIN_REQUEST_V2 = 0x8, - CMSG_MULTI_LOGON_REQUEST_V2 = 0x9, // Not implemented - - SMSG_LIST_SUBSCRIBE_RESPONSE = 0x0, - SMSG_LIST_UPDATE = 0x2, - SMSG_LIST_COMPLETE = 0x3, - SMSG_TOON_READY = 0x6, // Not implemented - SMSG_TOON_LOGGED_OUT = 0x7, // Not implemented - SMSG_JOIN_RESPONSE_V2 = 0x8 - }; - - class ListSubscribeRequest final : public ClientPacket - { - public: - ListSubscribeRequest(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_LIST_SUBSCRIBE_REQUEST, WOWREALM) && "Invalid packet header for ListSubscribeRequest"); - } - - void Read() override { } - std::string ToString() const override; - void CallHandler(Session* session) const override; - }; - - class JoinRequestV2 final : public ClientPacket - { - public: - JoinRequestV2(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_JOIN_REQUEST_V2, WOWREALM) && "Invalid packet header for RealmJoinRequest"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) const override; - - uint32 ClientSeed; - RealmId Realm; - }; - - class ListSubscribeResponse final : public ServerPacket - { - public: - enum Result - { - SUCCESS = 0, - FAILURE = 1 - }; - - ListSubscribeResponse() : ServerPacket(PacketHeader(SMSG_LIST_SUBSCRIBE_RESPONSE, WOWREALM)), - Response(SUCCESS), ResponseCode(26) - { - } - - ~ListSubscribeResponse(); - - struct CharacterCountEntry - { - RealmId Realm; - uint32 CharacterCount; - }; - - void Write() override; - std::string ToString() const override; - - Result Response; - uint8 ResponseCode; - std::vector<CharacterCountEntry> CharacterCounts; - std::vector<ServerPacket*> RealmData; - }; - - class ListUpdate final : public ServerPacket - { - public: - enum State - { - DELETED = 0, - UPDATE = 1 - }; - - ListUpdate() : ServerPacket(PacketHeader(SMSG_LIST_UPDATE, WOWREALM)), UpdateState(UPDATE), - Timezone(0), Population(0.0f), Lock(0), Type(0), Name(""), Version(""), - Flags(0), Region(0), Battlegroup(0), Index(0), Build(0) - { - } - - void Write() override; - std::string ToString() const override; - - int UpdateState; - uint32 Timezone; - float Population; - uint8 Lock; - uint32 Type; - std::string Name; - std::string Version; - tcp::endpoint Address; - uint8 Flags; - uint8 Region; - uint8 Battlegroup; - uint32 Index; - uint32 Build; - }; - - class ListComplete final : public ServerPacket - { - public: - ListComplete() : ServerPacket(PacketHeader(SMSG_LIST_COMPLETE, WOWREALM)) - { - } - - void Write() override { } - std::string ToString() const override { return "Battlenet::WoWRealm::ListComplete"; } - }; - - class JoinResponseV2 final : public ServerPacket - { - public: - enum Result - { - SUCCESS = 0, - FAILURE = 1 - }; - - JoinResponseV2() : ServerPacket(PacketHeader(SMSG_JOIN_RESPONSE_V2, WOWREALM)), - ServerSeed(0), Response(SUCCESS), ResponseCode(26) - { - } - - void Write() override; - std::string ToString() const override; - - Result Response; - uint8 ResponseCode; - uint32 ServerSeed; - std::vector<tcp::endpoint> IPv4; - std::vector<tcp::endpoint> IPv6; - }; - } -} - -#endif // WoWRealmPackets_h__ diff --git a/src/server/authserver/Server/BattlenetSession.cpp b/src/server/authserver/Server/BattlenetSession.cpp deleted file mode 100644 index 865e51c1a07..00000000000 --- a/src/server/authserver/Server/BattlenetSession.cpp +++ /dev/null @@ -1,1004 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "AuthCodes.h" -#include "BattlenetBitStream.h" -#include "BattlenetPacketFactory.h" -#include "BattlenetSessionManager.h" -#include "Database/DatabaseEnv.h" -#include "HmacHash.h" -#include "Log.h" -#include "RealmList.h" -#include "SHA256.h" -#include <map> - -Battlenet::Session::ModuleHandler const Battlenet::Session::ModuleHandlers[MODULE_COUNT] = -{ - &Battlenet::Session::HandlePasswordModule, - &Battlenet::Session::UnhandledModule, - &Battlenet::Session::UnhandledModule, - &Battlenet::Session::HandleSelectGameAccountModule, - &Battlenet::Session::HandleRiskFingerprintModule, - &Battlenet::Session::HandleResumeModule, -}; - -Battlenet::Session::Session(tcp::socket&& socket) : Socket(std::move(socket)), _accountId(0), _accountName(), _locale(), - _os(), _build(0), _gameAccountId(0), _gameAccountName(), _accountSecurityLevel(SEC_PLAYER), I(), s(), v(), b(), B(), K(), - _reconnectProof(), _crypt(), _authed(false) -{ - static uint8 const N_Bytes[] = - { - 0xAB, 0x24, 0x43, 0x63, 0xA9, 0xC2, 0xA6, 0xC3, 0x3B, 0x37, 0xE4, 0x61, 0x84, 0x25, 0x9F, 0x8B, - 0x3F, 0xCB, 0x8A, 0x85, 0x27, 0xFC, 0x3D, 0x87, 0xBE, 0xA0, 0x54, 0xD2, 0x38, 0x5D, 0x12, 0xB7, - 0x61, 0x44, 0x2E, 0x83, 0xFA, 0xC2, 0x21, 0xD9, 0x10, 0x9F, 0xC1, 0x9F, 0xEA, 0x50, 0xE3, 0x09, - 0xA6, 0xE5, 0x5E, 0x23, 0xA7, 0x77, 0xEB, 0x00, 0xC7, 0xBA, 0xBF, 0xF8, 0x55, 0x8A, 0x0E, 0x80, - 0x2B, 0x14, 0x1A, 0xA2, 0xD4, 0x43, 0xA9, 0xD4, 0xAF, 0xAD, 0xB5, 0xE1, 0xF5, 0xAC, 0xA6, 0x13, - 0x1C, 0x69, 0x78, 0x64, 0x0B, 0x7B, 0xAF, 0x9C, 0xC5, 0x50, 0x31, 0x8A, 0x23, 0x08, 0x01, 0xA1, - 0xF5, 0xFE, 0x31, 0x32, 0x7F, 0xE2, 0x05, 0x82, 0xD6, 0x0B, 0xED, 0x4D, 0x55, 0x32, 0x41, 0x94, - 0x29, 0x6F, 0x55, 0x7D, 0xE3, 0x0F, 0x77, 0x19, 0xE5, 0x6C, 0x30, 0xEB, 0xDE, 0xF6, 0xA7, 0x86 - }; - - N.SetBinary(N_Bytes, sizeof(N_Bytes)); - g.SetDword(2); - - SHA256Hash sha; - sha.UpdateBigNumbers(&N, &g, NULL); - sha.Finalize(); - k.SetBinary(sha.GetDigest(), sha.GetLength()); -} - -Battlenet::Session::~Session() -{ - sBattlenetSessionMgr.RemoveSession(this); - TC_LOG_TRACE("server.battlenet", "Battlenet::Session::OnClose"); -} - -void Battlenet::Session::_SetVSFields(std::string const& pstr) -{ - s.SetRand(uint32(BufferSizes::SRP_6_S) * 8); - - BigNumber p; - p.SetHexStr(pstr.c_str()); - - SHA256Hash sha; - sha.UpdateBigNumbers(&s, &p, NULL); - sha.Finalize(); - BigNumber x; - x.SetBinary(sha.GetDigest(), sha.GetLength()); - v = g.ModExp(x, N); - - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_VS_FIELDS); - stmt->setString(0, v.AsHexStr()); - stmt->setString(1, s.AsHexStr()); - stmt->setString(2, _accountName); - - LoginDatabase.Execute(stmt); -} - -void Battlenet::Session::LogUnhandledPacket(ClientPacket const& packet) -{ - TC_LOG_DEBUG("server.battlenet", "Battlenet::Session::LogUnhandledPacket %s", packet.ToString().c_str()); -} - -void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const& info) -{ - // Verify that this IP is not in the ip_banned table - LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS)); - - std::string ip_address = GetRemoteIpAddress().to_string(); - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED); - stmt->setString(0, ip_address); - if (PreparedQueryResult result = LoginDatabase.Query(stmt)) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(LOGIN_BANNED); - AsyncWrite(complete); - TC_LOG_DEBUG("server.battlenet", "[Battlenet::AuthChallenge] Banned ip '%s:%d' tries to login!", ip_address.c_str(), GetRemotePort()); - return; - } - - if (info.Program != "WoW") - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(AUTH_INVALID_PROGRAM); - AsyncWrite(complete); - return; - } - - if (!sBattlenetMgr->HasPlatform(info.Platform)) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(AUTH_INVALID_OS); - AsyncWrite(complete); - return; - } - - if (!sBattlenetMgr->HasPlatform(info.Locale)) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(AUTH_UNSUPPORTED_LANGUAGE); - AsyncWrite(complete); - return; - } - - for (Component const& component : info.Components) - { - if (!sBattlenetMgr->HasComponent(&component)) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - if (!sBattlenetMgr->HasProgram(component.Program)) - complete->SetAuthResult(AUTH_INVALID_PROGRAM); - else if (!sBattlenetMgr->HasPlatform(component.Platform)) - complete->SetAuthResult(AUTH_INVALID_OS); - else - { - if (component.Program != "WoW" || AuthHelper::IsBuildSupportingBattlenet(component.Build)) - complete->SetAuthResult(AUTH_REGION_BAD_VERSION); - else - complete->SetAuthResult(AUTH_USE_GRUNT_LOGON); - } - - AsyncWrite(complete); - return; - } - - if (component.Platform == "base") - _build = component.Build; - } - - _accountName = info.Login; - _locale = info.Locale; - _os = info.Platform; - - Utf8ToUpperOnlyLatin(_accountName); - stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_ACCOUNT_INFO); - stmt->setString(0, _accountName); - - PreparedQueryResult result = LoginDatabase.Query(stmt); - if (!result) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(AUTH_UNKNOWN_ACCOUNT); - AsyncWrite(complete); - return; - } - - Field* fields = result->Fetch(); - - _accountId = fields[1].GetUInt32(); - - // If the IP is 'locked', check that the player comes indeed from the correct IP address - if (fields[2].GetUInt8() == 1) // if ip is locked - { - TC_LOG_DEBUG("server.battlenet", "[Battlenet::AuthChallenge] Account '%s' is locked to IP - '%s' is logging in from '%s'", _accountName.c_str(), fields[4].GetCString(), ip_address.c_str()); - - if (strcmp(fields[4].GetCString(), ip_address.c_str()) != 0) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(AUTH_ACCOUNT_LOCKED); - AsyncWrite(complete); - return; - } - } - else - { - TC_LOG_DEBUG("server.battlenet", "[Battlenet::AuthChallenge] Account '%s' is not locked to ip", _accountName.c_str()); - std::string accountCountry = fields[3].GetString(); - if (accountCountry.empty() || accountCountry == "00") - TC_LOG_DEBUG("server.battlenet", "[Battlenet::AuthChallenge] Account '%s' is not locked to country", _accountName.c_str()); - else if (!accountCountry.empty()) - { - uint32 ip = inet_addr(ip_address.c_str()); - EndianConvertReverse(ip); - - stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_LOGON_COUNTRY); - stmt->setUInt32(0, ip); - if (PreparedQueryResult sessionCountryQuery = LoginDatabase.Query(stmt)) - { - std::string loginCountry = (*sessionCountryQuery)[0].GetString(); - TC_LOG_DEBUG("server.battlenet", "[Battlenet::AuthChallenge] Account '%s' is locked to country: '%s' Player country is '%s'", _accountName.c_str(), accountCountry.c_str(), loginCountry.c_str()); - if (loginCountry != accountCountry) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(AUTH_ACCOUNT_LOCKED); - AsyncWrite(complete); - return; - } - } - } - } - - //set expired bans to inactive - LoginDatabase.DirectExecute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_BNET_EXPIRED_BANS)); - - // If the account is banned, reject the logon attempt - stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_ACTIVE_ACCOUNT_BAN); - stmt->setUInt32(0, _accountId); - PreparedQueryResult banresult = LoginDatabase.Query(stmt); - if (banresult) - { - Field* fields = banresult->Fetch(); - if (fields[0].GetUInt32() == fields[1].GetUInt32()) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(LOGIN_BANNED); - AsyncWrite(complete); - TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::AuthChallenge] Banned account %s tried to login!", ip_address.c_str(), GetRemotePort(), _accountName.c_str()); - return; - } - else - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(LOGIN_SUSPENDED); - AsyncWrite(complete); - TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::AuthChallenge] Temporarily banned account %s tried to login!", ip_address.c_str(), GetRemotePort(), _accountName.c_str()); - return; - } - } - - SHA256Hash sha; - sha.UpdateData(_accountName); - sha.Finalize(); - - I.SetBinary(sha.GetDigest(), sha.GetLength()); - - ModuleInfo* password = sBattlenetMgr->CreateModule(_os, "Password"); - ModuleInfo* thumbprint = sBattlenetMgr->CreateModule(_os, "Thumbprint"); - - std::string pStr = fields[0].GetString(); - - std::string databaseV = fields[5].GetString(); - std::string databaseS = fields[6].GetString(); - - if (databaseV.size() != size_t(BufferSizes::SRP_6_V) * 2 || databaseS.size() != size_t(BufferSizes::SRP_6_S) * 2) - _SetVSFields(pStr); - else - { - s.SetHexStr(databaseS.c_str()); - v.SetHexStr(databaseV.c_str()); - } - - b.SetRand(128 * 8); - B = ((v * k) + g.ModExp(b, N)) % N; - BigNumber unk; - unk.SetRand(128 * 8); - - BitStream passwordData; - uint8 state = 0; - passwordData.WriteBytes(&state, 1); - passwordData.WriteBytes(I.AsByteArray(32).get(), 32); - passwordData.WriteBytes(s.AsByteArray(32).get(), 32); - passwordData.WriteBytes(B.AsByteArray(128).get(), 128); - passwordData.WriteBytes(unk.AsByteArray(128).get(), 128); - - password->DataSize = passwordData.GetSize(); - password->Data = new uint8[password->DataSize]; - memcpy(password->Data, passwordData.GetBuffer(), password->DataSize); - - _modulesWaitingForData.push(MODULE_PASSWORD); - - Authentication::ProofRequest* request = new Authentication::ProofRequest(); - request->Modules.push_back(password); - // if has authenticator, send Token module - request->Modules.push_back(thumbprint); - AsyncWrite(request); -} - -void Battlenet::Session::HandleResumeRequest(Authentication::ResumeRequest const& reconnect) -{ - _accountName = reconnect.Login; - _locale = reconnect.Locale; - _os = reconnect.Platform; - auto baseComponent = std::find_if(reconnect.Components.begin(), reconnect.Components.end(), [](Component const& c) { return c.Program == "base"; }); - if (baseComponent != reconnect.Components.end()) - _build = baseComponent->Build; - - Utf8ToUpperOnlyLatin(_accountName); - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_RECONNECT_INFO); - stmt->setString(0, _accountName); - stmt->setString(1, reconnect.GameAccountName); - PreparedQueryResult result = LoginDatabase.Query(stmt); - if (!result) - { - Authentication::ResumeResponse* resume = new Authentication::ResumeResponse(); - resume->SetAuthResult(AUTH_UNKNOWN_ACCOUNT); - AsyncWrite(resume); - return; - } - - Field* fields = result->Fetch(); - - _accountId = fields[0].GetUInt32(); - K.SetHexStr(fields[1].GetString().c_str()); - _gameAccountId = fields[2].GetUInt32(); - _gameAccountName = reconnect.GameAccountName; - - ModuleInfo* thumbprint = sBattlenetMgr->CreateModule(_os, "Thumbprint"); - ModuleInfo* resume = sBattlenetMgr->CreateModule(_os, "Resume"); - BitStream resumeData; - uint8 state = 0; - _reconnectProof.SetRand(16 * 8); - - resumeData.WriteBytes(&state, 1); - resumeData.WriteBytes(_reconnectProof.AsByteArray().get(), 16); - - resume->DataSize = resumeData.GetSize(); - resume->Data = new uint8[resume->DataSize]; - memcpy(resume->Data, resumeData.GetBuffer(), resume->DataSize); - - _modulesWaitingForData.push(MODULE_RESUME); - - Authentication::ProofRequest* request = new Authentication::ProofRequest(); - request->Modules.push_back(thumbprint); - request->Modules.push_back(resume); - AsyncWrite(request); -} - -void Battlenet::Session::HandleProofResponse(Authentication::ProofResponse const& proof) -{ - if (_modulesWaitingForData.size() < proof.Modules.size()) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(AUTH_CORRUPTED_MODULE); - AsyncWrite(complete); - return; - } - - ServerPacket* response = nullptr; - for (size_t i = 0; i < proof.Modules.size(); ++i) - { - if (!(this->*(ModuleHandlers[_modulesWaitingForData.front()]))(proof.Modules[i], &response)) - break; - - _modulesWaitingForData.pop(); - } - - if (!response) - { - response = new Authentication::LogonResponse(); - static_cast<Authentication::LogonResponse*>(response)->SetAuthResult(AUTH_INTERNAL_ERROR); - } - - AsyncWrite(response); - return; -} - -void Battlenet::Session::HandlePing(Connection::Ping const& /*ping*/) -{ - AsyncWrite(new Connection::Pong()); -} - -void Battlenet::Session::HandleEnableEncryption(Connection::EnableEncryption const& /*enableEncryption*/) -{ - _crypt.Init(&K); -} - -void Battlenet::Session::HandleLogoutRequest(Connection::LogoutRequest const& /*logoutRequest*/) -{ - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_SESSION_KEY); - stmt->setString(0, ""); - stmt->setBool(1, false); - stmt->setUInt32(2, _accountId); - LoginDatabase.Execute(stmt); -} - -void Battlenet::Session::HandleListSubscribeRequest(WoWRealm::ListSubscribeRequest const& /*listSubscribeRequest*/) -{ - sRealmList->UpdateIfNeed(); - - WoWRealm::ListSubscribeResponse* counts = new WoWRealm::ListSubscribeResponse(); - - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_CHARACTER_COUNTS); - stmt->setUInt32(0, _gameAccountId); - - if (PreparedQueryResult countResult = LoginDatabase.Query(stmt)) - { - do - { - Field* fields = countResult->Fetch(); - uint32 build = fields[4].GetUInt32(); - counts->CharacterCounts.push_back({ { fields[2].GetUInt8(), fields[3].GetUInt8(), fields[1].GetUInt32(), (_build != build ? build : 0) }, fields[0].GetUInt8() }); - } while (countResult->NextRow()); - } - - for (RealmList::RealmMap::const_iterator i = sRealmList->begin(); i != sRealmList->end(); ++i) - { - Realm const& realm = i->second; - - uint32 flag = realm.flag; - RealmBuildInfo const* buildInfo = AuthHelper::GetBuildInfo(realm.gamebuild); - if (realm.gamebuild != _build) - { - if (!buildInfo) - continue; - - flag |= REALM_FLAG_OFFLINE | REALM_FLAG_SPECIFYBUILD; // tell the client what build the realm is for - } - - if (!buildInfo) - flag &= ~REALM_FLAG_SPECIFYBUILD; - - WoWRealm::ListUpdate* update = new WoWRealm::ListUpdate(); - update->Timezone = realm.timezone; - update->Population = realm.populationLevel; - update->Lock = (realm.allowedSecurityLevel > _accountSecurityLevel) ? 1 : 0; - update->Type = realm.icon; - update->Name = realm.name; - - if (flag & REALM_FLAG_SPECIFYBUILD) - { - std::ostringstream version; - version << buildInfo->MajorVersion << '.' << buildInfo->MinorVersion << '.' << buildInfo->BugfixVersion << '.' << buildInfo->Build; - - update->Version = version.str(); - update->Address = realm.GetAddressForClient(GetRemoteIpAddress()); - update->Build = buildInfo->Build; - } - - update->Flags = flag; - update->Region = realm.Region; - update->Battlegroup = realm.Battlegroup; - update->Index = realm.m_ID; - - counts->RealmData.push_back(update); - } - - counts->RealmData.push_back(new WoWRealm::ListComplete()); - - AsyncWrite(counts); -} - -void Battlenet::Session::HandleJoinRequestV2(WoWRealm::JoinRequestV2 const& join) -{ - WoWRealm::JoinResponseV2* result = new WoWRealm::JoinResponseV2(); - Realm const* realm = sRealmList->GetRealm(join.Realm); - if (!realm || realm->flag & (REALM_FLAG_INVALID | REALM_FLAG_OFFLINE)) - { - result->Response = WoWRealm::JoinResponseV2::FAILURE; - AsyncWrite(result); - return; - } - - result->ServerSeed = uint32(rand32()); - - uint8 sessionKey[40]; - HmacSha1 hmac(K.GetNumBytes(), K.AsByteArray().get()); - hmac.UpdateData((uint8*)"WoW\0", 4); - hmac.UpdateData((uint8*)&join.ClientSeed, 4); - hmac.UpdateData((uint8*)&result->ServerSeed, 4); - hmac.Finalize(); - - memcpy(sessionKey, hmac.GetDigest(), hmac.GetLength()); - - HmacSha1 hmac2(K.GetNumBytes(), K.AsByteArray().get()); - hmac2.UpdateData((uint8*)"WoW\0", 4); - hmac2.UpdateData((uint8*)&result->ServerSeed, 4); - hmac2.UpdateData((uint8*)&join.ClientSeed, 4); - hmac2.Finalize(); - - memcpy(sessionKey + hmac.GetLength(), hmac2.GetDigest(), hmac2.GetLength()); - - LoginDatabase.DirectPExecute("UPDATE account SET sessionkey = '%s', last_ip = '%s', last_login = NOW(), locale = %u, failed_logins = 0, os = '%s' WHERE id = %u", - ByteArrayToHexStr(sessionKey, 40, true).c_str(), GetRemoteIpAddress().to_string().c_str(), GetLocaleByName(_locale), _os.c_str(), _gameAccountId); - - result->IPv4.emplace_back(realm->ExternalAddress, realm->port); - if (realm->ExternalAddress != realm->LocalAddress) - result->IPv4.emplace_back(realm->LocalAddress, realm->port); - - AsyncWrite(result); -} - -void Battlenet::Session::ReadHandler() -{ - BitStream stream(std::move(GetReadBuffer())); - _crypt.DecryptRecv(stream.GetBuffer(), stream.GetSize()); - - while (!stream.IsRead()) - { - try - { - PacketHeader header; - header.Opcode = stream.Read<uint32>(6); - if (stream.Read<bool>(1)) - header.Channel = stream.Read<int32>(4); - - if (header.Channel != AUTHENTICATION && !_authed) - { - TC_LOG_DEBUG("server.battlenet", "Battlenet::Session::ReadDataHandler Received not allowed packet %s", header.ToString().c_str()); - CloseSocket(); - return; - } - - if (ClientPacket* packet = sBattlenetPacketFactory.Create(header, stream)) - { - TC_LOG_TRACE("server.battlenet", "Battlenet::Session::ReadDataHandler %s", packet->ToString().c_str()); - packet->CallHandler(this); - delete packet; - } - else - { - TC_LOG_DEBUG("server.battlenet", "Battlenet::Session::ReadDataHandler Unhandled opcode %s", header.ToString().c_str()); - break; - } - - stream.AlignToNextByte(); - } - catch (BitStreamPositionException const& e) - { - TC_LOG_ERROR("server.battlenet", "Battlenet::Session::ReadDataHandler Exception: %s", e.what()); - CloseSocket(); - return; - } - } - - GetReadBuffer().Resize(size_t(BufferSizes::Read)); - AsyncRead(); -} - -void Battlenet::Session::Start() -{ - TC_LOG_TRACE("server.battlenet", "Battlenet::Session::Start"); - AsyncRead(); -} - -void Battlenet::Session::AsyncWrite(ServerPacket* packet) -{ - if (!IsOpen()) - { - delete packet; - return; - } - - TC_LOG_TRACE("server.battlenet", "Battlenet::Session::AsyncWrite %s", packet->ToString().c_str()); - - packet->Write(); - - MessageBuffer buffer; - buffer.Write(packet->GetData(), packet->GetSize()); - delete packet; - - std::unique_lock<std::mutex> guard(_writeLock); - - _crypt.EncryptSend(buffer.GetReadPointer(), buffer.GetActiveSize()); - - QueuePacket(std::move(buffer), guard); -} - -inline void ReplaceResponse(Battlenet::ServerPacket** oldResponse, Battlenet::ServerPacket* newResponse) -{ - if (*oldResponse) - delete *oldResponse; - - *oldResponse = newResponse; -} - -bool Battlenet::Session::HandlePasswordModule(BitStream* dataStream, ServerPacket** response) -{ - if (dataStream->GetSize() != 1 + 128 + 32 + 128) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(AUTH_CORRUPTED_MODULE); - ReplaceResponse(response, complete); - return false; - } - - if (dataStream->Read<uint8>(8) != 2) // State - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(AUTH_CORRUPTED_MODULE); - ReplaceResponse(response, complete); - return false; - } - - - BigNumber A, clientM1, clientChallenge; - A.SetBinary(dataStream->ReadBytes(128).get(), 128); - clientM1.SetBinary(dataStream->ReadBytes(32).get(), 32); - clientChallenge.SetBinary(dataStream->ReadBytes(128).get(), 128); - - if (A.isZero()) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(AUTH_CORRUPTED_MODULE); - ReplaceResponse(response, complete); - return false; - } - - SHA256Hash sha; - sha.UpdateBigNumbers(&A, &B, NULL); - sha.Finalize(); - - BigNumber u; - u.SetBinary(sha.GetDigest(), sha.GetLength()); - - BigNumber S = ((A * v.ModExp(u, N)) % N).ModExp(b, N); - - uint8 S_bytes[128]; - memcpy(S_bytes, S.AsByteArray(128).get(), 128); - - uint8 part1[64]; - uint8 part2[64]; - - for (int i = 0; i < 64; ++i) - { - part1[i] = S_bytes[i * 2]; - part2[i] = S_bytes[i * 2 + 1]; - } - - SHA256Hash part1sha, part2sha; - part1sha.UpdateData(part1, 64); - part1sha.Finalize(); - part2sha.UpdateData(part2, 64); - part2sha.Finalize(); - - uint8 sessionKey[SHA256_DIGEST_LENGTH * 2]; - for (int i = 0; i < SHA256_DIGEST_LENGTH; ++i) - { - sessionKey[i * 2] = part1sha.GetDigest()[i]; - sessionKey[i * 2 + 1] = part2sha.GetDigest()[i]; - } - - K.SetBinary(sessionKey, SHA256_DIGEST_LENGTH * 2); - - BigNumber M1; - - uint8 hash[SHA256_DIGEST_LENGTH]; - sha.Initialize(); - sha.UpdateBigNumbers(&N, NULL); - sha.Finalize(); - memcpy(hash, sha.GetDigest(), sha.GetLength()); - - sha.Initialize(); - sha.UpdateBigNumbers(&g, NULL); - sha.Finalize(); - - for (int i = 0; i < sha.GetLength(); ++i) - hash[i] ^= sha.GetDigest()[i]; - - SHA256Hash shaI; - shaI.UpdateData(ByteArrayToHexStr(I.AsByteArray().get(), 32)); - shaI.Finalize(); - - // Concat all variables for M1 hash - sha.Initialize(); - sha.UpdateData(hash, SHA256_DIGEST_LENGTH); - sha.UpdateData(shaI.GetDigest(), shaI.GetLength()); - sha.UpdateBigNumbers(&s, &A, &B, &K, NULL); - sha.Finalize(); - - M1.SetBinary(sha.GetDigest(), sha.GetLength()); - - if (memcmp(M1.AsByteArray().get(), clientM1.AsByteArray().get(), 32)) - { - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_FAILED_LOGINS); - stmt->setString(0, _accountName); - LoginDatabase.Execute(stmt); - - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(AUTH_UNKNOWN_ACCOUNT); - ReplaceResponse(response, complete); - return false; - } - - uint64 numAccounts = 0; - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_GAME_ACCOUNTS); - stmt->setUInt32(0, _accountId); - PreparedQueryResult result = LoginDatabase.Query(stmt); - if (result) - numAccounts = result->GetRowCount(); - - if (!numAccounts) - { - Authentication::LogonResponse* noAccounts = new Authentication::LogonResponse(); - noAccounts->SetAuthResult(LOGIN_NO_GAME_ACCOUNT); - ReplaceResponse(response, noAccounts); - return false; - } - - Field* fields = result->Fetch(); - - //set expired game account bans to inactive - LoginDatabase.DirectExecute(LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPIRED_ACCOUNT_BANS)); - - BigNumber M; - sha.Initialize(); - sha.UpdateBigNumbers(&A, &M1, &K, NULL); - sha.Finalize(); - M.SetBinary(sha.GetDigest(), sha.GetLength()); - - BigNumber serverProof; - serverProof.SetRand(128 * 8); // just send garbage, server signature check is patched out in client - - BitStream stream; - ModuleInfo* password = sBattlenetMgr->CreateModule(_os, "Password"); - uint8 state = 3; - - stream.WriteBytes(&state, 1); - stream.WriteBytes(M.AsByteArray(32).get(), 32); - stream.WriteBytes(serverProof.AsByteArray(128).get(), 128); - - password->DataSize = stream.GetSize(); - password->Data = new uint8[password->DataSize]; - memcpy(password->Data, stream.GetBuffer(), password->DataSize); - - Authentication::ProofRequest* request = new Authentication::ProofRequest(); - request->Modules.push_back(password); - if (numAccounts > 1) - { - BitStream accounts; - state = 0; - accounts.WriteBytes(&state, 1); - accounts.Write(numAccounts, 8); - do - { - fields = result->Fetch(); - std::ostringstream name; - std::string originalName = fields[1].GetString(); - if (originalName.find('#') != std::string::npos) - name << "WoW" << uint32(fields[0].GetUInt8()); - else - name << originalName; - - accounts.Write(2, 8); - accounts.WriteString(name.str(), 8); - } while (result->NextRow()); - - ModuleInfo* selectGameAccount = sBattlenetMgr->CreateModule(_os, "SelectGameAccount"); - selectGameAccount->DataSize = accounts.GetSize(); - selectGameAccount->Data = new uint8[selectGameAccount->DataSize]; - memcpy(selectGameAccount->Data, accounts.GetBuffer(), selectGameAccount->DataSize); - request->Modules.push_back(selectGameAccount); - _modulesWaitingForData.push(MODULE_SELECT_GAME_ACCOUNT); - } - else - { - if (fields[4].GetBool()) - { - delete request; - - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - if (fields[2].GetUInt32() == fields[3].GetUInt32()) - { - complete->SetAuthResult(LOGIN_BANNED); - TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::AuthChallenge] Banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str()); - } - else - { - complete->SetAuthResult(LOGIN_SUSPENDED); - TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::AuthChallenge] Temporarily banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str()); - } - - ReplaceResponse(response, complete); - return false; - } - - _gameAccountId = fields[0].GetUInt32(); - _gameAccountName = fields[1].GetString(); - - request->Modules.push_back(sBattlenetMgr->CreateModule(_os, "RiskFingerprint")); - _modulesWaitingForData.push(MODULE_RISK_FINGERPRINT); - } - - ReplaceResponse(response, request); - return true; -} - -bool Battlenet::Session::HandleSelectGameAccountModule(BitStream* dataStream, ServerPacket** response) -{ - if (dataStream->Read<uint8>(8) != 1) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(AUTH_CORRUPTED_MODULE); - ReplaceResponse(response, complete); - return false; - } - - dataStream->Read<uint8>(8); - std::string account = dataStream->ReadString(8); - if (account.empty()) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(LOGIN_NO_GAME_ACCOUNT); - ReplaceResponse(response, complete); - return false; - } - - PreparedStatement* stmt; - if (account.substr(0, 3) != "WoW") - { - stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_GAME_ACCOUNT); - stmt->setString(0, account); - } - else - { - stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_GAME_ACCOUNT_UNNAMED); - stmt->setUInt8(0, atol(account.substr(3).c_str())); - } - - stmt->setUInt32(1, _accountId); - PreparedQueryResult result = LoginDatabase.Query(stmt); - if (!result) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(LOGIN_NO_GAME_ACCOUNT); - ReplaceResponse(response, complete); - return false; - } - - Field* fields = result->Fetch(); - if (fields[4].GetBool()) - { - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - if (fields[2].GetUInt32() == fields[3].GetUInt32()) - { - complete->SetAuthResult(LOGIN_BANNED); - TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::SelectGameAccount] Banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str()); - } - else - { - complete->SetAuthResult(LOGIN_SUSPENDED); - TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::SelectGameAccount] Temporarily banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str()); - } - - ReplaceResponse(response, complete); - return false; - } - - _gameAccountId = fields[0].GetUInt32(); - _gameAccountName = fields[1].GetString(); - - Authentication::ProofRequest* request = new Authentication::ProofRequest(); - request->Modules.push_back(sBattlenetMgr->CreateModule(_os, "RiskFingerprint")); - ReplaceResponse(response, request); - - _modulesWaitingForData.push(MODULE_RISK_FINGERPRINT); - return true; -} - -bool Battlenet::Session::HandleRiskFingerprintModule(BitStream* dataStream, ServerPacket** response) -{ - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - if (dataStream->Read<uint8>(8) == 1) - { - complete->AccountId = _accountId; - complete->GameAccountName = _gameAccountName; - complete->GameAccountFlags = GAMEACCOUNT_FLAG_PROPASS_LOCK; - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_FAILED_LOGINS); - stmt->setUInt32(0, _accountId); - if (PreparedQueryResult failedLoginsResult = LoginDatabase.Query(stmt)) - complete->FailedLogins = (*failedLoginsResult)[0].GetUInt32(); - - SQLTransaction trans = LoginDatabase.BeginTransaction(); - - stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_LAST_LOGIN_INFO); - stmt->setString(0, GetRemoteIpAddress().to_string()); - stmt->setUInt8(1, GetLocaleByName(_locale)); - stmt->setString(2, _os); - stmt->setUInt32(3, _accountId); - trans->Append(stmt); - - stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_SESSION_KEY); - stmt->setString(0, K.AsHexStr()); - stmt->setBool(1, true); - stmt->setUInt32(2, _accountId); - trans->Append(stmt); - - LoginDatabase.CommitTransaction(trans); - - _authed = true; - sBattlenetSessionMgr.AddSession(this); - } - else - complete->SetAuthResult(AUTH_BAD_VERSION_HASH); - - ReplaceResponse(response, complete); - return true; -} - -bool Battlenet::Session::HandleResumeModule(BitStream* dataStream, ServerPacket** response) -{ - if (dataStream->Read<uint8>(8) != 1) - { - Authentication::ResumeResponse* complete = new Authentication::ResumeResponse(); - complete->SetAuthResult(AUTH_CORRUPTED_MODULE); - ReplaceResponse(response, complete); - return false; - } - - static uint8 const ResumeClient = 0; - static uint8 const ResumeServer = 1; - - std::unique_ptr<uint8[]> clientChallenge = dataStream->ReadBytes(16); - std::unique_ptr<uint8[]> clientProof = dataStream->ReadBytes(32); - std::unique_ptr<uint8[]> serverChallenge = _reconnectProof.AsByteArray(16); - std::unique_ptr<uint8[]> sessionKey = K.AsByteArray(64); - - HmacSha256 clientPart(64, sessionKey.get()); - clientPart.UpdateData(&ResumeClient, 1); - clientPart.UpdateData(clientChallenge.get(), 16); - clientPart.UpdateData(serverChallenge.get(), 16); - clientPart.Finalize(); - - HmacSha256 serverPart(64, sessionKey.get()); - serverPart.UpdateData(&ResumeServer, 1); - serverPart.UpdateData(serverChallenge.get(), 16); - serverPart.UpdateData(clientChallenge.get(), 16); - serverPart.Finalize(); - - uint8 newSessionKey[64]; - memcpy(&newSessionKey[0], clientPart.GetDigest(), clientPart.GetLength()); - memcpy(&newSessionKey[32], serverPart.GetDigest(), serverPart.GetLength()); - - K.SetBinary(newSessionKey, 64); - - HmacSha256 proof(64, newSessionKey); - proof.UpdateData(&ResumeClient, 1); - proof.UpdateData(clientChallenge.get(), 16); - proof.UpdateData(serverChallenge.get(), 16); - proof.Finalize(); - - if (memcmp(proof.GetDigest(), clientProof.get(), serverPart.GetLength())) - { - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_FAILED_LOGINS); - stmt->setString(0, _accountName); - LoginDatabase.Execute(stmt); - - TC_LOG_DEBUG("server.battlenet", "[Battlenet::Resume] Invalid proof!"); - Authentication::ResumeResponse* result = new Authentication::ResumeResponse(); - result->SetAuthResult(AUTH_UNKNOWN_ACCOUNT); - ReplaceResponse(response, result); - return false; - } - - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_SESSION_KEY); - stmt->setString(0, K.AsHexStr()); - stmt->setBool(1, true); - stmt->setUInt32(2, _accountId); - LoginDatabase.Execute(stmt); - - HmacSha256 serverProof(64, newSessionKey); - serverProof.UpdateData(&ResumeServer, 1); - serverProof.UpdateData(serverChallenge.get(), 16); - serverProof.UpdateData(clientChallenge.get(), 16); - serverProof.Finalize(); - - ModuleInfo* resume = sBattlenetMgr->CreateModule(_os, "Resume"); - - BitStream resumeData; - uint8 state = 2; - resumeData.WriteBytes(&state, 1); - resumeData.WriteBytes(serverProof.GetDigest(), serverProof.GetLength()); - - resume->DataSize = resumeData.GetSize(); - resume->Data = new uint8[resume->DataSize]; - memcpy(resume->Data, resumeData.GetBuffer(), resume->DataSize); - - Authentication::ResumeResponse* result = new Authentication::ResumeResponse(); - result->Modules.push_back(resume); - ReplaceResponse(response, result); - _authed = true; - sBattlenetSessionMgr.AddSession(this); - return true; -} - -bool Battlenet::Session::UnhandledModule(BitStream* /*dataStream*/, ServerPacket** response) -{ - Authentication::LogonResponse* complete = new Authentication::LogonResponse(); - complete->SetAuthResult(AUTH_CORRUPTED_MODULE); - ReplaceResponse(response, complete); - return false; -} diff --git a/src/server/authserver/Server/BattlenetSession.h b/src/server/authserver/Server/BattlenetSession.h deleted file mode 100644 index 2798949de1c..00000000000 --- a/src/server/authserver/Server/BattlenetSession.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef _BATTLENETSOCKET_H -#define _BATTLENETSOCKET_H - -#include "BattlenetPackets.h" -#include "BattlenetPacketCrypt.h" -#include "Socket.h" -#include "BigNumber.h" -#include <memory> -#include <boost/asio/ip/tcp.hpp> - -using boost::asio::ip::tcp; - -namespace Battlenet -{ - struct PacketHeader; - class BitStream; - - enum ModuleType - { - MODULE_PASSWORD, - MODULE_TOKEN, - MODULE_THUMBPRINT, - MODULE_SELECT_GAME_ACCOUNT, - MODULE_RISK_FINGERPRINT, - MODULE_RESUME, - - MODULE_COUNT - }; - - enum class BufferSizes : uint32 - { - SRP_6_V = 0x80, - SRP_6_S = 0x20, - Read = 0x4000 - }; - - class Session : public Socket<Session> - { - typedef Socket<Session> BattlenetSocket; - - public: - explicit Session(tcp::socket&& socket); - ~Session(); - - void LogUnhandledPacket(ClientPacket const& packet); - - // Authentication - void HandleLogonRequest(Authentication::LogonRequest const& logonRequest); - void HandleResumeRequest(Authentication::ResumeRequest const& resumeRequest); - void HandleProofResponse(Authentication::ProofResponse const& proofResponse); - - // Connection - void HandlePing(Connection::Ping const& ping); - void HandleEnableEncryption(Connection::EnableEncryption const& enableEncryption); - void HandleLogoutRequest(Connection::LogoutRequest const& logoutRequest); - - // WoWRealm - void HandleListSubscribeRequest(WoWRealm::ListSubscribeRequest const& listSubscribeRequest); - void HandleJoinRequestV2(WoWRealm::JoinRequestV2 const& joinRequest); - - void Start() override; - - void AsyncWrite(ServerPacket* packet); - - protected: - void ReadHandler() override; - - private: - void _SetVSFields(std::string const& rI); - - typedef bool(Session::*ModuleHandler)(BitStream* dataStream, ServerPacket** response); - static ModuleHandler const ModuleHandlers[MODULE_COUNT]; - - bool HandlePasswordModule(BitStream* dataStream, ServerPacket** response); - bool HandleSelectGameAccountModule(BitStream* dataStream, ServerPacket** response); - bool HandleRiskFingerprintModule(BitStream* dataStream, ServerPacket** response); - bool HandleResumeModule(BitStream* dataStream, ServerPacket** response); - bool UnhandledModule(BitStream* dataStream, ServerPacket** response); - - uint32 _accountId; - std::string _accountName; - std::string _locale; - std::string _os; - uint32 _build; - uint32 _gameAccountId; - std::string _gameAccountName; - AccountTypes _accountSecurityLevel; - - BigNumber N; - BigNumber g; - BigNumber k; - - BigNumber I; - BigNumber s; - BigNumber v; - - BigNumber b; - BigNumber B; - BigNumber K; // session key - - BigNumber _reconnectProof; - - std::queue<ModuleType> _modulesWaitingForData; - - PacketCrypt _crypt; - bool _authed; - }; - -} - -#endif // _BATTLENETSOCKET_H diff --git a/src/server/authserver/Server/BattlenetSessionManager.cpp b/src/server/authserver/Server/BattlenetSessionManager.cpp deleted file mode 100644 index 91ba2b65094..00000000000 --- a/src/server/authserver/Server/BattlenetSessionManager.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "BattlenetSessionManager.h" - -bool Battlenet::SessionManager::StartNetwork(boost::asio::io_service& service, std::string const& bindIp, uint16 port) -{ - if (!BaseSocketMgr::StartNetwork(service, bindIp, port)) - return false; - - _acceptor->AsyncAcceptManaged(&OnSocketAccept); - return true; -} - -NetworkThread<Battlenet::Session>* Battlenet::SessionManager::CreateThreads() const -{ - return new NetworkThread<Session>[GetNetworkThreadCount()]; -} - -void Battlenet::SessionManager::OnSocketAccept(tcp::socket&& sock) -{ - sBattlenetSessionMgr.OnSocketOpen(std::forward<tcp::socket>(sock)); -} diff --git a/src/server/authserver/Server/BattlenetSessionManager.h b/src/server/authserver/Server/BattlenetSessionManager.h deleted file mode 100644 index b5a54438ef1..00000000000 --- a/src/server/authserver/Server/BattlenetSessionManager.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef BattlenetSessionManager_h__ -#define BattlenetSessionManager_h__ - -#include "BattlenetSession.h" -#include "SocketMgr.h" - -namespace Battlenet -{ -#pragma pack(push, 1) - - struct SessionInfo - { - uint32 AccountId; - uint32 GameAccountIndex; - - bool operator<(SessionInfo const& right) const - { - return memcmp(this, &right, sizeof(SessionInfo)) < 0; - } - }; - -#pragma pack(pop) - - class SessionManager : SocketMgr<Session> - { - typedef SocketMgr<Session> BaseSocketMgr; - - public: - static SessionManager& Instance() - { - static SessionManager instance; - return instance; - } - - bool StartNetwork(boost::asio::io_service& service, std::string const& bindIp, uint16 port) override; - - // noop for now, will be needed later to broadcast realmlist updates for example - void AddSession(Session* /*session*/) { } - - void RemoveSession(Session* /*session*/) { } - - protected: - NetworkThread<Session>* CreateThreads() const override; - - private: - static void OnSocketAccept(tcp::socket&& sock); - - std::map<SessionInfo, Session> _sessions; - }; -} - -#define sBattlenetSessionMgr Battlenet::SessionManager::Instance() - -#endif // BattlenetSessionManager_h__ |
