mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-02 08:42:45 +03:00
feat(grunt): add Grunt:ClientLink:m_state enum
This commit is contained in:
parent
b94d5825bb
commit
5ef7dce744
@ -23,7 +23,7 @@ Grunt::ClientLink::ClientLink(Grunt::ClientResponse& clientResponse) {
|
||||
|
||||
this->m_clientResponse = &clientResponse;
|
||||
|
||||
this->SetState(0);
|
||||
this->SetState(STATE_NONE);
|
||||
|
||||
if (this->m_timer.m_thread.Valid()) {
|
||||
this->m_interval = 100;
|
||||
@ -37,9 +37,9 @@ void Grunt::ClientLink::Call() {
|
||||
|
||||
this->m_critSect.Enter();
|
||||
|
||||
if (this->m_state == 2) {
|
||||
if (this->m_state == STATE_CONNECTED) {
|
||||
this->m_clientResponse->GetLogonMethod();
|
||||
} else if (this->m_state == 6 && !this->m_clientResponse->OnlineIdle()) {
|
||||
} else if (this->m_state == STATE_AUTHENTICATED && !this->m_clientResponse->OnlineIdle()) {
|
||||
this->Disconnect();
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ int32_t Grunt::ClientLink::CmdAuthLogonChallenge(CDataStore& msg) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
this->SetState(2);
|
||||
this->SetState(STATE_CONNECTED);
|
||||
|
||||
if (result >= GRUNT_RESULT_LAST) {
|
||||
// TODO WLog error
|
||||
@ -189,10 +189,10 @@ int32_t Grunt::ClientLink::CmdAuthLogonChallenge(CDataStore& msg) {
|
||||
SRP6_Random srpRandom(randomSeed, sizeof(randomSeed));
|
||||
|
||||
if (this->m_srpClient.CalculateProof(largeSafePrime, largeSafePrimeLen, generator, generatorLen, salt, 32, serverPublicKey, 32, srpRandom)) {
|
||||
this->SetState(2);
|
||||
this->SetState(STATE_CONNECTED);
|
||||
this->m_clientResponse->LogonResult(GRUNT_RESULT_5, nullptr, 0, 0);
|
||||
} else {
|
||||
this->SetState(4);
|
||||
this->SetState(STATE_CONNECT_VERSION);
|
||||
this->m_clientResponse->SetPinInfo(logonFlags & 0x1, pinGridSeed, pinSalt);
|
||||
// TODO
|
||||
// this->m_clientResponse->SetMatrixInfo(logonFlags & 0x2, matrixWidth, matrixHeight, matrixDigitCount, matrixDigitCount, 0, matrixChallengeCount, matrixSeed, this->m_srpClient.buf20, 40);
|
||||
@ -222,7 +222,7 @@ int32_t Grunt::ClientLink::CmdAuthLogonProof(CDataStore& msg) {
|
||||
}
|
||||
|
||||
if (result != 10) {
|
||||
this->SetState(2);
|
||||
this->SetState(STATE_CONNECTED);
|
||||
|
||||
// TODO range check on result
|
||||
|
||||
@ -249,7 +249,7 @@ int32_t Grunt::ClientLink::CmdAuthLogonProof(CDataStore& msg) {
|
||||
|
||||
if (msg.m_read <= msg.m_size) {
|
||||
if (this->m_srpClient.VerifyServerProof(static_cast<uint8_t*>(serverProof), 20)) {
|
||||
this->SetState(2);
|
||||
this->SetState(STATE_CONNECTED);
|
||||
this->m_clientResponse->LogonResult(Grunt::GRUNT_RESULT_11, nullptr, 0, 0);
|
||||
} else {
|
||||
this->m_accountFlags = accountFlags;
|
||||
@ -257,7 +257,7 @@ int32_t Grunt::ClientLink::CmdAuthLogonProof(CDataStore& msg) {
|
||||
// this->uint94 = 0;
|
||||
this->m_surveyID = surveyID;
|
||||
|
||||
this->SetState(6);
|
||||
this->SetState(STATE_AUTHENTICATED);
|
||||
this->m_clientResponse->LogonResult(Grunt::GRUNT_RESULT_0, this->m_srpClient.sessionKey, 40, logonFlags);
|
||||
}
|
||||
|
||||
@ -379,7 +379,7 @@ void Grunt::ClientLink::Connect(const char* a2) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->SetState(1);
|
||||
this->SetState(STATE_CONNECTING);
|
||||
|
||||
auto connectionMem = SMemAlloc(sizeof(WowConnection), __FILE__, __LINE__, 0x0);
|
||||
auto connection = new (connectionMem) WowConnection(this, nullptr);
|
||||
@ -406,7 +406,7 @@ void Grunt::ClientLink::Disconnect() {
|
||||
}
|
||||
|
||||
void Grunt::ClientLink::GetRealmList() {
|
||||
if (this->m_state != 6) {
|
||||
if (this->m_state != STATE_AUTHENTICATED) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -424,7 +424,7 @@ void Grunt::ClientLink::GetRealmList() {
|
||||
}
|
||||
|
||||
void Grunt::ClientLink::LogonNewSession(const Grunt::ClientLink::Logon& logon) {
|
||||
this->SetState(3);
|
||||
this->SetState(STATE_AUTH_CHALLENGE);
|
||||
|
||||
SStrCopy(this->m_accountName, logon.accountName, sizeof(this->m_accountName));
|
||||
SStrUpper(this->m_accountName);
|
||||
@ -489,7 +489,7 @@ void Grunt::ClientLink::ProveVersion(const uint8_t* versionChecksum) {
|
||||
// cdKeys.int0 = 0;
|
||||
// }
|
||||
|
||||
if (this->m_state == 4) {
|
||||
if (this->m_state == STATE_CONNECT_VERSION) {
|
||||
command.Put(static_cast<uint8_t>(CMD_AUTH_LOGON_PROOF));
|
||||
command.PutData(this->m_srpClient.clientPublicKey, sizeof(this->m_srpClient.clientPublicKey));
|
||||
command.PutData(this->m_srpClient.clientProof, sizeof(this->m_srpClient.clientProof));
|
||||
@ -530,7 +530,7 @@ void Grunt::ClientLink::Send(CDataStore& msg) {
|
||||
this->m_critSect.Leave();
|
||||
}
|
||||
|
||||
void Grunt::ClientLink::SetState(int32_t state) {
|
||||
void Grunt::ClientLink::SetState(STATE state) {
|
||||
this->m_critSect.Enter();
|
||||
|
||||
this->m_state = state;
|
||||
@ -545,7 +545,7 @@ void Grunt::ClientLink::WCCantConnect(WowConnection* conn, uint32_t timeStamp, N
|
||||
void Grunt::ClientLink::WCConnected(WowConnection* conn, WowConnection* inbound, uint32_t timeStamp, const NETCONNADDR* addr) {
|
||||
this->m_critSect.Enter();
|
||||
|
||||
this->SetState(2);
|
||||
this->SetState(STATE_CONNECTED);
|
||||
|
||||
int32_t connected = this->m_clientResponse->Connected(addr->peerAddr);
|
||||
|
||||
|
||||
@ -25,6 +25,16 @@ class Grunt::ClientLink : public WowConnectionResponse, Grunt::Pending, Grunt::T
|
||||
CMD_XFER_DATA = 49,
|
||||
};
|
||||
|
||||
enum STATE {
|
||||
STATE_NONE = 0,
|
||||
STATE_CONNECTING = 1,
|
||||
STATE_CONNECTED = 2,
|
||||
STATE_AUTH_CHALLENGE = 3,
|
||||
STATE_CONNECT_VERSION = 4,
|
||||
STATE_RECONNECT_VERSION = 5,
|
||||
STATE_AUTHENTICATED = 6
|
||||
};
|
||||
|
||||
struct Logon {
|
||||
const char* accountName;
|
||||
const char* password;
|
||||
@ -43,7 +53,7 @@ class Grunt::ClientLink : public WowConnectionResponse, Grunt::Pending, Grunt::T
|
||||
uint32_t m_accountFlags = 0x0;
|
||||
uint32_t m_surveyID = 0;
|
||||
uint32_t m_clientIP = 0;
|
||||
int32_t m_state;
|
||||
STATE m_state;
|
||||
SRP6_Client m_srpClient;
|
||||
SCritSect m_critSect;
|
||||
CDataStore m_datastore1B0;
|
||||
@ -75,7 +85,7 @@ class Grunt::ClientLink : public WowConnectionResponse, Grunt::Pending, Grunt::T
|
||||
void PackLogon(CDataStore& msg, const Logon& logon);
|
||||
void ProveVersion(const uint8_t* versionChecksum);
|
||||
void Send(CDataStore& msg);
|
||||
void SetState(int32_t state);
|
||||
void SetState(STATE state);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user