void ConsoleSocket::AuthCallback(bool result) { ConsoleAuthMgr::getSingleton().SetRequest(m_requestNo, NULL); m_requestNo = 0; if (!result) { m_pConsole->Write("Authentication failed.\r\n\r\n"); m_failedLogins++; if (m_failedLogins < 3) { m_pConsole->Write("login: "******"User `%s` authenticated.\r\n\r\n", m_username.c_str()); Log.Notice("RemoteConsole", "User `%s` authenticated.", m_username.c_str()); const char* argv[1]; HandleInfoCommand(m_pConsole, 1, argv); m_pConsole->Write("Type ? to see commands, quit to end session.\r\n"); m_state = STATE_LOGGED; } }
void ConsoleSocket::AuthCallback(bool result) { ConsoleAuthMgr::getSingleton().SetRequest(m_requestNo, NULL); m_requestNo = 0; if( !result ) { m_pConsole->Write("Authentication failed.\r\n\r\n"); Disconnect(); } else { m_pConsole->Write("Authentication passed.\r\n"); m_pConsole->Write("You are now logged in under user `%s`.\r\n\r\n", m_username.c_str()); const char * argv[1]; HandleInfoCommand(m_pConsole,1, argv); m_pConsole->Write("Type ? to see commands, quit to end session.\r\n"); m_state = STATE_LOGGED; } }
void ConsoleSocket::OnConnect() { m_pConsole->Write("Welcome to Hearthstone's Remote Administration Console.\r\n"); m_pConsole->Write("Please authenticate to continue.\r\n\r\n"); m_pConsole->Write("login: "); }
void ConsoleSocket::OnRecvData() { uint32 readlen = (uint32)GetReadBuffer()->GetSize(); uint32 rlen; char * p; if( ( readlen + m_pBufferPos ) >= m_pBufferLen ) { Disconnect(); return; } Read((uint8*)&m_pBuffer[m_pBufferPos], readlen); m_pBufferPos += readlen; // let's look for any newline bytes. p = strchr(m_pBuffer, '\n'); while( p != NULL ) { // windows is stupid. :P rlen = (uint32)((p+1) - m_pBuffer); if( *(p-1) == '\r' ) *(p-1) = '\0'; *p = '\0'; // handle the command if( *m_pBuffer != '\0' ) { switch(m_state) { case STATE_USER: m_username = string(m_pBuffer); m_pConsole->Write("password: "******"\r\nAttempting to authenticate. Please wait.\r\n"); m_state = STATE_WAITING; m_requestNo = ConsoleAuthMgr::getSingleton().GenerateRequestId(); ConsoleAuthMgr::getSingleton().SetRequest(m_requestNo, this); TestConsoleLogin(m_username, m_password, m_requestNo); break; case STATE_LOGGED: if( !strnicmp( m_pBuffer, "quit", 4 ) ) { Disconnect(); break; } HandleConsoleInput(m_pConsole, m_pBuffer); break; } } // move the bytes back if( rlen == m_pBufferPos ) { m_pBuffer[0] = '\0'; m_pBufferPos = 0; } else { memcpy(m_pBuffer, &m_pBuffer[rlen], m_pBufferPos - rlen); m_pBufferPos -= rlen; } p = strchr(m_pBuffer, '\n'); } }