public void Resynchronize(ByteQueue state, PacketReader pvSrc, Socket s)
        {
            ClientIdentifier   client = ClientStorage.GetInstance().GetClient(s);
            Filter <Direction> f      = m_DirectionFilterManager.get(client);

            f.Sequence = 0;
            f.Reset();
        }
        public void onPreLogin(ByteQueue state, PacketReader pvSrc, Socket s)
        {
            int                authID   = pvSrc.ReadInt32();
            String             username = pvSrc.ReadString(30);
            ClientIdentifier   client   = ClientStorage.GetInstance().GetClient(s);
            Filter <Direction> f        = m_DirectionFilterManager.get(client);

            f.start();
        }
Exemplo n.º 3
0
 public Client(string Name , PacketskHandler hander)
 {
     proxyIp = ConfigurationManager.AppSettings.Get("proxyIp").Split('.');
     //m_Thread = new Thread(new ThreadStart(ThreadStartHander));
     //m_Thread.Name = Name;
     //m_Thread.Start();
     m_Buffer = new ByteQueue(this);
     this.m_PacketsHander = hander;
     this.m_Disposed = false;
 }
        public void onAccountLogin(ByteQueue state, PacketReader pvSrc, Socket s)
        {
            int      authID   = pvSrc.ReadInt32();
            String   username = pvSrc.ReadString(30);
            FastWalk fastWalk = new FastWalk(username);

            fastWalk.Sequence = 0;
            IPEndPoint endPoint = s.RemoteEndPoint as IPEndPoint;

            this.m_IpStorage.Add(username, endPoint.Address);
            ClientIdentifier client = ClientStorage.GetInstance().GetClient(s);

            client.Username = username;
            this.m_DirectionFilterManager.add(client, fastWalk);
        }
 public void Resynchronize(ByteQueue state, PacketReader pvSrc, Socket s)
 {
     ClientIdentifier client = ClientStorage.GetInstance().GetClient(s);
     Filter<Direction> f = m_DirectionFilterManager.get(client);
     f.Sequence = 0;
     f.Reset();
 }
 public void onPreLogin(ByteQueue state, PacketReader pvSrc, Socket s)
 {
     int authID = pvSrc.ReadInt32();
     String username = pvSrc.ReadString(30);
     ClientIdentifier client = ClientStorage.GetInstance().GetClient(s);
     Filter<Direction> f = m_DirectionFilterManager.get(client);
     f.start();
 }
        public void onMovementRequest(ByteQueue state, PacketReader pvSrc,Socket s)
        {
            Direction dir = (Direction)pvSrc.ReadByte();
            int seq = pvSrc.ReadByte();
            int key = pvSrc.ReadInt32();
            ClientIdentifier client = ClientStorage.GetInstance().GetClient(s);
            Filter<Direction> f = m_DirectionFilterManager.get(client);
            bool speedhack = f.DoFilter(dir);
            if (speedhack)
            {
                //LOGGA SU FILE PER ORA STAMPO
                String baseDirecotry = Directory.GetCurrentDirectory();
                AppendPath(ref baseDirecotry, "Logs");
                AppendPath(ref baseDirecotry, "SpeedHack");
                baseDirecotry = Path.Combine(baseDirecotry, String.Format("{0}.log", f.Username));
                using (StreamWriter sw = new StreamWriter(baseDirecotry, true))
                    sw.WriteLine("Account: " + f.Username + " usa speedhack " + " Data: " + DateTime.Now);

                //Console.WriteLine("Account: " + f.Username + "usa speedhack" + "Data: " + DateTime.Now);
                //Console.WriteLine("THREAD ID " + Thread.CurrentThread.ManagedThreadId);
            }
            if (f.Sequence == 0 && seq != 0)
            {
                f.Reset();
            }
            ++seq;

            if (seq == 256)
                seq = 1;

            f.Sequence = seq;
        }
 public void onLogoutReq(ByteQueue state, PacketReader pvSrc, Socket s)
 {
     byte [] toSend = { (byte) 0x01};
     s.Send(toSend);
     state.Sender.Dispose();
 }
 public void onLoginSeed(ByteQueue state, PacketReader pvSrc, Socket s)
 {
     //DO NOTHING
 }
Exemplo n.º 10
0
 public void onAccountLogin(ByteQueue state, PacketReader pvSrc, Socket s)
 {
     int authID = pvSrc.ReadInt32();
     String username = pvSrc.ReadString( 30 );
     FastWalk fastWalk = new FastWalk(username);
     fastWalk.Sequence = 0;
     IPEndPoint endPoint = s.RemoteEndPoint as IPEndPoint;
     this.m_IpStorage.Add(username, endPoint.Address);
     ClientIdentifier client = ClientStorage.GetInstance().GetClient(s);
     client.Username = username;
     this.m_DirectionFilterManager.add(client, fastWalk);
 }
Exemplo n.º 11
0
 public void onLogoutReq(ByteQueue state, PacketReader pvSrc, Socket s)
 {
     byte [] toSend = { (byte)0x01 };
     s.Send(toSend);
     state.Sender.Dispose();
 }
Exemplo n.º 12
0
 public void onLoginSeed(ByteQueue state, PacketReader pvSrc, Socket s)
 {
     //DO NOTHING
 }
Exemplo n.º 13
0
        public bool HandleReceive(ByteQueue ns)
        {
            ByteQueue buffer = ns;

            if (buffer == null || buffer.Length <= 0)
                return true;

            lock (buffer)
            {
                int length = buffer.Length;

                if (!ns.Sender.Seeded)
                {
                    if (buffer.GetPacketID() == 0xEF)
                    {
                        // new packet in client 6.0.5.0 replaces the traditional seed method with a seed packet
                        // 0xEF = 239 = multicast IP, so this should never appear in a normal seed.  So this is backwards compatible with older clients.
                        ns.Sender.Seeded = true;
                    }
                    else if (buffer.Length >= 4)
                    {
                        buffer.Dequeue(m_Peek, 0, 4);

                        int seed = (m_Peek[0] << 24) | (m_Peek[1] << 16) | (m_Peek[2] << 8) | m_Peek[3];

                        if (seed == 0)
                        {
                            Console.WriteLine("Login: {0}: Invalid client detected, disconnecting", ns);
                            ns.Socket.Dispose();
                            return false;
                        }

                        ns.Sender.Seed = seed;
                        ns.Sender.Seeded = true;

                        length = buffer.Length;
                    }
                    else
                    {
                        return true;
                    }
                }

                while (length > 0)
                {
                    int packetID = buffer.GetPacketID();

                    PacketHandler handler = m_PacketsHander.GetHandler(packetID);

                    if (handler == null)
                    {
                        return false;
                    }

                    int packetLength = handler.Length;

                    if (packetLength <= 0)
                    {
                        if (length >= 3)
                        {
                            packetLength = buffer.GetPacketLength();

                            if (packetLength < 3)
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (length >= packetLength)
                    {

                        byte[] packetBuffer;

                        if (BufferSize >= packetLength)
                            packetBuffer = m_Buffers.AcquireBuffer();
                        else
                            packetBuffer = new byte[packetLength];

                        packetLength = buffer.Dequeue(packetBuffer, 0, packetLength);

                        PacketReader r = new PacketReader(packetBuffer, packetLength, handler.Length != 0);

                        handler.OnReceive(ns, r, ns.Socket);
                        length = buffer.Length;

                        if (BufferSize >= packetLength)
                            m_Buffers.ReleaseBuffer(packetBuffer);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return true;
        }
Exemplo n.º 14
0
 public override void doAction(int readed)
 {
     DecodeIncomingPacket(m_ListenSocket, ref data, ref readed, true);
     ByteQueue temp = new ByteQueue(this);
     temp.Enqueue(data, 0, readed);
     temp.Socket = m_ListenSocket;
     HandleReceive(temp);
 }