Advertisement
Guest User

AuthSession.h

a guest
Jun 5th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. /*
  2. * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
  3. * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18.  
  19. #ifndef __AUTHSESSION_H__
  20. #define __AUTHSESSION_H__
  21.  
  22. #include "Common.h"
  23. #include "ByteBuffer.h"
  24. #include "Socket.h"
  25. #include "BigNumber.h"
  26. #include <memory>
  27. #include <boost/asio/ip/tcp.hpp>
  28.  
  29. using boost::asio::ip::tcp;
  30.  
  31. struct AuthHandler;
  32.  
  33. class AuthSession : public Socket<AuthSession>
  34. {
  35. public:
  36. static std::unordered_map<uint8, AuthHandler> InitHandlers();
  37.  
  38. AuthSession(tcp::socket&& socket) : Socket(std::move(socket)),
  39. _status(STATUS_CHALLENGE), _build(0), _expversion(0), _accountSecurityLevel(SEC_PLAYER)
  40. {
  41. N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7");
  42. g.SetDword(7);
  43. }
  44.  
  45. void Start() override
  46. {
  47. AsyncRead();
  48. }
  49.  
  50. void SendPacket(ByteBuffer& packet);
  51.  
  52. protected:
  53. void ReadHandler() override;
  54.  
  55. private:
  56. enum eStatus
  57. {
  58. STATUS_CHALLENGE,
  59. STATUS_LOGON_PROOF,
  60. STATUS_RECON_PROOF,
  61. STATUS_PATCH,
  62. STATUS_AUTHED,
  63. STATUS_CLOSED
  64. };
  65.  
  66. bool HandleLogonChallenge();
  67. bool HandleLogonProof();
  68. bool HandleReconnectChallenge();
  69. bool HandleReconnectProof();
  70. bool HandleRealmList();
  71.  
  72. //data transfer handle for patch
  73. bool HandleXferResume();
  74. bool HandleXferCancel();
  75. bool HandleXferAccept();
  76.  
  77. void SetVSFields(const std::string& rI);
  78.  
  79. BigNumber N, s, g, v;
  80. BigNumber b, B;
  81. BigNumber K;
  82. BigNumber _reconnectProof;
  83.  
  84. eStatus _status;
  85. std::string _tokenKey;
  86. std::string _login;
  87. std::string _localizationName;
  88. std::string _os;
  89. uint16 _build;
  90. uint8 _expversion;
  91.  
  92. AccountTypes _accountSecurityLevel;
  93. };
  94.  
  95. #pragma pack(push, 1)
  96.  
  97. struct AuthHandler
  98. {
  99. uint32 status;
  100. size_t packetSize;
  101. bool (AuthSession::*handler)();
  102. };
  103.  
  104. #pragma pack(pop)
  105.  
  106. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement