#include "stdafx.h" #include "Query_Auth.h" #include "AuthFrame.h" #include "WZ_MD5.h" #include "QueryManager.h" #include "AlertRequestSender.h" #include "AccountManager.h" #include "ServerDataManager.h" #include "AuthAgentServerSession.h" #include "LoginFrontServerSession.h" #include #include #include #include "ReAuthInfo.h" #ifdef _KR_0_20120207_CRYPT_SHA256 #include "../ProgramCommon/SHA256.h" #endif #if defined(_JP_0_20100723_GAMECHU_AUTHFLOW_) || defined(__CN_20100909_SECURITY_TOKEN__ ) || defined(_NA_20100307_BETAKEY_SYSTEM) #include #endif extern TCHAR g_LoginErrorString[AUTHRESULT_MAX][MAX_AUTHRESULT_MESSAGE_LEN + 1]; #ifdef _CHANNELING_AUTH_FLOW BOOST_STATIC_ASSERT(sizeof(MSG_CF_AUTH_TOKEN_PASS_SYN::Stream) > sizeof(DB_LOGIN_USER::AuthToken) && sizeof(DB_LOGIN_USER::AuthToken) == sizeof(wchar_t) * (36 + 1)); BOOST_STATIC_ASSERT(AuthStepAuthToken::DB_AuthToken_Length == DB_LOGIN_USER::DB_AuthToken_Length && sizeof(AuthStepAuthToken::AuthTokenStreamTimeout) == sizeof(DB_LOGIN_USER::AuthToken)); #endif //_CHANNELING_AUTH_FLOW QueryAuth::QueryAuth() : QueryObject(QUERYTYPE_LOGINUSER) , m_TokenType(eAuthToken_None) , m_front_user_id(0) { //Sts3绰 吝惫俊辑父 角疙 牢刘 侥喊侩档肺 静烙(0 : 厚角疙 , 1 : 角疙) m_recordSet.RegisterVariable(&m_Record.UserGuid, "UserGuid"); m_recordSet.RegisterVariable(m_Record.PassWD, "PassWD"); m_recordSet.RegisterVariable(&m_Record.Sts[0], "Sts"); m_recordSet.RegisterVariable(&m_Record.Sts[1], "Sts2"); m_recordSet.RegisterVariable(&m_Record.Sts[2], "Sts3"); m_recordSet.RegisterVariable(m_Record.CharPassWD, "CharPassWD"); m_recordSet.RegisterVariable(&m_Record.Age, "Age"); m_recordSet.RegisterVariable(&m_Record.IpGuid, "IpGuid"); #ifdef _SECURE_AUTH m_recordSet.RegisterVariable(&m_Record.pData, "CardNo"); #endif m_recordSet.RegisterVariable(&m_Record.btAuthFailCount, "AuthFailCount"); #ifdef _AUTH_MATRIX_FAIL_COUNT m_recordSet.RegisterVariable(&m_Record.btShapeAuthFailCount, "ShapeAuthFailCount"); m_recordSet.RegisterVariable(&m_Record.btMatrixAuthFailCount, "MatrixAuthFailCount"); #endif #ifdef _NA_20100307_BETAKEY_SYSTEM #endif #ifdef _CHANNELING_AUTH_FLOW // m_recordSet.RegisterVariable(&m_Record.auth_token_result, "AuthKey"); #endif #ifdef _CHANNELING_AUTH_FLOW_HANGAME_USER_ // m_recordSet.RegisterVariable(&m_Record.userType, "UserType"); #endif #ifdef _JP_0_20100723_GAMECHU_AUTHFLOW_ m_recordSet.RegisterVariable(m_Record.user_account, "UserID"); #endif #ifdef __CN_20100909_SECURITY_TOKEN__ m_recordSet.RegisterVariable(&m_Record.is_token_use_, "is_token_auth"); m_recordSet.RegisterVariable(m_Record.token_base64_key_, "base64string"); #endif m_recordSet.RegisterVariable(m_Record.Login_PassWD, "Login_PassWD"); //修改密码验证为明文密码验证 by:十里坡剑神 2021-06-08 m_recordSet.RegisterParameter(&m_DbResult, "", adInteger, adParamReturnValue, sizeof(int), ""); } void QueryAuth::Configuration(eAuthToken token_type) { #ifdef _JP_0_20100723_GAMECHU_AUTHFLOW_ gamechu_usn_ = 0; #endif m_key = 0; m_TokenType = token_type; m_ReAuthKey = 0; m_front_user_id = 0; m_DbResult = eQueryResult_Undefined; ZeroMemory(&m_Record, sizeof(m_Record)); ZeroMemory(&m_account, sizeof(m_account)); ZeroMemory(&m_password, sizeof(m_password)); ZeroMemory(&m_clientIp, sizeof(m_clientIp)); ZeroMemory(&m_localIp, sizeof(m_localIp)); ZeroMemory(&m_AuthToken, sizeof(m_AuthToken)); } BOOLEAN QueryAuth::ValidClientAuthInfo() { BOOLEAN is_matched = FALSE; if (m_TokenType == eAuthToken_None) { is_matched = CheckPassword(); } else if (m_TokenType == eAuthToken_AuthTokenKorea) { // DB_LOGIN_USER::DB_AuthToken_Length ==> hard-code value (DB AuthToken 32Byte) BOOST_STATIC_ASSERT(sizeof(m_AuthToken) == sizeof(m_Record.auth_token_result) && sizeof(m_AuthToken) == _countof(m_AuthToken) * sizeof(wchar_t)); BOOLEAN is_null = memcmp(AuthStepAuthToken::AuthTokenStreamNull, m_Record.auth_token_result, sizeof(m_Record.auth_token_result)) == 0; BOOLEAN is_timeout = TRUE; if (is_null == FALSE) { // "00000000-0000-0000-0000-000000000000" timeout stream is_timeout = memcmp(AuthStepAuthToken::AuthTokenStreamTimeout, m_Record.auth_token_result, sizeof(m_Record.auth_token_result)) == 0; } ////////////////////////////////////////////////////////////////////////// // current step status table // isNull | is_timeout // 0 0 - O (compare client auth_token) // 0 1 - Timeout // 1 0 - X // 1 1 - Already Queried | Server Selecting Client ////////////////////////////////////////////////////////////////////////// if (is_timeout == FALSE) { is_matched = memcmp(m_AuthToken, m_Record.auth_token_result, sizeof(m_Record.auth_token_result)) == 0; } else { ////////////////////////////////////////////////////////////////////////// // if server selecting client? // F: already queried client (irregular) // T: compare 're-authentication token stream' with 'client auth token' ////////////////////////////////////////////////////////////////////////// is_matched = ReauthTokenAuthentication(); if (is_matched == FALSE) { SUNLOG(eCRITICAL_LOG, "["__FUNCTION__"] 重新身份验证令牌身份验证失败 [账号:%s]", this->m_account); } } SUNLOG(eCRITICAL_LOG, "["__FUNCTION__"] [账号是否匹配:%d][查询是否成功:%d][是否超时:%d] [账号:%s]", is_matched, is_null, is_timeout, this->m_account); } #ifdef __NA000000_NORTH_AMERICA_HANGAME_CHANNELING__ else if (m_TokenType == eAuthToken_AuthTokenNorthA) { BOOST_STATIC_WARNING(0); is_matched = true; //#define __WAVERIX_DEBUG_CODE__ #ifdef __WAVERIX_DEBUG_CODE__ BYTE tokenStream[128]; char outputMsg[1024]; int iWritten = 0; ////////////////////////////////////////////////////////////////////////// SUNLOG(eCRITICAL_LOG, "ID: {%s} AuthToken DBStream", m_account); BOOST_STATIC_ASSERT(sizeof(tokenStream) >= sizeof(m_Record.auth_token_result)); CopyMemory(tokenStream, &m_Record.auth_token_result, sizeof(m_Record.auth_token_result)); iWritten = 0; for(int i = 0; i < sizeof(m_Record.auth_token_result); ++i) iWritten += _snprintf(&outputMsg[iWritten], _countof(outputMsg) - iWritten, "[%02X]", tokenStream[i]); SUNLOG(eCRITICAL_LOG, outputMsg); ////////////////////////////////////////////////////////////////////////// SUNLOG(eCRITICAL_LOG, "ID: {%s} AuthToken UserStream", m_account); BOOST_STATIC_ASSERT(sizeof(tokenStream) >= sizeof(m_AuthToken)); CopyMemory(tokenStream, &m_AuthToken, sizeof(m_AuthToken)); iWritten = 0; for(int i = 0; i < sizeof(m_AuthToken); ++i) iWritten += _snprintf(&outputMsg[iWritten], _countof(outputMsg) - iWritten, "[%02X]", tokenStream[i]); SUNLOG(eCRITICAL_LOG, outputMsg); ////////////////////////////////////////////////////////////////////////// #endif } #endif #ifdef _JP_0_20100723_GAMECHU_AUTHFLOW_ else if(m_TokenType == eAuthToken_AuthTokenGameChu) { is_matched = true; } #endif #ifdef _RU_INGAMBA_AUTH_PROCESS else if(m_TokenType == eAuthToken_AuthIngamba) { is_matched = true; } #endif #ifdef _CN_ZY_AUTH_PROCESS else if (m_TokenType == eAuthToken_AuthChinaZY) { #ifdef _CN_ZY_AUTH_PROCESS_DBAUTH is_matched = true; #else is_matched = CheckPassword(); #endif //_CN_ZY_AUTH_PROCESS_DBAUTH } #endif //_CN_ZY_AUTH_PROCESS return is_matched; } //#endif //_CHANNELING_AUTH_FLOW BOOLEAN QueryAuth::ReauthTokenAuthentication() { BOOLEAN is_matched = false; #ifdef __NA001334_090420_SERVER_SELECT_FACILITY__ if(m_ReAuthKey != 0) { ReAuthManager* pReAuthManager = ReAuthManager::Instance(); const ReAuthInfo* pReAuthInfo = pReAuthManager->FindReAuthInfo(m_ReAuthKey); if(pReAuthInfo != 0) { // 捞固 m_ReAuthKey啊 且寸登绰 矫痢 八刘等 蔼烙. pReAuthManager->OnAcceptQueryLoginUser(pReAuthInfo); is_matched = true; } } #endif return is_matched; } BOOLEAN QueryAuth::CheckPassword() { //修改密码验证为明文密码验证 by:十里坡剑神 2021-06-08 //wchar_t password_widen[32] = { 0, }; //wchar_t key_widen[32] = { 0, }; char* password = m_password; char dbPassword[kCryptStringSize]={0}; ::WideCharToMultiByte(CP_ACP, 0, m_Record.Login_PassWD, -1, dbPassword, kCryptStringSize, 0, 0); //int password_len = int(strlen(m_password)); //MultiByteToWideChar(CP_ACP, 0, // password, password_len + 1, // password_widen, _countof(password_widen)); //char* key = m_account; //int key_len = int(strlen(m_account)); //MultiByteToWideChar(CP_ACP, 0, // key, key_len + 1, // key_widen, _countof(key_widen)); bool is_matched = false; //#ifdef _KR_0_20120207_CRYPT_SHA256 // int mode = AuthFrame::Instance()->GetMode(); // switch (mode) // { // case eSERVER_DEV: // { // is_matched = !!MD5::Compare((BYTE*)password_widen, int(wcslen(password_widen) * sizeof(wchar_t)), // (BYTE*)m_Record.PassWD, // digest[16] // (BYTE*)key_widen, int(wcslen(key_widen) * sizeof(wchar_t))); // } // break; // case eSERVER_INTRAOFFICE: // case eSERVER_LIVE: // case eSERVER_TESTLIVE: // { // Crypt::SHA256 sha256; // is_matched = sha256.Compare(password, (const char*)m_account, m_Record.PassWD); // if (is_matched == false && strlen(sha256.GetLastError()) != 0) // SUNLOG(eCRITICAL_LOG, "[SHA256]Account FAIL : %s", sha256.GetLastError()); // } // break; // default: // is_matched = false; // break; // } //#else is_matched = (strcmp(password,dbPassword)==0); //!!MD5::Compare((BYTE*)password_widen, int(wcslen(password_widen) * sizeof(wchar_t)), // (BYTE*)m_Record.Login_PassWD, // digest[16] // (BYTE*)key_widen, int(wcslen(key_widen) * sizeof(wchar_t))); //#endif #ifdef __NA001334_090420_SERVER_SELECT_FACILITY__ if(is_matched == 0 && m_ReAuthKey != 0) { ReAuthManager* pReAuthManager = ReAuthManager::Instance(); const ReAuthInfo* pReAuthInfo = pReAuthManager->FindReAuthInfo(m_ReAuthKey); if(pReAuthInfo != 0) { // 捞固 m_ReAuthKey啊 且寸登绰 矫痢 八刘等 蔼烙. pReAuthManager->OnAcceptQueryLoginUser(pReAuthInfo); is_matched = true; } } #endif return is_matched; } /* BOOLEAN QueryAuth::CheckPassword(LPTSTR key, LPTSTR password, LPTSTR recvPasswd) { WCHAR wszPasswd[32] = {0, }; WCHAR wszKey[32] = {0, }; ::ZeroMemory(wszPasswd, 32); ::MultiByteToWideChar(CP_ACP, 0, recvPasswd, (int)strlen(recvPasswd) + 1, wszPasswd, (int)sizeof(wszPasswd) / 2); ::ZeroMemory(wszKey, 32); ::MultiByteToWideChar(CP_ACP, 0, key, (int)strlen(key) + 1, wszKey, (int)sizeof(wszKey) / 2); if(MD5::Compare((BYTE*)wszPasswd, (int)strlen(recvPasswd) * 2, (BYTE*)password, (BYTE*)wszKey, (int)strlen(key) * 2)) { return TRUE; } return FALSE; } */ AccountInfo* QueryAuth::CheckOverlapLogin(DWORD user_guid, LPTSTR account, DWORD login_front_id, DWORD front_user_id, BYTE& result_value) { AuthFrame* const auth_frame = AuthFrame::Instance(); AccountManager* const account_manager = AccountManager::Instance(); LoginFrontServerSession* login_front = (LoginFrontServerSession*)auth_frame->FindSession(login_front_id); // 捞傈 立加磊啊 乐促搁, 弊 沥焊甫 掘绢柯促. AccountInfo* prev_account_info = NULL; AccountInfo* current_account_info = account_manager->CreateAccountInfo(account, &prev_account_info); // 捞傈 立加磊啊 绝栏搁 己傍! if (prev_account_info == NULL) { current_account_info->m_LoginFrontId = login_front_id; current_account_info->m_LoginFrontUserId = front_user_id; current_account_info->m_locationId = 0; current_account_info->m_userGuid = user_guid; return current_account_info; } if(prev_account_info->m_locationId == NULL) { // 泅犁 牢刘吝牢 拌沥捞 粮犁(辑滚甫 急琶窍瘤 臼篮 惑炔) result_value = AUTHRESULT_PROCESSLOGIN; SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 账号 : %s, 上一次登录验证状态 : %u", prev_account_info->m_account, prev_account_info->m_status ); } else { // 泅犁 立加吝牢 拌沥捞 粮犁(辑滚甫 急琶茄 惑炔) result_value = AUTHRESULT_ALREADYLOGIN; SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 账号 : %s, 上一次登录验证状态 : %u, 代理服务端连接编号 : %u", prev_account_info->m_account, prev_account_info->m_status, prev_account_info->m_locationId ); AuthAgentServerSession* auth_agent_server = ServerDataManager::Instance()->FindAuthAgentServerSession(prev_account_info->m_locationId); if (auth_agent_server) { // 捞傈 立加磊 碍力辆丰 夸没 MSG_SA_AUTH_ASK_PC_LOGOUT_SYN logout_msg; logout_msg.m_dwAuthUserID = prev_account_info->m_authKey; logout_msg.m_GameAgentID = prev_account_info->m_locationId; logout_msg.m_dwUserGUID = prev_account_info->m_userGuid; CHECK_ID_LENGTH_BUFFER(logout_msg.m_szID); CHECK_ID_LENGTH_BUFFER(prev_account_info->m_account); ::_tcsncpy(logout_msg.m_szID, prev_account_info->m_account, _countof(logout_msg.m_szID)); logout_msg.m_szID[_countof(logout_msg.m_szID) - 1] = '\0'; logout_msg.m_dwLogoutCode = eDRC_OVERLAPPEDCONN; auth_agent_server->SendPacket(&logout_msg, sizeof(logout_msg)); } else { account_manager->ClearInfo(prev_account_info->m_account); } } return NULL; } VOID QueryAuth::onResult() { QueryObject::onResult(); AuthFrame* const auth_frame = AuthFrame::Instance(); QueryManager* const query_manager = QueryManager::Instance(); LoginFrontServerSession* login_front = static_cast(auth_frame->FindSession(m_key)); if (login_front == NULL) { SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 未找到登录门户,连接编号 : %u", m_key ); return; } MSG_SF_AUTH_ID_PASSWORD_CHECK_ACK ack_msg; ack_msg.m_dwFrontUserID = m_front_user_id; ack_msg.m_byFailCount = 0; ack_msg.m_byResult = AUTHRESULT_OK; #ifdef __CN_20100909_SECURITY_TOKEN__ ack_msg.m_Is_Token_Use = m_Record.is_token_use_; #endif // - eQueryResult_Undefined = -1, Impossible // - eQueryResult_Success = 0, Query Successed // - eQueryResult_Fail = 1, can't find user, 扁粮 老馆 俊矾. if (m_DbResult != eQueryResult_Success && m_DbResult != eQueryResult_Fail) { #ifdef _JP_0_20100723_GAMECHU_AUTHFLOW_ if(m_TokenType == eAuthToken_AuthTokenGameChu) { SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 数据库查询结果 : %d, 账号 : %u", m_DbResult, gamechu_usn_ ); } else { #endif SUNLOG( eCRITICAL_LOG, __FUNCTION__ " : 数据库查询结果 : %d - 账号 : %s", m_DbResult, m_account ); #ifdef _JP_0_20100723_GAMECHU_AUTHFLOW_ } #endif } if(m_DbResult==eQueryResult_MaxLoginCount) {// 超过最大连接数 by:十里坡剑神 2021-06-28 SUNLOG( eCRITICAL_LOG, __FUNCTION__ " : 超过最大连接数 :账号 : %s IP=%s", m_account, m_clientIp ); ack_msg.m_byResult = AUTHRESULT_MAXLOGINCOUNT; goto ERROR_RESULT; } if (m_recordSet.GetRecordCount() == 0) { ack_msg.m_byResult = AUTHRESULT_INVALIDACCOUNT; #ifdef _JP_0_20100723_GAMECHU_AUTHFLOW_ if(m_TokenType == eAuthToken_AuthTokenGameChu) { SUNLOG( eCRITICAL_LOG, __FUNCTION__" : doesn't exist in DB : GameChu USN : %u", gamechu_usn_ ); } else { #endif SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 未查询到对应账号信息 : 账号 : %s", m_account ); #ifdef _JP_0_20100723_GAMECHU_AUTHFLOW_ } #endif goto ERROR_RESULT; } #ifdef _JP_0_20100723_GAMECHU_AUTHFLOW_ if (m_TokenType == eAuthToken_AuthTokenGameChu) { USES_CONVERSION; ::_tcsncpy(m_account, W2A(m_Record.user_account), _countof(m_account)); m_account[_countof(m_account) - 1] = '\0'; _strupr(m_account); ::_tcsncpy(ack_msg.m_szID, m_account , _countof(m_account)); ack_msg.m_szID[_countof(ack_msg.m_szID) - 1] = '\0'; } #endif if (auth_frame->IsAllowSts((USER_STS)m_Record.Sts[0]) == false) { ack_msg.m_byResult = AUTHRESULT_NOTALLOWEDACCOUNT; SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 不允许登录 : 账号: %s, 状态 : %u", m_account, m_Record.Sts[0] ); goto ERROR_RESULT; } #ifdef _RESTRICT_ADULT if (m_Record.Age < 18) { ack_msg.m_byResult = AUTHRESULT_RESTRICTADULT; SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 不允许登录 : 账号: %s, 年龄 : %u", m_account, m_Record.Age ); goto ERROR_RESULT; } #endif const DWORD limit_block_count = auth_frame->GetBlockLimit(); if (m_Record.btAuthFailCount >= limit_block_count) { ack_msg.m_byResult = AUTHRESULT_ACCOUNT_BLOCK; SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 账号锁定 : 账号: %s, 登录失败次数 : %u", m_account, m_Record.btAuthFailCount ); goto ERROR_RESULT; } //鞠龋 八荤 BOOLEAN is_valid_client = ValidClientAuthInfo(); if (is_valid_client == FALSE) { #ifdef _AUTH_CHINA ack_msg.m_byResult = AUTHRESULT_INVALIDACCOUNT; SUNLOG( eCRITICAL_LOG, __FUNCTION__ " : Invalid password : Account : %s", m_account ); goto ERROR_RESULT; #else //DB俊 楷加 坷幅 冉荐甫 刘啊矫挪 饶 ACK甫 焊辰促. query_manager->QueryUpdateAuthFailCount(m_account, m_clientIp, 0, m_front_user_id, m_key, ACCOUNT_AUTH); return; #endif } #if !defined(_SECURE_AUTH) && !defined(_AUTH_CHINA) // 牢刘 己傍 饶浚 楷加坷幅雀荐甫 檬扁拳 query_manager->QueryUpdateAuthFailCount(m_account, m_clientIp, 1, m_front_user_id, m_key, ACCOUNT_AUTH); #endif AccountInfo* account_info = CheckOverlapLogin(m_Record.UserGuid, m_account, m_key, m_front_user_id, ack_msg.m_byResult); if (account_info == NULL) { goto ERROR_RESULT; } else { #ifdef _JP_0_20100723_GAMECHU_AUTHFLOW_ account_info->gamechu_usn_ = gamechu_usn_; #endif//_JP_0_20100723_GAMECHU_AUTHFLOW_ #ifdef __CN_20100909_SECURITY_TOKEN__ account_info->is_token_use_ = m_Record.is_token_use_; if (m_Record.is_token_use_) { USES_CONVERSION; ::_tcsncpy(account_info->token_base64_key_, W2A(m_Record.token_base64_key_), _countof(account_info->token_base64_key_)); account_info->token_base64_key_[_countof(account_info->token_base64_key_) - 1] = '\0'; } #endif//__CN_20100909_SECURITY_TOKEN__ #ifdef _NA_20100307_BETAKEY_SYSTEM account_info->betakey_ = ack_msg.m_betakey_ = 0; #endif//_NA_20100307_BETAKEY_SYSTEM BOOST_STATIC_ASSERT(_countof(account_info->m_userCode) == _countof(m_Record.Sts)); for (int i = 0; i < _countof(account_info->m_userCode); ++i) { account_info->m_userCode[i] = static_cast(m_Record.Sts[i]); } account_info->m_LoginFrontId = m_key; account_info->m_userGuid = m_Record.UserGuid; account_info->m_age = static_cast(m_Record.Age); account_info->m_pcBangId = m_Record.IpGuid; ::_tcsncpy(account_info->m_clientIp, m_clientIp, IP_MAX_LEN); ::_tcsncpy(account_info->m_localIp, m_localIp, IP_MAX_LEN); #ifdef __PCBANG_IP_UPDATE account_info->pc_room_ip_value_ = ::inet_addr(account_info->m_clientIp); #endif//__PCBANG_IP_UPDATE BOOST_STATIC_ASSERT( sizeof(account_info->m_MD5) == sizeof(m_Record.CharPassWD) ); ::memcpy(account_info->m_MD5, m_Record.CharPassWD, sizeof(account_info->m_MD5)); account_info->m_AuthUserType = static_cast(m_Record.userType); #if defined(_SECURE_AUTH) //概飘腐胶 牢刘 if (m_Record.pData[0] != '\0') { //概飘腐胶 墨靛 荤侩磊老 版快 auth_frame->SendMatrixCardAuth(login_front, account_info, m_front_user_id, m_Record.btMatrixAuthFailCount, 1); } else { //酒聪搁 弊成 己傍 ack_msg.m_byResult = AUTHRESULT_OK; ::_tcsncpy(ack_msg.m_szInfo, g_LoginErrorString[ack_msg.m_byResult], _countof(ack_msg.m_szInfo)); login_front->SendPacket(&ack_msg, sizeof(ack_msg)); account_info->m_status = ACCOUNTSTATUS_AUTH; } #else//_SECURE_AUTH //拌沥 牢刘父 荤侩 #ifdef _NET_CAFE account_info->m_pcBangId = 0; // 老夯 齿墨其狼 版快 DB俊辑 绊蜡锅龋甫 逞败霖促 #ifdef _JP_0_20100723_GAMECHU_AUTHFLOW_ eNetCafeLoginType token_type; token_type = (m_TokenType == eAuthToken_AuthTokenGameChu) ? NETCAFE_GAMECHU_LOGIN : NETCAFE_ONTIME_LOGIN; query_manager->QueryNetCafeLogInsert(m_key, m_front_user_id, m_account, m_clientIp, token_type, m_ReAuthKey); #else query_manager->QueryNetCafeLogInsert(m_key, m_front_user_id, m_account, m_clientIp, true, m_ReAuthKey); #endif #else//_NET_CAFE //吝惫,老夯,臂肺国阑 力寇茄 促弗 滚傈甸篮 捞镑俊辑 弥辆 牢刘 己傍 ack_msg.m_byResult = AUTHRESULT_OK; ::_tcsncpy(ack_msg.m_szInfo, g_LoginErrorString[ack_msg.m_byResult], _countof(ack_msg.m_szInfo)); login_front->SendPacket(&ack_msg, sizeof(ack_msg)); account_info->m_status = ACCOUNTSTATUS_AUTH; #endif//_NET_CAFE #endif//_SECURE_AUTH #ifdef _TIRED_CHECK account_info->m_ucRealNameAuth = m_Record.Sts[2]; // 角疙 牢刘磊 牢瘤 侥喊 #endif #ifdef _SECURE_AUTH if (m_Record.pData[0] != '\0') { // 概飘腐胶 墨靛 荤侩磊老 版快 char szSeedValue[(SEED_SIZE * 2) + 1] = { 0, }; wchar_t* wszSCValue = (wchar_t*)m_Record.pData; ::WideCharToMultiByte(CP_ACP, 0, wszSCValue, -1, szSeedValue, SEED_SIZE * 2, 0, 0); // 墨靛锅龋甫 啊瘤绊 矫靛蔼阑 父电促 genseed(szSeedValue, account_info->m_seedValue); account_info->m_bSucceedShape = true; SUNLOG( eFULL_LOG, __FUNCTION__" : 数据库游标值 : %s", szSeedValue ); } #endif account_info->m_tickConnectTime = ::GetTickCount(); ::GetLocalTime(&account_info->m_loginTime); } SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 登录验证成功 : 账号 : %s, ip : %s", account_info->m_account, account_info->m_clientIp ); return; ERROR_RESULT: query_manager->UpdateIPCount(m_clientIp); ::_tcsncpy(ack_msg.m_szInfo, g_LoginErrorString[ack_msg.m_byResult], _countof(ack_msg.m_szInfo)); login_front->SendPacket(&ack_msg, sizeof(ack_msg)); } VOID QueryRecoverLocation::onResult() { QueryObject::onResult(); TCHAR temp_account_id[ID_MAX_LEN + 1]; int count = 0; AccountManager* const account_manager = AccountManager::Instance(); ServerDataManager* const server_data_manager = ServerDataManager::Instance(); AccountInfo* account_info = NULL; AccountInfo* temp_account_info = NULL; // 汗备累诀阑 矫累茄促. // SET NOCOUNT 甫 荤侩窍绰 procedure捞骨肺 GetRecordCount甫 荤侩且 荐 绝促. while (m_recordSet.IsEndRecord() == false) { CHECK_ID_LENGTH_BUFFER(temp_account_id); ZeroMemory(temp_account_id, sizeof(temp_account_id)); // (WAVERIX) (090331) UserID 窍靛内爹 蔼 荐沥 ::WideCharToMultiByte(CP_ACP, 0, m_Record.UserID, -1, temp_account_id, ID_MAX_LEN, 0, 0); account_info = account_manager->CreateAccountInfo(temp_account_id, &temp_account_info); if (account_info != NULL) { ServerData* server_data = server_data_manager->FindServerData((AGENTID)m_Record.ServerGuid); if (server_data == NULL) { SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 未查询到对应服务 : 账号ID : %s, 服务ID : %u", temp_account_id, m_Record.ServerGuid ); m_recordSet.Next(); continue; } short status_type = (m_Record.ConnectSts == USERSTATUS_PLAY ? ACCOUNTSTATUS_PLAY : 0); account_info->m_status = static_cast(status_type); account_info->m_userGuid = m_Record.UserGuid; account_info->m_locationId = server_data->GetGameAgentID(); account_info->m_tickBillingTime = ::GetTickCount(); account_info->m_pcBangId = m_Record.CompGuid; ::WideCharToMultiByte(CP_ACP, 0, m_Record.IpPublicAddr, -1, account_info->m_clientIp, 15, 0, 0); ::WideCharToMultiByte(CP_ACP, 0, m_Record.IpLocalAddr, -1, account_info->m_localIp, 15, 0, 0); ::WideCharToMultiByte(CP_ACP, 0, m_Record.AuthUserGuid, -1, account_info->m_glogKey, 8, 0, 0); account_info->m_authKey = m_Record.AuthKey; account_info->m_tickConnectTime = account_info->m_tickBillingTime; SYSTEMTIME login_time; VariantTimeToSystemTime(static_cast(m_Record.ConnectTime), &login_time); account_info->m_loginTime = login_time; ++count; // location Id绰 1何磐 矫累茄促. server_data->IncLoginUserCount(); } m_recordSet.Next(); } if(account_info&&strlen(account_info->m_clientIp)>0) { QueryManager* const query_manager = QueryManager::Instance(); query_manager->UpdateIPCount(account_info->m_clientIp); } #if !defined(__NA000000_GLOBAL_AUTH_PROCESS__) // (WAVERIX) (NOTE) 臂肺国 牢刘辑滚绰 秦寸 孽府甫 荤侩窍瘤 臼绰促. 内靛甫 阜绰 捞蜡绰 // ReadyState俊 狼秦 listen沥氓捞 沥秦瘤扁 锭巩 AuthFrame::Instance()->GetReadyState().SetReadyState(AUTH_READY_RECOVER_STS, TRUE); #endif SUNLOG(eCRITICAL_LOG, "[QueryRecoverLocation::onResult] Recover Count[%d]", count); } VOID QueryAuthFailCount::onResult() { QueryObject::onResult(); if(m_btFlag) { return; } QueryManager* const query_manager = QueryManager::Instance(); query_manager->UpdateIPCount(m_clientIP); // 牢刘 角菩俊 措茄 贸府甫 茄促. MSG_SF_AUTH_ID_PASSWORD_CHECK_ACK ack_msg; ack_msg.m_dwFrontUserID = m_front_user_id; ack_msg.m_byFailCount = 0; ack_msg.m_byResult = AUTHRESULT_OK; AuthFrame* const auth_frame = AuthFrame::Instance(); LoginFrontServerSession* login_front = static_cast(auth_frame->FindSession(m_key)); if (login_front == NULL) { SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 未查询到登录验证前端: %u", m_key ); return; } AccountInfo* account_info = AccountManager::Instance()->FindWithLoginFrontUserID(m_front_user_id); // 穿利 坷幅 冉荐 力茄俊 吧妨 拌沥 喉废 if (m_btAuthFailCount >= auth_frame->GetBlockLimit()) { if(account_info) { #ifdef _SECURE_AUTH account_info->m_bSucceedShape = false; #endif } ack_msg.m_byResult = AUTHRESULT_ACCOUNT_BLOCK; SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 账号锁定 : 账号 : %s, 失败次数 : %u", m_account, m_btAuthFailCount ); goto ERROR_RESULT; } switch(m_btAuthType) { case ACCOUNT_AUTH: { ack_msg.m_byResult = AUTHRESULT_INVALIDACCOUNT; ack_msg.m_byFailCount = static_cast(m_btAuthFailCount); SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 密码无效 : 账号 : %s", m_account ); goto ERROR_RESULT; } break; #ifdef _SECURE_AUTH case MATRIX_CARD_AUTH: { auth_frame->SendMatrixCardAuth(login_front, account_info, m_front_user_id, 0, 0); return; } break; #endif default: { SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 验证类型无效 : %u", m_btAuthType ); } break; } return; ERROR_RESULT: ::_tcsncpy(ack_msg.m_szInfo, g_LoginErrorString[ack_msg.m_byResult], _countof(ack_msg.m_szInfo)); login_front->SendPacket(&ack_msg, sizeof(ack_msg)); } QueryCheckPassword::QueryCheckPassword() : QueryObject(QUERYTYPE_CHECK_PASSWORD) { memset(m_account, 0, sizeof(m_account)); memset(m_password, 0, sizeof(m_password)); m_front_user_id = 0; m_recordSet.RegisterParameter(&m_DbResult, "", adInteger, adParamReturnValue, sizeof(int), ""); } VOID QueryCheckPassword::onResult() { QueryObject::onResult(); AuthFrame* const auth_frame = AuthFrame::Instance(); QueryManager* const query_manager = QueryManager::Instance(); LoginFrontServerSession* login_front = static_cast(auth_frame->FindSession(m_key)); if (login_front == NULL) { SUNLOG( eCRITICAL_LOG, __FUNCTION__" : 未查询到登录验证前端 : %u", m_key ); return; } if (m_DbResult == 0) // success { #ifdef _CN_ZY_AUTH_PROCESS_DBAUTH query_manager->QueryLoginUserByChinaZY( \ m_key/*login_front_id*/, m_account, NULL/*password*/, \ m_front_user_id, m_ReAuthKey, m_clientIp, m_localIp); #endif //_CN_ZY_AUTH_PROCESS_DBAUTH } else { MSG_SF_AUTH_ID_PASSWORD_CHECK_ACK ack_msg; ack_msg.m_dwFrontUserID = m_front_user_id; ack_msg.m_byFailCount = 0; ack_msg.m_byResult = AUTHRESULT_INVALIDACCOUNT; login_front->SendPacket(&ack_msg, sizeof(ack_msg)); } }