示例#1
0
        //todo fix me
        public bool EvaluateOpcode(WorldPacket packet, long time)
        {
            uint maxPacketCounterAllowed = 0;// GetMaxPacketCounterAllowed(p.GetOpcode());

            // Return true if there no limit for the opcode
            if (maxPacketCounterAllowed == 0)
            {
                return(true);
            }

            if (!_PacketThrottlingMap.ContainsKey(packet.GetOpcode()))
            {
                _PacketThrottlingMap[packet.GetOpcode()] = new PacketCounter();
            }

            PacketCounter packetCounter = _PacketThrottlingMap[packet.GetOpcode()];

            if (packetCounter.lastReceiveTime != time)
            {
                packetCounter.lastReceiveTime = time;
                packetCounter.amountCounter   = 0;
            }

            // Check if player is flooding some packets
            if (++packetCounter.amountCounter <= maxPacketCounterAllowed)
            {
                return(true);
            }

            Log.outWarn(LogFilter.Network, "AntiDOS: Account {0}, IP: {1}, Ping: {2}, Character: {3}, flooding packet (opc: {4} (0x{4}), count: {5})",
                        Session.GetAccountId(), Session.GetRemoteAddress(), Session.GetLatency(), Session.GetPlayerName(), packet.GetOpcode(), packetCounter.amountCounter);

            switch (_policy)
            {
            case Policy.Log:
                return(true);

            case Policy.Kick:
                Log.outInfo(LogFilter.Network, "AntiDOS: Player kicked!");
                return(false);

            case Policy.Ban:
                BanMode bm       = (BanMode)WorldConfig.GetIntValue(WorldCfg.PacketSpoofBanmode);
                uint    duration = WorldConfig.GetUIntValue(WorldCfg.PacketSpoofBanduration);  // in seconds
                string  nameOrIp = "";
                switch (bm)
                {
                case BanMode.Character:         // not supported, ban account
                case BanMode.Account:
                    Global.AccountMgr.GetName(Session.GetAccountId(), out nameOrIp);
                    break;

                case BanMode.IP:
                    nameOrIp = Session.GetRemoteAddress();
                    break;
                }
                Global.WorldMgr.BanAccount(bm, nameOrIp, duration, "DOS (Packet Flooding/Spoofing", "Server: AutoDOS");
                Log.outInfo(LogFilter.Network, "AntiDOS: Player automatically banned for {0} seconds.", duration);
                return(false);
            }
            return(true);
        }
示例#2
0
 void LogUnexpectedOpcode(WorldPacket packet, SessionStatus status, string reason)
 {
     Log.outError(LogFilter.Network, "Received unexpected opcode {0} Status: {1} Reason: {2} from {3}", (ClientOpcodes)packet.GetOpcode(), status, reason, GetPlayerInfo());
 }
示例#3
0
 public void Dispatch(WorldPacket worldPacket)
 {
     link[worldPacket.GetOpcode()].Manage(worldPacket);
 }