Ejemplo n.º 1
0
        private ReplayDevice ParseRDDNSResponse(byte[] responseContent)
        {
            byte[] bytes = ReplayCrypt.RDDNSDecrypt(responseContent);
            string text  = Encoding.Default.GetString(bytes);

            if (text.IndexOf("ReplayError") >= 0)
            {
                char[]   separator = new char[] { ' ' };
                string[] textArray = text.Split(separator);
                char[]   trimChars = new char[] { '"' };
                this.erRespType = textArray[2].Substring(5).Trim(trimChars);
                char[] chArray3 = new char[] { '"' };
                this.erRespId = textArray[3].Substring(3).Trim(chArray3);
            }
            else
            {
                this.erRespType = "";
                this.erRespId   = "";
            }
            if (text.IndexOf("UnitTicket") >= 0)
            {
                ReplayDevice device     = new ReplayDevice();
                char[]       chArray4   = new char[] { ' ' };
                string[]     textArray2 = text.Split(chArray4);
                char[]       chArray5   = new char[] { '"' };
                device.isn = textArray2[1].Substring(4).Trim(chArray5);
                char[] chArray6 = new char[] { '"' };
                device.ip = textArray2[2].Substring(3).Trim(chArray6);
                char[] chArray7 = new char[] { '"' };
                device.port = textArray2[3].Substring(5).Trim(chArray7);
                return(device);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public long GetFileSize(string file)
        {
            string text2 = ReplayHelper.ByteArrayToHexString(ReplayCrypt.HTTPFSEncrypt("name=" + file)).ToLower();

            byte[] bytes = HTTPClient.Get(string.Format("http://{0}/httpfs-fstat?__Q_={1}", this.theDevice.ip, text2), httpfsHeaders);
            if (bytes == null)
            {
                throw new ApplicationException(string.Format("Send failed!  No response from {0} ReplayTV.  Is it connected to the network?", this.theDevice.friendlyName));
            }
            if (bytes.GetLength(0) == 0)
            {
                throw new ApplicationException("Send failed!  Show size -1MB error caught. Unable to determine a valid clock offset. Check your computer's clock.");
            }
            string text4 = Encoding.Default.GetString(bytes);

            char[]   separator = new char[] { '\n' };
            string[] textArray = text4.Split(separator);
            if (text4.StartsWith("80820005"))
            {
                throw new ApplicationException(string.Format("Send failed!  Show not found on {0} ReplayTV.  Refresh your listings.", this.theDevice.friendlyName));
            }
            long num = -1;

            string[] textArray2 = textArray;
            int      length     = textArray2.Length;

            for (int i = 0; i < length; i++)
            {
                string text5 = textArray2[i];
                if (text5.StartsWith("size="))
                {
                    num = Convert.ToInt64(text5.Substring(5).Trim());
                }
            }
            if (num == -1)
            {
                throw new ApplicationException("Send failed!  Show size -1MB error caught.  Check your computer's clock.");
            }
            return(num);
        }
Ejemplo n.º 3
0
        public ReplayDevice RDDNSLookup(string isn, bool final, string rddnsip)
        {
            string requestUri;
            string text2 = ReplayHelper.ByteArrayToHexString(ReplayCrypt.RDDNSEncrypt("isn=" + isn)).ToLower();

            if (rddnsip.Length > 0)
            {
                requestUri = string.Format("http://{0}/rd/servlet/gu?q={1}", rddnsip, text2);
            }
            else
            {
                requestUri = string.Format("http://{0}/rd/servlet/gu?q={1}", rddnsServer, text2);
            }
            byte[]       responseContent = HTTPClient.Get(requestUri);
            ReplayDevice device          = this.ParseRDDNSResponse(responseContent);

            if ((!final && this.erRespType.Equals("SERVER")) && this.erRespId.Equals("-1"))
            {
                device = this.RDDNSLookup(isn, true, rddnsip);
            }
            return(device);
        }