forked from lduguid/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AuthSocket.h
136 lines (110 loc) · 3.69 KB
/
AuthSocket.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
* Copyright (C) 2009-2011 MaNGOSZero <https://github.com/mangos/zero>
* Copyright (C) 2011-2016 Nostalrius <https://nostalrius.org>
* Copyright (C) 2016-2017 Elysium Project <https://github.com/elysium-project>
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/// \addtogroup realmd
/// @{
/// \file
#ifndef _AUTHSOCKET_H
#define _AUTHSOCKET_H
#include "Common.h"
#include "Auth/BigNumber.h"
#include "Auth/Sha1.h"
#include "ByteBuffer.h"
#include "BufferedSocket.h"
struct PINData
{
uint8 salt[16];
uint8 hash[20];
};
enum LockFlag
{
NONE = 0x00,
IP_LOCK = 0x01,
FIXED_PIN = 0x02,
TOTP = 0x04,
ALWAYS_ENFORCE = 0x08
};
/// Handle login commands
class AuthSocket: public BufferedSocket
{
public:
const static int s_BYTE_SIZE = 32;
AuthSocket();
~AuthSocket();
void OnAccept();
void OnRead();
void SendProof(Sha1Hash sha);
void LoadRealmlist(ByteBuffer &pkt);
bool VerifyPinData(uint32 pin, const PINData& clientData);
uint32 GenerateTotpPin(const std::string& secret, int interval);
bool _HandleLogonChallenge();
bool _HandleLogonProof();
bool _HandleReconnectChallenge();
bool _HandleReconnectProof();
bool _HandleRealmList();
//data transfer handle for patch
bool _HandleXferResume();
bool _HandleXferCancel();
bool _HandleXferAccept();
void _SetVSFields(const std::string& rI);
private:
enum eStatus
{
STATUS_CHALLENGE,
STATUS_LOGON_PROOF,
STATUS_RECON_PROOF,
STATUS_PATCH, // unused in CMaNGOS
STATUS_AUTHED,
STATUS_CLOSED
};
BigNumber N, s, g, v;
BigNumber b, B;
BigNumber K;
BigNumber _reconnectProof;
bool _authed, promptPin;
eStatus _status;
std::string _login;
std::string _safelogin;
std::string securityInfo;
BigNumber serverSecuritySalt;
LockFlag lockFlags;
uint32 gridSeed;
static constexpr uint32 Win = 'Win';
static constexpr uint32 OSX = 'OSX';
static constexpr uint32 X86 = 'x86';
static constexpr uint32 PPC = 'PPC';
uint32 _os;
uint32 _platform;
uint32 _accountId;
uint32 _lastRealmListRequest;
// Since GetLocaleByName() is _NOT_ bijective, we have to store the locale as a string. Otherwise we can't differ
// between enUS and enGB, which is important for the patch system
std::string _localizationName;
uint16 _build;
AccountTypes GetSecurityOn(uint32 realmId) const;
void LoadAccountSecurityLevels(uint32 accountId);
AccountTypes _accountDefaultSecurityLevel;
typedef std::map<uint32, AccountTypes> AccountSecurityMap;
AccountSecurityMap _accountSecurityOnRealm;
ACE_HANDLE patch_;
void InitPatch();
};
#endif
/// @}