GetPayload() public method

Gets the payload of this packet.
public GetPayload ( ) : byte[]
return byte[]
Ejemplo n.º 1
0
        /// <summary>
        /// Requests the client config record from the server.
        /// </summary>
        /// <returns>A binary blob that represents the config record on success; otherwise <c>null</c>.</returns>
        public byte[] GetClientConfigRecord()
        {
            if (!this.HandshakeServer(ESteam2ServerType.ConfigServer))
            {
                this.Disconnect();
                return(null);
            }

            uint externalIp = Socket.Reader.ReadUInt32();

            if (!this.SendCommand(1))     // command: Get CCR
            {
                return(null);
            }

            TcpPacket pack = Socket.ReceivePacket();

            this.Disconnect();

            if (pack == null)
            {
                return(null);
            }

            return(pack.GetPayload());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets an auth server list for a specific username.
        /// </summary>
        /// <param name="userName">The username.</param>
        /// <returns>A list of servers on success; otherwise, <c>null</c>.</returns>
        public IPEndPoint[] GetAuthServerList(string userName)
        {
            userName = userName.ToLower();

            byte[] userHash = CryptoHelper.JenkinsHash(Encoding.ASCII.GetBytes(userName));
            uint   userData = BitConverter.ToUInt32(userHash, 0) & 1;

            TcpPacket packet = base.GetRawServerList(ESteam2ServerType.ProxyASClientAuthentication, NetHelpers.EndianSwap(userData));

            if (packet == null)
            {
                return(null);
            }

            DataStream ds = new DataStream(packet.GetPayload(), true);

            ushort numAddrs = ds.ReadUInt16();

            IPEndPoint[] serverList = new IPEndPoint[numAddrs];
            for (int x = 0; x < numAddrs; ++x)
            {
                IPAddrPort ipAddr = IPAddrPort.Deserialize(ds.ReadBytes(6));

                serverList[x] = ipAddr;
            }

            return(serverList);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the current content description record (CDR) provided by the config server.
        /// Optionally accepts an old CDR hash in order to determine if a new CDR should be downloaded or not.
        /// The old CDR hash is a SHA-1 hash of the entire CDR payload.
        /// </summary>
        /// <param name="oldCDRHash">An optional CDR hash.</param>
        /// <returns>A byte blob representing the CDR on success; otherwise, <c>null</c>.</returns>
        public byte[] GetContentDescriptionRecord(byte[] oldCDRHash = null)
        {
            try
            {
                if (!this.HandshakeServer(ESteam2ServerType.ConfigServer))
                {
                    return(null);
                }

                uint externalIp = Socket.Reader.ReadUInt32();

                if (oldCDRHash == null)
                {
                    oldCDRHash = new byte[20];
                }

                if (!SendCommand(9, oldCDRHash))
                {
                    return(null);
                }

                byte[] unk = Socket.Reader.ReadBytes(11);

                TcpPacket pack = Socket.ReceivePacket();
                Socket.Disconnect();

                if (pack == null)
                {
                    return(null);
                }

                return(pack.GetPayload());
            }
            catch (Exception ex)
            {
                DebugLog.WriteLine("ConfigServerClient", "GetContentDescriptionRecord threw an exception.\n{0}", ex.ToString());

                Socket.Disconnect();
                return(null);
            }
        }
        /// <summary>
        /// Gets a list of all currently active content servers.
        /// </summary>
        /// <returns>A list of servers on success; otherwise, <c>null</c>.</returns>
        public IPEndPoint[] GetContentServerList()
        {
            TcpPacket packet = base.GetRawServerList(3);   // command 3

            if (packet == null)
            {
                return(null);
            }

            DataStream ds = new DataStream(packet.GetPayload(), true);

            ushort numAddrs = ds.ReadUInt16();

            IPEndPoint[] serverList = new IPEndPoint[numAddrs];
            for (int x = 0; x < numAddrs; ++x)
            {
                IPAddrPort ipAddr = IPAddrPort.Deserialize(ds.ReadBytes(6));
                serverList[x] = ipAddr;
            }

            return(serverList);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the server list for a specific server type.
        /// </summary>
        /// <param name="type">The server type.</param>
        /// <returns>A list of servers on success; otherwise, <c>null</c>.</returns>
        public IPEndPoint[] GetServerList(ESteam2ServerType type)
        {
            TcpPacket packet = this.GetRawServerList(( byte )type);

            if (packet == null)
            {
                return(null);
            }

            DataStream ds = new DataStream(packet.GetPayload(), true);

            ushort numAddrs = ds.ReadUInt16();

            IPEndPoint[] serverList = new IPEndPoint[numAddrs];
            for (int x = 0; x < numAddrs; ++x)
            {
                IPAddrPort ipAddr = IPAddrPort.Deserialize(ds.ReadBytes(6));

                serverList[x] = ipAddr;
            }

            return(serverList);
        }
Ejemplo n.º 6
0
            /// <summary>
            /// Downloads a list of updated FileIDs since the given version.
            /// </summary>
            /// <param name="oldVersion">The old version to compare to.</param>
            /// <returns>A list of FileIDs that have been updated.</returns>
            public uint[] DownloadUpdates(uint oldVersion)
            {
                bool bRet = this.SendCommand(
                    5, // download updates
                    this.StorageID,
                    this.MessageID,
                    oldVersion
                    );

                uint storId = NetHelpers.EndianSwap(this.Socket.Reader.ReadUInt32());
                uint msgId  = NetHelpers.EndianSwap(this.Socket.Reader.ReadUInt32());

                byte updateState = this.Socket.Reader.ReadByte();

                uint numUpdates = NetHelpers.EndianSwap(this.Socket.Reader.ReadUInt32());

                if (numUpdates == 0)
                {
                    return(null);
                }

                uint storId2 = NetHelpers.EndianSwap(this.Socket.Reader.ReadUInt32());
                uint msgId2  = NetHelpers.EndianSwap(this.Socket.Reader.ReadUInt32());

                TcpPacket  packet = this.Socket.ReceivePacket();
                DataStream ds     = new DataStream(packet.GetPayload());

                uint[] fileIdList = new uint[numUpdates];
                for (int x = 0; x < numUpdates; ++x)
                {
                    fileIdList[x] = ds.ReadUInt32();
                }

                this.MessageID++;

                return(fileIdList);
            }
        static ContentServer[] GetServersFromPacket(TcpPacket packet)
        {
            DataStream ds = new DataStream(packet.GetPayload(), true);

            ushort numAddrs = ds.ReadUInt16();

            ContentServer[] serverList = new ContentServer[numAddrs];
            for (int x = 0; x < numAddrs; ++x)
            {
                uint weighedLoad = ds.ReadUInt32();

                IPAddrPort ipAddr  = IPAddrPort.Deserialize(ds.ReadBytes(6));
                IPAddrPort ipAddr2 = IPAddrPort.Deserialize(ds.ReadBytes(6));

                serverList[x] = new ContentServer()
                {
                    Load          = weighedLoad,
                    PackageServer = ipAddr,
                    StorageServer = ipAddr2,
                };
            }

            return(serverList);
        }
        static ContentServer[] GetServersFromPacket( TcpPacket packet )
        {
            DataStream ds = new DataStream( packet.GetPayload(), true );

            ushort numAddrs = ds.ReadUInt16();

            ContentServer[] serverList = new ContentServer[ numAddrs ];
            for ( int x = 0 ; x < numAddrs ; ++x )
            {
                uint weighedLoad = ds.ReadUInt32();

                IPAddrPort ipAddr = IPAddrPort.Deserialize( ds.ReadBytes( 6 ) );
                IPAddrPort ipAddr2 = IPAddrPort.Deserialize( ds.ReadBytes( 6 ) );

                serverList[ x ] = new ContentServer()
                {
                    Load = weighedLoad,
                    PackageServer = ipAddr,
                    StorageServer = ipAddr2,
                };

            }

            return serverList;
        }