本文整理汇总了C++中GetRemoteAddress函数的典型用法代码示例。如果您正苦于以下问题:C++ GetRemoteAddress函数的具体用法?C++ GetRemoteAddress怎么用?C++ GetRemoteAddress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetRemoteAddress函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ACE_ASSERT
int WorldSocket::ProcessIncoming(WorldPacket* new_pct)
{
ACE_ASSERT (new_pct);
// manage memory ;)
ACE_Auto_Ptr<WorldPacket> aptr (new_pct);
const ACE_UINT16 opcode = new_pct->GetOpcode();
if (closing_)
return -1;
// Dump received packet.
if (sPacketLog->CanLogPacket())
sPacketLog->LogPacket(*new_pct, CLIENT_TO_SERVER);
try
{
switch (opcode)
{
case CMSG_PING:
return HandlePing (*new_pct);
case CMSG_AUTH_SESSION:
if (m_Session)
{
sLog->outError("WorldSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again");
return -1;
}
sScriptMgr->OnPacketReceive(this, WorldPacket(*new_pct));
return HandleAuthSession(*new_pct);
case CMSG_KEEP_ALIVE:
sLog->outStaticDebug ("CMSG_KEEP_ALIVE, size: " UI64FMTD, uint64(new_pct->size()));
sScriptMgr->OnPacketReceive(this, WorldPacket(*new_pct));
return 0;
default:
{
ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1);
if (m_Session != NULL)
{
// Our Idle timer will reset on any non PING opcodes.
// Catches people idling on the login screen and any lingering ingame connections.
m_Session->ResetTimeOutTime();
// OK, give the packet to WorldSession
aptr.release();
// WARNINIG here we call it with locks held.
// Its possible to cause deadlock if QueuePacket calls back
m_Session->QueuePacket (new_pct);
return 0;
}
else
{
sLog->outError("WorldSocket::ProcessIncoming: Client not authed opcode = %u", uint32(opcode));
return -1;
}
}
}
}
catch (ByteBufferException &)
{
sLog->outError("WorldSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i. Disconnected client.",
opcode, GetRemoteAddress().c_str(), m_Session?m_Session->GetAccountId():-1);
if (sLog->IsOutDebug())
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "Dumping error causing packet:");
new_pct->hexlike();
}
return -1;
}
ACE_NOTREACHED (return 0);
}
开发者ID:Allowed,项目名称:Strawberry335,代码行数:77,代码来源:WorldSocket.cpp
示例2: MANGOS_ASSERT
int WorldSocket::ProcessIncoming(WorldPacket* new_pct)
{
MANGOS_ASSERT(new_pct);
// manage memory ;)
ACE_Auto_Ptr<WorldPacket> aptr(new_pct);
const ACE_UINT16 opcode = new_pct->GetOpcode();
if (opcode >= NUM_MSG_TYPES)
{
sLog.outError("SESSION: received nonexistent opcode 0x%.4X", opcode);
return -1;
}
if (closing_)
return -1;
// Dump received packet.
sLog.outWorldPacketDump(uint32(get_handle()), new_pct->GetOpcode(), new_pct->GetOpcodeName(), new_pct, true);
try
{
switch (opcode)
{
case CMSG_PING:
return HandlePing(*new_pct);
case CMSG_AUTH_SESSION:
if (m_Session)
{
sLog.outError("WorldSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again");
return -1;
}
return HandleAuthSession(*new_pct);
case CMSG_KEEP_ALIVE:
DEBUG_LOG("CMSG_KEEP_ALIVE ,size: " SIZEFMTD " ", new_pct->size());
return 0;
default:
{
GUARD_RETURN(m_SessionLock, -1);
if (m_Session != nullptr)
{
// OK ,give the packet to WorldSession
aptr.release();
// WARNING here we call it with locks held.
// Its possible to cause deadlock if QueuePacket calls back
m_Session->QueuePacket(new_pct);
return 0;
}
else
{
sLog.outError("WorldSocket::ProcessIncoming: Client not authed opcode = %u", uint32(opcode));
return -1;
}
}
}
}
catch (ByteBufferException&)
{
sLog.outError("WorldSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i.",
opcode, GetRemoteAddress().c_str(), m_Session ? m_Session->GetAccountId() : -1);
if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
{
DEBUG_LOG("Dumping error-causing packet:");
new_pct->hexlike();
}
if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET))
{
DETAIL_LOG("Disconnecting session [account id %i / address %s] for badly formatted packet.",
m_Session ? m_Session->GetAccountId() : -1, GetRemoteAddress().c_str());
return -1;
}
else
return 0;
}
ACE_NOTREACHED(return 0);
}
开发者ID:Cio0,项目名称:mangos-tbc,代码行数:83,代码来源:WorldSocket.cpp
示例3: diff_time
int WorldSocket::HandlePing(WorldPacket& recvPacket)
{
uint32 ping;
uint32 latency;
// Get the ping packet content
recvPacket >> ping;
recvPacket >> latency;
if (m_LastPingTime == ACE_Time_Value::zero)
m_LastPingTime = ACE_OS::gettimeofday(); // for 1st ping
else
{
ACE_Time_Value cur_time = ACE_OS::gettimeofday();
ACE_Time_Value diff_time(cur_time);
diff_time -= m_LastPingTime;
m_LastPingTime = cur_time;
if (diff_time < ACE_Time_Value(27))
{
++m_OverSpeedPings;
uint32 max_count = sWorld.getConfig(CONFIG_UINT32_MAX_OVERSPEED_PINGS);
if (max_count && m_OverSpeedPings > max_count)
{
GUARD_RETURN(m_SessionLock, -1);
if (m_Session && m_Session->GetSecurity() == SEC_PLAYER)
{
sLog.outError("WorldSocket::HandlePing: Player kicked for "
"overspeeded pings address = %s",
GetRemoteAddress().c_str());
return -1;
}
}
}
else
m_OverSpeedPings = 0;
}
// critical section
{
GUARD_RETURN(m_SessionLock, -1);
if (m_Session)
{
m_Session->SetLatency(latency);
m_Session->ResetClientTimeDelay();
}
else
{
sLog.outError("WorldSocket::HandlePing: peer sent CMSG_PING, "
"but is not authenticated or got recently kicked,"
" address = %s",
GetRemoteAddress().c_str());
return -1;
}
}
WorldPacket packet(SMSG_PONG, 4);
packet << ping;
return SendPacket(packet);
}
开发者ID:Cio0,项目名称:mangos-tbc,代码行数:65,代码来源:WorldSocket.cpp
示例4: data
//.........这里部分代码省略.........
// TODO: what to if account already has characters of both races?
if (!AllowTwoSideAccounts)
{
uint32 acc_team = 0;
if(acc_race > 0)
acc_team = Player::TeamForRace(acc_race);
if(acc_team != team_)
{
data << (uint8)CHAR_CREATE_PVP_TEAMS_VIOLATION;
SendPacket( &data );
delete result2;
return;
}
}
// search same race for cinematic or same class if need
// TODO: check if cinematic already shown? (already logged in?; cinematic field)
while ((skipCinematics == 1 && !have_same_race) || class_ == CLASS_DEATH_KNIGHT)
{
if(!result2->NextRow())
break;
field = result2->Fetch();
acc_race = field[1].GetUInt32();
if(!have_same_race)
have_same_race = race_ == acc_race;
if(GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT)
{
uint8 acc_class = field[2].GetUInt32();
if(acc_class == CLASS_DEATH_KNIGHT)
{
if(heroic_free_slots > 0)
--heroic_free_slots;
if(heroic_free_slots == 0)
{
data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT;
SendPacket( &data );
return;
}
}
if(!have_req_level_for_heroic)
{
uint32 acc_level = field[0].GetUInt32();
if(acc_level >= req_level_for_heroic)
have_req_level_for_heroic = true;
}
}
}
delete result2;
}
}
if(GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT && !have_req_level_for_heroic)
{
data << (uint8)CHAR_CREATE_LEVEL_REQUIREMENT;
SendPacket( &data );
return;
}
// extract other data required for player creating
uint8 gender, skin, face, hairStyle, hairColor, facialHair, outfitId;
recv_data >> gender >> skin >> face;
recv_data >> hairStyle >> hairColor >> facialHair >> outfitId;
Player *pNewChar = new Player(this);
if(!pNewChar->Create( objmgr.GenerateLowGuid(HIGHGUID_PLAYER), name, race_, class_, gender, skin, face, hairStyle, hairColor, facialHair, outfitId ))
{
// Player not create (race/class problem?)
delete pNewChar;
data << (uint8)CHAR_CREATE_ERROR;
SendPacket( &data );
return;
}
if ((have_same_race && skipCinematics == 1) || skipCinematics == 2)
pNewChar->setCinematic(1); // not show intro
// Player created, save it now
pNewChar->SaveToDB();
charcount += 1;
loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", GetAccountId(), realmID);
loginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charcount, GetAccountId(), realmID);
delete pNewChar; // created only to call SaveToDB()
data << (uint8)CHAR_CREATE_SUCCESS;
SendPacket( &data );
std::string IP_str = GetRemoteAddress();
sLog.outBasic("Account: %d (IP: %s) Create Character:[%s]", GetAccountId(), IP_str.c_str(), name.c_str());
sLog.outChar("Account: %d (IP: %s) Create Character:[%s]", GetAccountId(), IP_str.c_str(), name.c_str());
}
开发者ID:viruscs,项目名称:mangos,代码行数:101,代码来源:CharacterHandler.cpp
示例5: guard
/// Update the WorldSession (triggered by World update)
bool WorldSession::Update(PacketFilter& updater)
{
std::lock_guard<std::mutex> guard(m_recvQueueLock);
///- Retrieve packets from the receive queue and call the appropriate handlers
/// not process packets if socket already closed
while (m_Socket && !m_Socket->IsClosed() && !m_recvQueue.empty())
{
auto const packet = std::move(m_recvQueue.front());
m_recvQueue.pop_front();
/*#if 1
sLog.outError( "MOEP: %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
#endif*/
OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()];
try
{
switch (opHandle.status)
{
case STATUS_LOGGEDIN:
if (!_player)
{
// skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets
if (!m_playerRecentlyLogout)
LogUnexpectedOpcode(*packet, "the player has not logged in yet");
}
else if (_player->IsInWorld())
ExecuteOpcode(opHandle, *packet);
// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
break;
case STATUS_LOGGEDIN_OR_RECENTLY_LOGGEDOUT:
if (!_player && !m_playerRecentlyLogout)
{
LogUnexpectedOpcode(*packet, "the player has not logged in yet and not recently logout");
}
else
// not expected _player or must checked in packet hanlder
ExecuteOpcode(opHandle, *packet);
break;
case STATUS_TRANSFER:
if (!_player)
LogUnexpectedOpcode(*packet, "the player has not logged in yet");
else if (_player->IsInWorld())
LogUnexpectedOpcode(*packet, "the player is still in world");
else
ExecuteOpcode(opHandle, *packet);
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if (m_inQueue)
{
LogUnexpectedOpcode(*packet, "the player not pass queue yet");
break;
}
// single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
if (packet->GetOpcode() != CMSG_SET_ACTIVE_VOICE_CHANNEL)
m_playerRecentlyLogout = false;
ExecuteOpcode(opHandle, *packet);
break;
case STATUS_NEVER:
sLog.outError("SESSION: received not allowed opcode %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
break;
case STATUS_UNHANDLED:
DEBUG_LOG("SESSION: received not handled opcode %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
break;
default:
sLog.outError("SESSION: received wrong-status-req opcode %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
break;
}
}
catch (ByteBufferException&)
{
sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
{
DEBUG_LOG("Dumping error causing packet:");
packet->hexlike();
}
if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET))
{
DETAIL_LOG("Disconnecting session [account id %u / address %s] for badly formatted packet.",
GetAccountId(), GetRemoteAddress().c_str());
KickPlayer();
//.........这里部分代码省略.........
开发者ID:Ozerev,项目名称:mangos-tbc,代码行数:101,代码来源:WorldSession.cpp
示例6: Player
//.........这里部分代码省略.........
if (!pCurrChar->GetMap()->Add(pCurrChar))
{
// normal delayed teleport protection not applied (and this correct) for this case (Player object just created)
AreaTrigger const* at = sObjectMgr.GetGoBackTrigger(pCurrChar->GetMapId());
if (at)
pCurrChar->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, pCurrChar->GetOrientation());
else
pCurrChar->TeleportToHomebind();
}
sObjectAccessor.AddObject(pCurrChar);
// DEBUG_LOG("Player %s added to Map.",pCurrChar->GetName());
pCurrChar->GetSocial()->SendFriendList();
pCurrChar->GetSocial()->SendIgnoreList();
pCurrChar->SendInitialPacketsAfterAddToMap();
static SqlStatementID updChars;
static SqlStatementID updAccount;
SqlStatement stmt = CharacterDatabase.CreateStatement(updChars, "UPDATE characters SET online = 1 WHERE guid = ?");
stmt.PExecute(pCurrChar->GetGUIDLow());
stmt = LoginDatabase.CreateStatement(updAccount, "UPDATE account SET active_realm_id = ? WHERE id = ?");
stmt.PExecute(realmID, GetAccountId());
pCurrChar->SetInGameTime(WorldTimer::getMSTime());
// announce group about member online (must be after add to player list to receive announce to self)
if (Group* group = pCurrChar->GetGroup())
group->SendUpdate();
// friend status
sSocialMgr.SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetObjectGuid(), true);
// Place character in world (and load zone) before some object loading
pCurrChar->LoadCorpse();
// setting Ghost+speed if dead
if (pCurrChar->m_deathState != ALIVE)
{
// not blizz like, we must correctly save and load player instead...
if (pCurrChar->getRace() == RACE_NIGHTELF)
pCurrChar->CastSpell(pCurrChar, 20584, true); // auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form)
pCurrChar->CastSpell(pCurrChar, 8326, true); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?)
pCurrChar->SetMovement(MOVE_WATER_WALK);
}
pCurrChar->ContinueTaxiFlight();
// Load pet if any (if player not alive and in taxi flight or another then pet will remember as temporary unsummoned)
pCurrChar->LoadPet();
// Set FFA PvP for non GM in non-rest mode
if (sWorld.IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING))
pCurrChar->SetFFAPvP(true);
if (pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
pCurrChar->SetContestedPvP();
// Apply at_login requests
if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS))
{
pCurrChar->resetSpells();
SendNotification(LANG_RESET_SPELLS);
}
if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
{
pCurrChar->resetTalents(true);
SendNotification(LANG_RESET_TALENTS); // we can use SMSG_TALENTS_INVOLUNTARILY_RESET here
}
if (pCurrChar->HasAtLoginFlag(AT_LOGIN_FIRST))
pCurrChar->RemoveAtLoginFlag(AT_LOGIN_FIRST);
// show time before shutdown if shutdown planned.
if (sWorld.IsShutdowning())
sWorld.ShutdownMsg(true, pCurrChar);
if (sWorld.getConfig(CONFIG_BOOL_ALL_TAXI_PATHS))
pCurrChar->SetTaxiCheater(true);
if (pCurrChar->isGameMaster())
SendNotification(LANG_GM_ON);
if (!pCurrChar->isGMVisible())
SendNotification(LANG_INVISIBLE_INVISIBLE);
std::string IP_str = GetRemoteAddress();
sLog.outChar("Account: %d (IP: %s) Login Character:[%s] (guid: %u)",
GetAccountId(), IP_str.c_str(), pCurrChar->GetName(), pCurrChar->GetGUIDLow());
if (!pCurrChar->IsStandState() && !pCurrChar->hasUnitState(UNIT_STAT_STUNNED))
pCurrChar->SetStandState(UNIT_STAND_STATE_STAND);
m_playerLoading = false;
delete holder;
}
开发者ID:mynew4,项目名称:MaNGOSZero,代码行数:101,代码来源:CharacterHandler.cpp
示例7: SendString
void RASocket::TryToLog(std::string str)
{
if (m_userName.empty())
{
m_accountID = sAccountMgr.GetId(str);
m_userName = str;
SendString(sObjectMgr.GetMangosStringForDBCLocale(LANG_RA_PASS));
return;
}
++m_loginTry;
m_accountID = sAccountMgr.GetId(m_userName);
if (!m_accountID)
{
SendString("Wrong user name or password.\r\n");
sLog.outRALog("User %s ip'%s' tried to connect with wrong user name.", m_userName.c_str(), GetRemoteAddress().c_str());
CanTryAnotherTime();
return;
}
AccountTypes accountLevel = sAccountMgr.GetSecurity(m_accountID);
if (accountLevel < m_minAccountLevel)
{
sLog.outRALog("Account %s ip'%s' tried to connect on Remote Administration console with insufficient privilege.", m_userName.c_str(), GetRemoteAddress().c_str());
sLog.outString("Account %s ip'%s' tried to connect on Remote Administration console with insufficient privilege.", m_userName.c_str(), GetRemoteAddress().c_str());
SendString("Wrong user name or password.\r\n");
CanTryAnotherTime();
return;
}
m_accountLevel = accountLevel;
if (!sAccountMgr.CheckPassword(m_accountID, str))
{
sLog.outRALog("Account %s ip'%s' tried to connect on Remote Administration console with wrong password.", m_userName.c_str(), GetRemoteAddress().c_str());
sLog.outString("Account %s ip'%s' tried to connect on Remote Administration console with wrong password.", m_userName.c_str(), GetRemoteAddress().c_str());
SendString("Wrong user name or password.\r\n");
CanTryAnotherTime();
return;
}
m_isLogged = true;
SendString("\r\n");
SendString(CMANGOS_PROMPT);
}
开发者ID:beyourself,项目名称:RustEmu-Core,代码行数:45,代码来源:RemoteAdministration.cpp
示例8: while
/// Update the WorldSession (triggered by World update)
bool WorldSession::Update(uint32 /*diff*/)
{
///- Retrieve packets from the receive queue and call the appropriate handlers
/// not proccess packets if socket already closed
WorldPacket* packet;
while (m_Socket && !m_Socket->IsClosed() && _recvQueue.next(packet))
{
/*#if 1
sLog.outError( "MOEP: %s (0x%.4X)",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
#endif*/
OpcodeStruct const* opHandle = opCodes.LookupOpcode(packet->GetOpcode());
try
{
switch (opHandle->status)
{
case STATUS_LOGGEDIN:
if(!_player)
{
// skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets
if(!m_playerRecentlyLogout)
LogUnexpectedOpcode(packet, "the player has not logged in yet");
}
else if(_player->IsInWorld())
{
(this->*opHandle->handler)(*packet);
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
}
// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
break;
case STATUS_LOGGEDIN_OR_RECENTLY_LOGGEDOUT:
if(!_player && !m_playerRecentlyLogout)
{
LogUnexpectedOpcode(packet, "the player has not logged in yet and not recently logout");
}
else
{
// not expected _player or must checked in packet hanlder
(this->*opHandle->handler)(*packet);
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
}
break;
case STATUS_TRANSFER:
if(!_player)
LogUnexpectedOpcode(packet, "the player has not logged in yet");
else if(_player->IsInWorld())
LogUnexpectedOpcode(packet, "the player is still in world");
else
{
(this->*opHandle->handler)(*packet);
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
}
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if(m_inQueue)
{
LogUnexpectedOpcode(packet, "the player not pass queue yet");
break;
}
// single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
m_playerRecentlyLogout = false;
(this->*opHandle->handler)(*packet);
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
break;
case STATUS_NEVER:
sLog.outError( "SESSION: received not allowed opcode %s (0x%.4X)",
opHandle->name,
packet->GetOpcode());
break;
case STATUS_UNHANDLED:
sLog.outDebug("SESSION: received not handled opcode %s (0x%.4X)",
opHandle->name,
packet->GetOpcode());
break;
default:
sLog.outError("SESSION: received wrong-status-req opcode %s (0x%.4X)",
opHandle->name,
packet->GetOpcode());
break;
}
}
catch (ByteBufferException &)
{
sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if(sLog.IsOutDebug())
{
sLog.outDebug("Dumping error causing packet:");
packet->hexlike();
//.........这里部分代码省略.........
开发者ID:dythzer,项目名称:mangoszero,代码行数:101,代码来源:WorldSession.cpp
示例9: LOG_ERROR
void AuthSocket::HandleChallenge()
{
// No header
if (readBuffer.GetContiguiousBytes() < 4)
{
LOG_ERROR("[AuthChallenge] Packet has no header. Refusing to handle.");
return;
}
// Check the rest of the packet is complete.
uint8* ReceiveBuffer = (uint8*)readBuffer.GetBufferStart();
uint16 full_size = *(uint16*)&ReceiveBuffer[2];
LOG_DETAIL("[AuthChallenge] got header, body is %u bytes", full_size);
if (readBuffer.GetSize() < uint32(full_size + 4))
{
LOG_ERROR("[AuthChallenge] Packet is smaller than expected, refusing to handle");
return;
}
// Copy the data into our cached challenge structure
if (full_size > sizeof(sAuthLogonChallenge_C))
{
LOG_ERROR("[AuthChallenge] Packet is larger than expected, refusing to handle!");
Disconnect();
return;
}
LOG_DEBUG("[AuthChallenge] got a complete packet.");
readBuffer.Read(&m_challenge, full_size + 4);
// Check client build.
uint16 client_build = m_challenge.build;
switch (client_build)
{
case 5875:
case 8606:
case 12340:
case 15595:
case 18414:
{
LOG_DEBUG("Client with valid build %u connected", (uint32)client_build);
}break;
default:
{
LOG_DEBUG("Client %s has unsupported game version. Clientbuild: %u", GetRemoteIP().c_str(), (uint32)client_build);
SendChallengeError(CE_WRONG_BUILD_NUMBER);
}break;
}
/*Patchmgr... Do not delete this
if(build < LogonServer::getSingleton().min_build)
{
// can we patch?
char flippedloc[5] = {0, 0, 0, 0, 0};
flippedloc[0] = m_challenge.country[3];
flippedloc[1] = m_challenge.country[2];
flippedloc[2] = m_challenge.country[1];
flippedloc[3] = m_challenge.country[0];
m_patch = PatchMgr::getSingleton().FindPatchForClient(build, flippedloc);
if(m_patch == NULL)
{
// could not find a valid patch
LOG_DETAIL("[AuthChallenge] Client %s has wrong version. More out of date than server. Server: %u, Client: %u", GetRemoteIP().c_str(), LogonServer::getSingleton().min_build, m_challenge.build);
SendChallengeError(CE_WRONG_BUILD_NUMBER);
return;
}
LogDebug("Patch : elected patch %u%s for client.", m_patch->Version, m_patch->Locality);
uint8 response[119] =
{
0x00, 0x00, 0x00, 0x72, 0x50, 0xa7, 0xc9, 0x27, 0x4a, 0xfa, 0xb8, 0x77, 0x80, 0x70, 0x22,
0xda, 0xb8, 0x3b, 0x06, 0x50, 0x53, 0x4a, 0x16, 0xe2, 0x65, 0xba, 0xe4, 0x43, 0x6f, 0xe3,
0x29, 0x36, 0x18, 0xe3, 0x45, 0x01, 0x07, 0x20, 0x89, 0x4b, 0x64, 0x5e, 0x89, 0xe1, 0x53,
0x5b, 0xbd, 0xad, 0x5b, 0x8b, 0x29, 0x06, 0x50, 0x53, 0x08, 0x01, 0xb1, 0x8e, 0xbf, 0xbf,
0x5e, 0x8f, 0xab, 0x3c, 0x82, 0x87, 0x2a, 0x3e, 0x9b, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x32, 0xa3,
0x49, 0x76, 0x5c, 0x5b, 0x35, 0x9a, 0x93, 0x3c, 0x6f, 0x3c, 0x63, 0x6d, 0xc0, 0x00
};
Send(response, 119);
return;
}*/
// Check for a possible IP ban on this client.
IpBanStatus ipb = sIpBanMgr.getBanStatus(GetRemoteAddress());
if (ipb != BAN_STATUS_NOT_BANNED)
LOG_DETAIL("[AuthChallenge] Client %s is banned, refusing to continue.", GetRemoteIP().c_str());
switch (ipb)
{
//.........这里部分代码省略.........
开发者ID:AscEmu,项目名称:AscEmu,代码行数:101,代码来源:AuthSocket.Legacy.cpp
示例10: while
//.........这里部分代码省略.........
sOutdoorPvPMgr->HandlePlayerLeaveZone(_player, _player->GetZoneId());
for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
{
if (BattlegroundQueueTypeId bgQueueTypeId = _player->GetBattlegroundQueueTypeId(i))
{
// track if player logs out after invited to join BG
if (_player->IsInvitedForBattlegroundQueueType(bgQueueTypeId) && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS))
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
stmt->setUInt32(0, _player->GetGUID());
stmt->setUInt8(1, BG_DESERTION_TYPE_INVITE_LOGOUT);
CharacterDatabase.Execute(stmt);
}
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
sBattlegroundMgr->m_BattlegroundQueues[ bgQueueTypeId ].RemovePlayer(_player->GetGUID(), true);
}
}
// Repop at GraveYard or other player far teleport will prevent saving player because of not present map
// Teleport player immediately for correct player save
while (_player->IsBeingTeleportedFar())
HandleMoveWorldportAckOpcode();
///- If the player is in a guild, update the guild roster and broadcast a logout message to other guild members
if (Guild* guild = sGuildMgr->GetGuildById(_player->GetGuildId()))
guild->HandleMemberLogout(this);
///- Remove pet
_player->RemovePet(NULL, PET_SAVE_AS_CURRENT, true);
///- empty buyback items and save the player in the database
// some save parts only correctly work in case player present in map/player_lists (pets, etc)
if (Save)
{
uint32 eslot;
for (int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; ++j)
{
eslot = j - BUYBACK_SLOT_START;
_player->SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0);
_player->SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0);
_player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0);
}
_player->SaveToDB();
}
///- Leave all channels before player delete...
_player->CleanupChannels();
///- If the player is in a group (or invited), remove him. If the group if then only 1 person, disband the group.
_player->UninviteFromGroup();
// remove player from the group if he is:
// a) in group; b) not in raid group; c) logging out normally (not being kicked or disconnected)
if (_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && m_Socket)
_player->RemoveFromGroup();
//! Send update to group and reset stored max enchanting level
if (_player->GetGroup())
{
_player->GetGroup()->SendUpdate();
_player->GetGroup()->ResetMaxEnchantingLevel();
}
//! Broadcast a logout message to the player's friends
sSocialMgr->SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUIDLow(), true);
sSocialMgr->RemovePlayerSocial(_player->GetGUIDLow());
//! Call script hook before deletion
sScriptMgr->OnPlayerLogout(_player);
//! Remove the player from the world
// the player may not be in the world when logging out
// e.g if he got disconnected during a transfer to another map
// calls to GetMap in this case may cause crashes
_player->CleanupsBeforeDelete();
sLog->OutCharacters("Account: %d (IP: %s) Logout Character:[%s] (GUID: %u) Level: %d", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName(), _player->GetGUIDLow(), _player->GetCurrentLevel());
if (Map* _map = _player->FindMap())
_map->RemovePlayerFromMap(_player, true);
SetPlayer(NULL); //! Pointer already deleted during RemovePlayerFromMap
//! Send the 'logout complete' packet to the client
//! Client will respond by sending 3x CMSG_CANCEL_TRADE, which we currently dont handle
WorldPacket data(SMSG_LOGOUT_COMPLETE, 0);
SendPacket(&data);
sLog->outDebug(LOG_FILTER_NETWORKIO, "SESSION: Sent SMSG_LOGOUT_COMPLETE Message");
//! Since each account can only have one online character at any given time, ensure all characters for active account are marked as offline
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ACCOUNT_ONLINE);
stmt->setUInt32(0, GetAccountId());
CharacterDatabase.Execute(stmt);
}
m_playerLogout = false;
m_playerSave = false;
m_playerRecentlyLogout = true;
LogoutRequest(0);
}
开发者ID:boom8866,项目名称:new,代码行数:101,代码来源:WorldSession.cpp
示例11: LOG_DETAIL
void AuthSocket::HandleReconnectChallenge()
{
// No header
if (readBuffer.GetContiguiousBytes() < 4)
return;
// Check the rest of the packet is complete.
uint8* ReceiveBuffer = /*GetReadBuffer(0)*/(uint8*)readBuffer.GetBufferStart();
uint16 full_size = *(uint16*)&ReceiveBuffer[2];
LOG_DETAIL("[AuthChallenge] got header, body is %u bytes", full_size);
if (readBuffer.GetSize() < (uint32)full_size + 4)
return;
// Copy the data into our cached challenge structure
if ((size_t)(full_size + 4) > sizeof(sAuthLogonChallenge_C))
{
Disconnect();
return;
}
LOG_DEBUG("[AuthChallenge] got full packet.");
memcpy(&m_challenge, ReceiveBuffer, full_size + 4);
//RemoveReadBufferBytes(full_size + 4, false);
readBuffer.Read(&m_challenge, full_size + 4);
// Check client build.
if (m_challenge.build > sMasterLogon.clientMaxBuild || m_challenge.build < sMasterLogon.clientMinBuild)
{
SendChallengeError(CE_WRONG_BUILD_NUMBER);
return;
}
// Check for a possible IP ban on this client.
IpBanStatus ipb = sIpBanMgr.getBanStatus(GetRemoteAddress());
switch (ipb)
{
case BAN_STATUS_PERMANENT_BAN:
SendChallengeError(CE_ACCOUNT_CLOSED);
return;
case BAN_STATUS_TIME_LEFT_ON_BAN:
SendChallengeError(CE_ACCOUNT_FREEZED);
return;
default:
break;
}
/* buffer overflow thing */
if (m_challenge.I_len >= 50)
{
Disconnect();
return;
}
// Null-terminate the account string
m_challenge.I[m_challenge.I_len] = 0;
// Clear the shitty hash (for server)
/* size_t i = 0;
for( i = m_challenge.I_len; i >= 0; --i )
{
if( m_challenge.I[i] == '#' )
{
m_challenge.I[i] = '\0';
break;
}
}*/
// Look up the account information
std::string AccountName = (char*)&m_challenge.I;
LOG_DEBUG("[AuthChallenge] Account Name: \"%s\"", AccountName.c_str());
m_account = sAccountMgr.getAccountByName(AccountName);
if (m_account == 0)
{
LOG_DEBUG("[AuthChallenge] Invalid account.");
// Non-existant account
SendChallengeError(CE_NO_ACCOUNT);
return;
}
LOG_DEBUG("[AuthChallenge] Account banned state = %u", m_account->Banned);
// Check that the account isn't banned.
if (m_account->Banned == 1)
{
SendChallengeError(CE_ACCOUNT_CLOSED);
return;
}
else if (m_account->Banned > 0)
{
SendChallengeError(CE_ACCOUNT_FREEZED);
return;
}
//.........这里部分代码省略.........
开发者ID:AscEmu,项目名称:AscEmu,代码行数:101,代码来源:AuthSocket.Legacy.cpp
示例12: diff_time
int WorldSocket::HandlePing (WorldPacket& recvPacket)
{
uint32 ping;
uint32 latency;
// Get the ping packet content
recvPacket >> ping;
recvPacket >> latency;
if (m_LastPingTime == ACE_Time_Value::zero)
m_LastPingTime = ACE_OS::gettimeofday(); // for 1st ping
else
{
ACE_Time_Value cur_time = ACE_OS::gettimeofday();
ACE_Time_Value diff_time (cur_time);
diff_time -= m_LastPingTime;
m_LastPingTime = cur_time;
if (diff_time < ACE_Time_Value (27))
{
++m_OverSpeedPings;
uint32 max_count = sWorld->getIntConfig (CONFIG_MAX_OVERSPEED_PINGS);
if (max_count && m_OverSpeedPings > max_count)
{
ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1);
if (m_Session && AccountMgr::IsVIPorPlayer(m_Session->GetSecurity()))
{
Player* _player = m_Session->GetPlayer();
sLog->outError("WorldSocket::HandlePing: Player (account: %u, GUID: %u, name: %s) kicked for over-speed pings (address: %s)",
m_Session->GetAccountId(),
_player ? _player->GetGUIDLow() : 0,
_player ? _player->GetName() : "<none>",
GetRemoteAddress().c_str());
return -1;
}
}
}
else
m_OverSpeedPings = 0;
}
// critical section
{
ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1);
if (m_Session)
m_Session->SetLatency (latency);
else
{
sLog->outError("WorldSocket::HandlePing: peer sent CMSG_PING, "
"but is not authenticated or got recently kicked, "
" address = %s",
GetRemoteAddress().c_str());
return -1;
}
}
WorldPacket packet (SMSG_PONG, 4);
packet << ping;
return SendPacket(packet);
}
开发者ID:Allowed,项目名称:Strawberry335,代码行数:65,代码来源:WorldSocket.cpp
示例13: uint8
int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
{
// NOTE: ATM the socket is singlethread, have this in mind ...
std::string account;
uint32 id, security;
bool authed, forceTele;
//uint8 expansion = 0;
LocaleConstant locale;
WorldPacket packet, SendAddonPacked;
if (sWorld->IsClosed())
{
packet.Initialize(SMSG_AUTH_RESPONSE, 1);
packet << uint8(AUTH_REJECT);
SendPacket (packet);
sLog->outError ("WorldSocket::HandleAuthSession: World closed, denying client (%s).", GetRemoteAddress().c_str());
return -1;
}
// Read the content of the packet
recvPacket >> account; // for now no use
recvPacket >> id;
recvPacket >> security;
recvPacket >> authed;
recvPacket >> forceTele;
// Get the account information from the realmd database
std::string safe_account = account; // Duplicate, else will screw the SHA hash verification below
LoginDatabase.EscapeString (safe_account);
// No SQL injection, username escaped.
QueryResult result =
LoginDatabase.PQuery ("SELECT "
"id, " //0
"sessionkey, " //1
"last_ip, " //2
"locked, " //3
"v, " //4
"s, " //5
"expansion, " //6
"mutetime, " //7
"locale, " //8
"recruiter " //9
"FROM account "
"WHERE username = '%s'",
safe_account.c_str());
// Stop if the account is not found
if (!result)
{
packet.Initialize (SMSG_AUTH_RESPONSE, 1);
packet << uint8 (AUTH_UNKNOWN_ACCOUNT);
SendPacket (packet);
sLog->outError ("WorldSocket::HandleAuthSession: Sent Auth Response (unknown account).");
return -1;
}
Field* fields = result->Fetch();
uint8 expansion = fields[6].GetUInt8();
uint32 world_expansion = sWorld->getIntConfig(CONFIG_EXPANSION);
if (expansion > world_expansion)
expansion = world_expansion;
//expansion = ((sWorld->getIntConfig(CONFIG_EXPANSION) > fields[6].GetUInt8()) ? fields[6].GetUInt8() : sWorld->getIntConfig(CONFIG_EXPANSION));
m_Address = fields[2].GetCString();
id = fields[0].GetUInt32();
time_t mutetime = time_t (fields[7].GetUInt64());
locale = LocaleConstant (fields[8].GetUInt8());
if (locale >= TOTAL_LOCALES)
locale = LOCALE_enUS;
uint32 recruiter = fields[9].GetUInt32();
// Re-check account ban (same check as in realmd)
QueryResult banresult =
LoginDatabase.PQuery ("SELECT 1 FROM account_banned WHERE id = %u AND active = 1 "
"UNION "
"SELECT 1 FROM ip_banned WHERE ip = '%s'",
id, GetRemoteAddress().c_str());
if (banresult) // if account banned
{
packet.Initialize (SMSG_AUTH_RESPONSE, 1);
packet << uint8 (AUTH_BANNED);
SendPacket (packet);
sLog->outError ("WorldSocket::HandleAuthSession: Sent Auth Response (Account banned).");
return -1;
}
// Check locked state for server
AccountTypes allowedAccountType = sWorld->GetPlayerSecurityLimit();
sLog->outDebug(LOG_FILTER_NETWORKIO, "Allowed Level: %u Player Level %u", allowedAccountType, AccountTypes(security));
if (allowedAccountType > SEC_PLAYER && AccountTypes(security) < allowedAccountType)
//.........这里部分代码省略.........
开发者ID:Allowed,项目名称:Strawberry335,代码行数:101,代码来源:WorldSocket.cpp
|
请发表评论