public void Dispatch(WorldSession session, uint serviceHash, uint token, uint methodId, CodedInputStream stream) { var action = _dispatchers.LookupByKey(serviceHash); if (action != null) { action(session, serviceHash, token, methodId, stream); } else { Log.outDebug(LogFilter.SessionRpc, "{0} tried to call invalid service {1}", session.GetPlayerInfo(), serviceHash); } }
public void LogPacket(WorldSession session) { Log.outDebug(LogFilter.Network, "Received ClientOpcode: {0} From: {1}", GetOpcode(), session != null ? session.GetPlayerInfo() : "Unknown IP"); }
public void LogPacket(WorldSession session) { Log.outDebug(LogFilter.Network, "Sent ServerOpcode: {0} To: {1}", GetOpcode(), session != null ? session.GetPlayerInfo() : ""); }
ReadDataHandlerResult ReadData() { PacketHeader header = new PacketHeader(); header.Read(_headerBuffer.GetData()); if (!_worldCrypt.Decrypt(_packetBuffer.GetData(), header.Tag)) { Log.outError(LogFilter.Network, $"WorldSocket.ReadData(): client {GetRemoteIpAddress()} failed to decrypt packet (size: {header.Size})"); return(ReadDataHandlerResult.Error); } WorldPacket packet = new WorldPacket(_packetBuffer.GetData()); _packetBuffer.Reset(); if (packet.GetOpcode() >= (int)ClientOpcodes.Max) { Log.outError(LogFilter.Network, $"WorldSocket.ReadData(): client {GetRemoteIpAddress()} sent wrong opcode (opcode: {packet.GetOpcode()})"); return(ReadDataHandlerResult.Error); } PacketLog.Write(packet.GetData(), packet.GetOpcode(), GetRemoteIpAddress(), _connectType, true); ClientOpcodes opcode = (ClientOpcodes)packet.GetOpcode(); switch (opcode) { case ClientOpcodes.Ping: Ping ping = new Ping(packet); ping.Read(); if (!HandlePing(ping)) { return(ReadDataHandlerResult.Error); } break; case ClientOpcodes.AuthSession: if (_worldSession != null) { Log.outError(LogFilter.Network, $"WorldSocket.ReadData(): received duplicate CMSG_AUTH_SESSION from {_worldSession.GetPlayerInfo()}"); return(ReadDataHandlerResult.Error); } AuthSession authSession = new AuthSession(packet); authSession.Read(); HandleAuthSession(authSession); return(ReadDataHandlerResult.WaitingForQuery); case ClientOpcodes.AuthContinuedSession: if (_worldSession != null) { Log.outError(LogFilter.Network, $"WorldSocket.ReadData(): received duplicate CMSG_AUTH_CONTINUED_SESSION from {_worldSession.GetPlayerInfo()}"); return(ReadDataHandlerResult.Error); } AuthContinuedSession authContinuedSession = new AuthContinuedSession(packet); authContinuedSession.Read(); HandleAuthContinuedSession(authContinuedSession); return(ReadDataHandlerResult.WaitingForQuery); case ClientOpcodes.KeepAlive: if (_worldSession != null) { _worldSession.ResetTimeOutTime(true); } break; case ClientOpcodes.LogDisconnect: break; case ClientOpcodes.EnableNagle: SetNoDelay(false); break; case ClientOpcodes.ConnectToFailed: ConnectToFailed connectToFailed = new ConnectToFailed(packet); connectToFailed.Read(); HandleConnectToFailed(connectToFailed); break; case ClientOpcodes.EnterEncryptedModeAck: HandleEnterEncryptedModeAck(); break; default: if (_worldSession == null) { Log.outError(LogFilter.Network, $"ProcessIncoming: Client not authed opcode = {opcode}"); return(ReadDataHandlerResult.Error); } if (!PacketManager.ContainsHandler(opcode)) { Log.outError(LogFilter.Network, $"No defined handler for opcode {opcode} sent by {_worldSession.GetPlayerInfo()}"); break; } // Our Idle timer will reset on any non PING opcodes on login screen, allowing us to catch people idling. _worldSession.ResetTimeOutTime(false); // Copy the packet to the heap before enqueuing _worldSession.QueuePacket(packet); break; } return(ReadDataHandlerResult.Ok); }