public override void OnPacketInbound(Packet pPacket) { if (pPacket.Length == 0) { return; } StartLogging(); try { byte header = pPacket.ReadByte(); if (IsConnectedAsClient) { if (header == (byte)ServerMessages.PING) { SendPong(); } } else { if (header == (byte)ClientMessages.PONG) { gotPong = true; PingMS = (int)(MasterThread.CurrentTime - pingSentDateTime); } else if (header == (byte)ClientMessages.__CUSTOM_DC_ME__) { ScheduleDisconnect(); return; } else if (MEMORY_CRC_ENABLED) { // Check for expected CRC packet if ((BitConverter.ToUInt16(previousDecryptIV, 0) % 31) == 0) { bool disconnect = true; if (header == (byte)ClientMessages.CLIENT_HASH) { var mode = pPacket.ReadByte(); if (mode == 1) { var clientCRC = pPacket.ReadUInt(); if (ValidateCRC(clientCRC)) { disconnect = false; } else { log.Error($"Disconnecting client because CRC didnt match {clientCRC}"); } } else { log.Error($"Disconnecting client because unexpected mode: {mode}"); } } else { log.Error( $"Disconnecting client because expected CLIENT_HASH packet, but got {header} instead"); } if (disconnect) { Disconnect(); return; } } } } pPacket.Reset(0); AC_OnPacketInbound(pPacket); } catch (Exception ex) { log.Error(ex); } finally { EndLogging(); } }