Skip to content

Commit bb4424c

Browse files
committed
Core/Authserver: Remove blocking query in HandleLogonProof
1 parent 27d5080 commit bb4424c

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

src/server/authserver/Server/AuthSession.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -517,39 +517,39 @@ bool AuthSession::HandleLogonProof()
517517
stmt->setString(3, _os);
518518
stmt->setInt16(4, _timezoneOffset.count());
519519
stmt->setString(5, _accountInfo.Login);
520-
LoginDatabase.DirectExecute(stmt);
521-
522-
// Finish SRP6 and send the final result to the client
523-
Trinity::Crypto::SHA1::Digest M2 = Trinity::Crypto::SRP6::GetSessionVerifier(logonProof->A, logonProof->clientM, _sessionKey);
524-
525-
ByteBuffer packet;
526-
if (_expversion & POST_BC_EXP_FLAG) // 2.x and 3.x clients
520+
_queryProcessor.AddCallback(LoginDatabase.AsyncQuery(stmt)
521+
.WithPreparedCallback([this, M2 = Trinity::Crypto::SRP6::GetSessionVerifier(logonProof->A, logonProof->clientM, _sessionKey)](PreparedQueryResult const&)
527522
{
528-
sAuthLogonProof_S proof;
529-
proof.M2 = M2;
530-
proof.cmd = AUTH_LOGON_PROOF;
531-
proof.error = 0;
532-
proof.AccountFlags = 0x00800000; // 0x01 = GM, 0x08 = Trial, 0x00800000 = Pro pass (arena tournament)
533-
proof.SurveyId = 0;
534-
proof.LoginFlags = 0; // 0x1 = has account message
535-
536-
packet.resize(sizeof(proof));
537-
std::memcpy(packet.contents(), &proof, sizeof(proof));
538-
}
539-
else
540-
{
541-
sAuthLogonProof_S_Old proof;
542-
proof.M2 = M2;
543-
proof.cmd = AUTH_LOGON_PROOF;
544-
proof.error = 0;
545-
proof.unk2 = 0x00;
546-
547-
packet.resize(sizeof(proof));
548-
std::memcpy(packet.contents(), &proof, sizeof(proof));
549-
}
523+
// Finish SRP6 and send the final result to the client
524+
ByteBuffer packet;
525+
if (_expversion & POST_BC_EXP_FLAG) // 2.x and 3.x clients
526+
{
527+
sAuthLogonProof_S proof;
528+
proof.M2 = M2;
529+
proof.cmd = AUTH_LOGON_PROOF;
530+
proof.error = 0;
531+
proof.AccountFlags = 0x00800000; // 0x01 = GM, 0x08 = Trial, 0x00800000 = Pro pass (arena tournament)
532+
proof.SurveyId = 0;
533+
proof.LoginFlags = 0; // 0x1 = has account message
534+
535+
packet.resize(sizeof(proof));
536+
std::memcpy(packet.contents(), &proof, sizeof(proof));
537+
}
538+
else
539+
{
540+
sAuthLogonProof_S_Old proof;
541+
proof.M2 = M2;
542+
proof.cmd = AUTH_LOGON_PROOF;
543+
proof.error = 0;
544+
proof.unk2 = 0x00;
545+
546+
packet.resize(sizeof(proof));
547+
std::memcpy(packet.contents(), &proof, sizeof(proof));
548+
}
550549

551-
SendPacket(packet);
552-
_status = STATUS_AUTHED;
550+
SendPacket(packet);
551+
_status = STATUS_AUTHED;
552+
}));
553553
}
554554
else
555555
{

src/server/database/Database/Implementation/LoginDatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void LoginDatabaseConnection::DoPrepareStatements()
3636
PrepareStatement(LOGIN_INS_ACCOUNT_AUTO_BANNED, "INSERT INTO account_banned (id, bandate, unbandate, bannedby, banreason, active) VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Trinity Auth', 'Failed login autoban', 1)", CONNECTION_ASYNC);
3737
PrepareStatement(LOGIN_DEL_ACCOUNT_BANNED, "DELETE FROM account_banned WHERE id = ?", CONNECTION_ASYNC);
3838
PrepareStatement(LOGIN_UPD_LOGON, "UPDATE account SET salt = ?, verifier = ? WHERE id = ?", CONNECTION_ASYNC);
39-
PrepareStatement(LOGIN_UPD_LOGONPROOF, "UPDATE account SET session_key_auth = ?, last_ip = ?, last_login = NOW(), locale = ?, failed_logins = 0, os = ?, timezone_offset = ? WHERE username = ?", CONNECTION_SYNCH);
39+
PrepareStatement(LOGIN_UPD_LOGONPROOF, "UPDATE account SET session_key_auth = ?, last_ip = ?, last_login = NOW(), locale = ?, failed_logins = 0, os = ?, timezone_offset = ? WHERE username = ?", CONNECTION_ASYNC);
4040
PrepareStatement(LOGIN_SEL_LOGONCHALLENGE, "SELECT a.id, a.username, a.locked, a.lock_country, a.last_ip, a.failed_logins, ab.unbandate > UNIX_TIMESTAMP() OR ab.unbandate = ab.bandate, "
4141
"ab.unbandate = ab.bandate, aa.SecurityLevel, a.totp_secret, a.salt, a.verifier "
4242
"FROM account a LEFT JOIN account_access aa ON a.id = aa.AccountID LEFT JOIN account_banned ab ON ab.id = a.id AND ab.active = 1 WHERE a.username = ?", CONNECTION_ASYNC);

0 commit comments

Comments
 (0)