Esempio n. 1
0
        public SharedItem(AresTCPPacketReader packet)
        {
            this.Mime = (Mime)packet.ReadByte();
            this.Size = packet.ReadUInt32();
            ushort len = packet.ReadUInt16();
            this.SearchWords = Encoding.UTF8.GetString(packet.ReadBytes(len)).ToUpper();
            this.Data = packet.ReadBytes();
            this.FileName = null;
            this.Title = null;

            packet = new AresTCPPacketReader(this.Data);
            packet.SkipBytes(18); // 16 guid + 2 detail len

            switch (this.Mime)
            {
                case Mime.ARES_MIME_MP3:
                    packet.SkipBytes(4);
                    break;

                case Mime.ARES_MIME_VIDEO:
                    packet.SkipBytes(6);
                    break;

                case Mime.ARES_MIME_IMAGE:
                    packet.SkipBytes(5);
                    break;
            }

            while (packet.Remaining > 2)
            {
                byte size = packet.ReadByte();
                byte type = packet.ReadByte();

                if (packet.Remaining < size)
                    break;

                byte[] data = packet.ReadBytes(size);

                switch (type)
                {
                    case 1:
                        this.Title = Encoding.UTF8.GetString(data);
                        break;

                    case 15:
                        this.FileName = Encoding.UTF8.GetString(data);
                        break;
                }
            }

            if (this.FileName != null)
                if (this.Title == null)
                    this.Title = this.FileName;
        }
Esempio n. 2
0
 public void PopulateCredentials(AresTCPPacketReader packet)
 {
     this.Guid = packet.ReadGuid();
     this.FileCount = packet.ReadUInt16();
     packet.SkipByte(); // not used
     this.Port = packet.ReadUInt16();
     this.NodeIP = packet.ReadIP();
     this.NodePort = packet.ReadUInt16();
     packet.SkipBytes(4); // line speed
     this.OrgName = packet.ReadString();
     this.OrgName = UserPool.PrepareUserName(this);
     this.name = this.OrgName;
     this.Version = packet.ReadString();
     this.LocalIP = packet.ReadIP();
     packet.SkipBytes(4); // external ip
     this.CanBrowse = packet.ReadByte() >= 3;
     this.FileCount = this.CanBrowse ? this.FileCount : (ushort)0;
     this.CurrentUploads = packet.ReadByte();
     this.MaxUploads = packet.ReadByte();
     this.CurrentQueued = packet.ReadByte();
     this.Age = packet.ReadByte();
     this.Sex = packet.ReadByte();
     this.Country = packet.ReadByte();
     this.Location = packet.ReadString();
     this.Muzzled = Muzzles.IsMuzzled(this);
 }