Exemple #1
0
        public void Block(Int32 c, Warning client)
        {
            Pair <Int32, Warning> obj = ObjOfIndex(c);

            if (obj == null)
            {
                lock (_lock)
                    Addresses.Add(new Pair <Int32, Warning>(c, client)); // != null ? client : null)); // fix bug, object locked & null client
            }
            Warning.AddWarningToClient(client);
        }
Exemple #2
0
        private void HandleHeartBeat()
        {
            int indexOfPacketByte = Array.LastIndexOf <byte>(buff, (byte)CmdPacket.HeartBeat);

            if (indexOfPacketByte < 10) // This is a limited check for some.. years or time, needs to be specific
            {
                if (indexOfPacketByte < 0)
                {
                    Disconnect("Spoof Packet recieved from: {0}", ipport);
                }
                else
                {
                    Disconnect("Spoof Packet recieved, Beat found at: {0}", indexOfPacketByte);
                }
            }
            else
            {
                DateTime now  = DateTime.UtcNow;
                byte[]   sync = SyncClock(indexOfPacketByte);
                if (sync == null)
                {
                    Disconnect("Fake SyncClock from: {0}", ipport);
                    return;
                }

                DateTime PacketSyncData = new DateTime(BitConverter.ToInt64(sync, 0));
                //Log.Write("OneWayPing (Milliseconds): {0} Of Client: {1}", now.Subtract(testme).Milliseconds.ToString(), ip);

                if (PacketSyncData.AddSeconds(Globals.MaxOneWayRoundTime) <= now)
                {
                    Warning.AddWarningToClient(warning);
                    string msg = "Client Lagging or Faking SyncClock: {0}, Now: {1}, Client: {2}";
                    if (Warning.GetLevel(warning) > 3)
                    {
                        Disconnect(msg, PacketSyncData.ToString(), now.ToString(), ipport);
                    }
                    else
                    {
                        Log.Write(msg, PacketSyncData.ToString(), now.ToString(), ipport);
                    }
                }
                else
                {
                    lastPingOneWay = (now - PacketSyncData).Milliseconds.ToString();
                    lastheartbeat  = DateTime.UtcNow;
                }
            }
        }