PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/src/server/bnetserver/Server/Session.h

https://gitlab.com/IlluminatiCore/IlluminatiCore
C Header | 148 lines | 93 code | 34 blank | 21 comment | 0 complexity | 848067fcafab4cb306575cdcc877aa79 MD5 | raw file
Possible License(s): GPL-2.0, BSD-2-Clause
  1. /*
  2. * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef Session_h__
  18. #define Session_h__
  19. #include "Packets.h"
  20. #include "BattlenetPacketCrypt.h"
  21. #include "Socket.h"
  22. #include "BigNumber.h"
  23. #include <memory>
  24. #include <boost/asio/ip/tcp.hpp>
  25. struct Realm;
  26. using boost::asio::ip::tcp;
  27. namespace Battlenet
  28. {
  29. struct PacketHeader;
  30. class BitStream;
  31. enum ModuleType
  32. {
  33. MODULE_PASSWORD,
  34. MODULE_TOKEN,
  35. MODULE_THUMBPRINT,
  36. MODULE_SELECT_GAME_ACCOUNT,
  37. MODULE_RISK_FINGERPRINT,
  38. MODULE_RESUME,
  39. MODULE_COUNT
  40. };
  41. enum class BufferSizes : uint32
  42. {
  43. SRP_6_V = 0x80,
  44. SRP_6_S = 0x20,
  45. Read = 0x4000
  46. };
  47. class Session : public Socket<Session>
  48. {
  49. typedef Socket<Session> BattlenetSocket;
  50. public:
  51. explicit Session(tcp::socket&& socket);
  52. ~Session();
  53. void LogUnhandledPacket(PacketHeader const& header);
  54. // Authentication
  55. void HandleLogonRequest(Authentication::LogonRequest const& logonRequest);
  56. void HandleResumeRequest(Authentication::ResumeRequest const& resumeRequest);
  57. void HandleProofResponse(Authentication::ProofResponse const& proofResponse);
  58. // Connection
  59. void HandlePing(Connection::Ping const& ping);
  60. void HandleEnableEncryption(Connection::EnableEncryption const& enableEncryption);
  61. void HandleLogoutRequest(Connection::LogoutRequest const& logoutRequest);
  62. void HandleConnectionClosing(Connection::ConnectionClosing const& connectionClosing);
  63. // WoWRealm
  64. void HandleListSubscribeRequest(WoWRealm::ListSubscribeRequest const& listSubscribeRequest);
  65. void HandleListUnsubscribe(WoWRealm::ListUnsubscribe const& listUnsubscribe);
  66. void HandleJoinRequestV2(WoWRealm::JoinRequestV2 const& joinRequest);
  67. // Friends
  68. void HandleSocialNetworkCheckConnected(Friends::SocialNetworkCheckConnected const& socialNetworkCheckConnected);
  69. // Cache
  70. void HandleGetStreamItemsRequest(Cache::GetStreamItemsRequest const& getStreamItemsRequest);
  71. void Start() override;
  72. void UpdateRealms(std::vector<Realm const*>& realms, std::vector<RealmId>& deletedRealms);
  73. uint32 GetAccountId() const { return _accountId; }
  74. uint32 GetGameAccountId() const { return _gameAccountId; }
  75. bool IsSubscribedToRealmListUpdates() const { return _subscribedToRealmListUpdates; }
  76. void AsyncWrite(ServerPacket* packet);
  77. protected:
  78. void ReadHandler() override;
  79. private:
  80. void _SetVSFields(std::string const& rI);
  81. typedef bool(Session::*ModuleHandler)(BitStream* dataStream, ServerPacket** response);
  82. static ModuleHandler const ModuleHandlers[MODULE_COUNT];
  83. bool HandlePasswordModule(BitStream* dataStream, ServerPacket** response);
  84. bool HandleSelectGameAccountModule(BitStream* dataStream, ServerPacket** response);
  85. bool HandleRiskFingerprintModule(BitStream* dataStream, ServerPacket** response);
  86. bool HandleResumeModule(BitStream* dataStream, ServerPacket** response);
  87. bool UnhandledModule(BitStream* dataStream, ServerPacket** response);
  88. WoWRealm::ListUpdate* BuildListUpdate(Realm const* realm) const;
  89. std::string GetClientInfo() const;
  90. uint32 _accountId;
  91. std::string _accountName;
  92. std::string _locale;
  93. std::string _os;
  94. uint32 _build;
  95. uint32 _gameAccountId;
  96. std::string _gameAccountName;
  97. AccountTypes _accountSecurityLevel;
  98. BigNumber N;
  99. BigNumber g;
  100. BigNumber k;
  101. BigNumber I;
  102. BigNumber s;
  103. BigNumber v;
  104. BigNumber b;
  105. BigNumber B;
  106. BigNumber K; // session key
  107. BigNumber _reconnectProof;
  108. std::queue<ModuleType> _modulesWaitingForData;
  109. PacketCrypt _crypt;
  110. bool _authed;
  111. bool _subscribedToRealmListUpdates;
  112. };
  113. }
  114. #endif // Session_h__