chore(Core/Authserver): restyle authserver library with astyle (#3464)
This commit is contained in:
@@ -154,7 +154,7 @@ public:
|
||||
Patches::const_iterator begin() const { return _patches.begin(); }
|
||||
Patches::const_iterator end() const { return _patches.end(); }
|
||||
void LoadPatchMD5(char*);
|
||||
bool GetHash(char * pat, uint8 mymd5[16]);
|
||||
bool GetHash(char* pat, uint8 mymd5[16]);
|
||||
|
||||
private:
|
||||
void LoadPatchesInfo();
|
||||
@@ -206,16 +206,16 @@ void AuthSocket::OnClose(void)
|
||||
// Read the packet from the client
|
||||
void AuthSocket::OnRead()
|
||||
{
|
||||
#define MAX_AUTH_LOGON_CHALLENGES_IN_A_ROW 3
|
||||
#define MAX_AUTH_LOGON_CHALLENGES_IN_A_ROW 3
|
||||
uint32 challengesInARow = 0;
|
||||
|
||||
#define MAX_AUTH_GET_REALM_LIST 10
|
||||
#define MAX_AUTH_GET_REALM_LIST 10
|
||||
uint32 challengesInARowRealmList = 0;
|
||||
|
||||
uint8 _cmd;
|
||||
while (1)
|
||||
{
|
||||
if (!socket().recv_soft((char *)&_cmd, 1))
|
||||
if (!socket().recv_soft((char*)&_cmd, 1))
|
||||
return;
|
||||
|
||||
if (_cmd == AUTH_LOGON_CHALLENGE)
|
||||
@@ -228,7 +228,8 @@ void AuthSocket::OnRead()
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (_cmd == REALM_LIST) {
|
||||
else if (_cmd == REALM_LIST)
|
||||
{
|
||||
challengesInARowRealmList++;
|
||||
if (challengesInARowRealmList == MAX_AUTH_GET_REALM_LIST)
|
||||
{
|
||||
@@ -297,7 +298,7 @@ void AuthSocket::_SetVSFields(const std::string& rI)
|
||||
v = g.ModExp(x, N);
|
||||
|
||||
// No SQL injection (username escaped)
|
||||
char *v_hex, *s_hex;
|
||||
char* v_hex, *s_hex;
|
||||
v_hex = v.AsHexStr();
|
||||
s_hex = s.AsHexStr();
|
||||
|
||||
@@ -342,7 +343,7 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
socket().send((char const*)pkt.contents(), pkt.size());
|
||||
return true;
|
||||
}
|
||||
if (LastLoginAttemptCleanTime+60 < currTime)
|
||||
if (LastLoginAttemptCleanTime + 60 < currTime)
|
||||
{
|
||||
LastLoginAttemptTimeForIP.clear();
|
||||
LastLoginAttemptCleanTime = currTime;
|
||||
@@ -355,11 +356,11 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
std::vector<uint8> buf;
|
||||
buf.resize(4);
|
||||
|
||||
socket().recv((char *)&buf[0], 4);
|
||||
socket().recv((char*)&buf[0], 4);
|
||||
|
||||
EndianConvertPtr<uint16>(&buf[0]);
|
||||
|
||||
uint16 remaining = ((sAuthLogonChallenge_C *)&buf[0])->size;
|
||||
uint16 remaining = ((sAuthLogonChallenge_C*)&buf[0])->size;
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] got header, body is %#04x bytes", remaining);
|
||||
#endif
|
||||
@@ -370,10 +371,10 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
//No big fear of memory outage (size is int16, i.e. < 65536)
|
||||
buf.resize(remaining + buf.size() + 1);
|
||||
buf[buf.size() - 1] = 0;
|
||||
sAuthLogonChallenge_C *ch = (sAuthLogonChallenge_C*)&buf[0];
|
||||
sAuthLogonChallenge_C* ch = (sAuthLogonChallenge_C*)&buf[0];
|
||||
|
||||
// Read the remaining of the packet
|
||||
socket().recv((char *)&buf[4], remaining);
|
||||
socket().recv((char*)&buf[4], remaining);
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] got full packet, %#04x bytes", ch->size);
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] name(%d): '%s'", ch->I_len, ch->I);
|
||||
@@ -416,7 +417,7 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
{
|
||||
pkt << uint8(WOW_FAIL_BANNED);
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] Banned ip tries to login!",socket().getRemoteAddress().c_str(), socket().getRemotePort());
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] Banned ip tries to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort());
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@@ -577,7 +578,7 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
|
||||
_localizationName.resize(4);
|
||||
for (int i = 0; i < 4; ++i)
|
||||
_localizationName[i] = ch->country[4-i-1];
|
||||
_localizationName[i] = ch->country[4 - i - 1];
|
||||
|
||||
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
@@ -606,7 +607,7 @@ bool AuthSocket::_HandleLogonProof()
|
||||
// Read the packet
|
||||
sAuthLogonProof_C lp;
|
||||
|
||||
if (!socket().recv((char *)&lp, sizeof(sAuthLogonProof_C)))
|
||||
if (!socket().recv((char*)&lp, sizeof(sAuthLogonProof_C)))
|
||||
return false;
|
||||
|
||||
_status = STATUS_CLOSED;
|
||||
@@ -707,9 +708,9 @@ bool AuthSocket::_HandleLogonProof()
|
||||
|
||||
// Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account
|
||||
// No SQL injection (escaped user name) and IP address as received by socket
|
||||
const char *K_hex = K.AsHexStr();
|
||||
const char* K_hex = K.AsHexStr();
|
||||
|
||||
PreparedStatement *stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGONPROOF);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGONPROOF);
|
||||
stmt->setString(0, K_hex);
|
||||
stmt->setString(1, socket().getRemoteAddress().c_str());
|
||||
stmt->setUInt32(2, GetLocaleByName(_localizationName));
|
||||
@@ -752,7 +753,7 @@ bool AuthSocket::_HandleLogonProof()
|
||||
proof.unk1 = 0x00800000; // Accountflags. 0x01 = GM, 0x08 = Trial, 0x00800000 = Pro pass (arena tournament)
|
||||
proof.unk2 = 0x00; // SurveyId
|
||||
proof.unk3 = 0x00;
|
||||
socket().send((char *)&proof, sizeof(proof));
|
||||
socket().send((char*)&proof, sizeof(proof));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -761,7 +762,7 @@ bool AuthSocket::_HandleLogonProof()
|
||||
proof.cmd = AUTH_LOGON_PROOF;
|
||||
proof.error = 0;
|
||||
proof.unk2 = 0x00;
|
||||
socket().send((char *)&proof, sizeof(proof));
|
||||
socket().send((char*)&proof, sizeof(proof));
|
||||
}
|
||||
|
||||
///- Set _status to authed!
|
||||
@@ -853,11 +854,11 @@ bool AuthSocket::_HandleReconnectChallenge()
|
||||
std::vector<uint8> buf;
|
||||
buf.resize(4);
|
||||
|
||||
socket().recv((char *)&buf[0], 4);
|
||||
socket().recv((char*)&buf[0], 4);
|
||||
|
||||
EndianConvertPtr<uint16>(&buf[0]);
|
||||
|
||||
uint16 remaining = ((sAuthLogonChallenge_C *)&buf[0])->size;
|
||||
uint16 remaining = ((sAuthLogonChallenge_C*)&buf[0])->size;
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "[ReconnectChallenge] got header, body is %#04x bytes", remaining);
|
||||
#endif
|
||||
@@ -871,10 +872,10 @@ bool AuthSocket::_HandleReconnectChallenge()
|
||||
// No big fear of memory outage (size is int16, i.e. < 65536)
|
||||
buf.resize(remaining + buf.size() + 1);
|
||||
buf[buf.size() - 1] = 0;
|
||||
sAuthLogonChallenge_C *ch = (sAuthLogonChallenge_C*)&buf[0];
|
||||
sAuthLogonChallenge_C* ch = (sAuthLogonChallenge_C*)&buf[0];
|
||||
|
||||
// Read the remaining of the packet
|
||||
socket().recv((char *)&buf[4], remaining);
|
||||
socket().recv((char*)&buf[4], remaining);
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "[ReconnectChallenge] got full packet, %#04x bytes", ch->size);
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "[ReconnectChallenge] name(%d): '%s'", ch->I_len, ch->I);
|
||||
@@ -933,7 +934,7 @@ bool AuthSocket::_HandleReconnectProof()
|
||||
#endif
|
||||
// Read the packet
|
||||
sAuthReconnectProof_C lp;
|
||||
if (!socket().recv((char *)&lp, sizeof(sAuthReconnectProof_C)))
|
||||
if (!socket().recv((char*)&lp, sizeof(sAuthReconnectProof_C)))
|
||||
return false;
|
||||
|
||||
_status = STATUS_CLOSED;
|
||||
@@ -1032,7 +1033,7 @@ bool AuthSocket::_HandleRealmList()
|
||||
size_t RealmListSize = 0;
|
||||
for (RealmList::RealmMap::const_iterator i = sRealmList->begin(); i != sRealmList->end(); ++i)
|
||||
{
|
||||
const Realm &realm = i->second;
|
||||
const Realm& realm = i->second;
|
||||
// don't work with realms which not compatible with the client
|
||||
bool okBuild = ((_expversion & POST_BC_EXP_FLAG) && realm.gamebuild == _build) || ((_expversion & PRE_BC_EXP_FLAG) && !AuthHelper::IsPreBCAcceptedClientBuild(realm.gamebuild));
|
||||
|
||||
@@ -1199,8 +1200,8 @@ void PatcherRunnable::run() { }
|
||||
#include <errno.h>
|
||||
void Patcher::LoadPatchesInfo()
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
DIR* dirp;
|
||||
struct dirent* dp;
|
||||
dirp = opendir("./patches/");
|
||||
|
||||
if (!dirp)
|
||||
@@ -1248,7 +1249,7 @@ void Patcher::LoadPatchesInfo()
|
||||
#endif
|
||||
|
||||
// Calculate and store MD5 hash for a given patch file
|
||||
void Patcher::LoadPatchMD5(char *szFileName)
|
||||
void Patcher::LoadPatchMD5(char* szFileName)
|
||||
{
|
||||
// Try to open the patch file
|
||||
std::string path = "./patches/";
|
||||
@@ -1280,11 +1281,11 @@ void Patcher::LoadPatchMD5(char *szFileName)
|
||||
|
||||
// Store the result in the internal patch hash map
|
||||
_patches[path] = new PATCH_INFO;
|
||||
MD5_Final((uint8 *)&_patches[path]->md5, &ctx);
|
||||
MD5_Final((uint8*)&_patches[path]->md5, &ctx);
|
||||
}
|
||||
|
||||
// Get cached MD5 hash for a given patch file
|
||||
bool Patcher::GetHash(char * pat, uint8 mymd5[16])
|
||||
bool Patcher::GetHash(char* pat, uint8 mymd5[16])
|
||||
{
|
||||
for (Patches::iterator i = _patches.begin(); i != _patches.end(); ++i)
|
||||
if (!stricmp(pat, i->first.c_str()))
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual int make_svc_handler(RealmSocket* &sh)
|
||||
virtual int make_svc_handler(RealmSocket*& sh)
|
||||
{
|
||||
if (sh == 0)
|
||||
ACE_NEW_RETURN(sh, RealmSocket, -1);
|
||||
|
||||
@@ -26,7 +26,7 @@ int base32_decode(const char* encoded, char* result, int bufSize)
|
||||
int buffer = 0;
|
||||
int bitsLeft = 0;
|
||||
int count = 0;
|
||||
for (const char *ptr = encoded; count < bufSize && *ptr; ++ptr)
|
||||
for (const char* ptr = encoded; count < bufSize && *ptr; ++ptr)
|
||||
{
|
||||
char ch = *ptr;
|
||||
if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' || ch == '-')
|
||||
@@ -66,19 +66,19 @@ namespace TOTP
|
||||
unsigned int GenerateToken(const char* b32key)
|
||||
{
|
||||
size_t keySize = strlen(b32key);
|
||||
int bufsize = (keySize + 7)/8*5;
|
||||
int bufsize = (keySize + 7) / 8 * 5;
|
||||
char* encoded = new char[bufsize];
|
||||
memset(encoded, 0, bufsize);
|
||||
unsigned int hmacResSize = HMAC_RES_SIZE;
|
||||
unsigned char hmacRes[HMAC_RES_SIZE];
|
||||
unsigned long timestamp = time(nullptr)/30;
|
||||
unsigned long timestamp = time(nullptr) / 30;
|
||||
unsigned char challenge[8];
|
||||
for (int i = 8; i--;timestamp >>= 8)
|
||||
for (int i = 8; i--; timestamp >>= 8)
|
||||
challenge[i] = timestamp;
|
||||
base32_decode(b32key, encoded, bufsize);
|
||||
HMAC(EVP_sha1(), encoded, bufsize, challenge, 8, hmacRes, &hmacResSize);
|
||||
unsigned int offset = hmacRes[19] & 0xF;
|
||||
unsigned int truncHash = (hmacRes[offset] << 24) | (hmacRes[offset+1] << 16 )| (hmacRes[offset+2] << 8) | (hmacRes[offset+3]);
|
||||
unsigned int truncHash = (hmacRes[offset] << 24) | (hmacRes[offset + 1] << 16 ) | (hmacRes[offset + 2] << 8) | (hmacRes[offset + 3]);
|
||||
truncHash &= 0x7FFFFFFF;
|
||||
delete[] encoded;
|
||||
return truncHash % 1000000;
|
||||
|
||||
Reference in New Issue
Block a user