Esempio n. 1
0
        public override bool Handle(HttpListenerContext context)
        {
            // Validate Handler
            if (context.Request.Url.LocalPath.ToLower() != "/billing_silkdatacall.asp")
            {
                return(false);
            }

            // Security check
            base.Handle(context);

            int UserJID = 0;

            try
            {
                UserJID = Int32.Parse(context.Request.QueryString["JID"]);
            }
            catch (FormatException ex)
            {
                Console.WriteLine("SilkDataCall: Invalid JID Format");
                SendResult(context.Response, "-2");
                return(true);
            }

            Model.SilkData data = Model.SilkDB.Instance.GetSilkData(UserJID);

            string KeyString = "SROG8Z_CDE1210598DK_AKD3HW1K04DL2-";

            string Valid_Key = md5sum(string.Format("{0}.{1}.{2}.{3}.{4}", UserJID, data.SilkOwn, data.SilkGift, data.Mileage, KeyString));

            SendResult(context.Response, string.Format("1:{0},{1},{2},{3}", data.SilkOwn, data.SilkGift, data.Mileage, Valid_Key));

            return(true);
        }
        public bool Handle(HttpListenerContext context)
        {
            #region SecurityCheck
            string clientIP = context.Request.RemoteEndPoint.ToString();
            try { clientIP = clientIP.Substring(0, clientIP.IndexOf(":")); } catch { }

            List <string> HostIP = new List <string>();
            foreach (string AuthorizedHost in IO.Config.cfg.Allowed_Hosts)
            {
                HostIP.Add(Dns.GetHostAddresses(AuthorizedHost)[0].ToString());
            }

            if (IO.Config.cfg.Allowed_IPs.Contains(clientIP) || HostIP.Contains(clientIP))
            {
            }
            else
            {
                return(false);
            }

            #endregion
            // Validate Handler
            if (context.Request.Url.LocalPath.ToLower() != "/billing_silkdatacall.asp")
            {
                return(false);
            }

            int UserJID = 0;

            try
            {
                UserJID = Int32.Parse(context.Request.QueryString["JID"]);
            }
            catch (FormatException ex)
            {
                Console.WriteLine("SilkDataCall: Invalid JID Format");
                SendResult(context.Response, "-2");
                return(true);
            }

            Model.SilkData data = Model.SilkDB.Instance.GetSilkData(UserJID);

            string KeyString = "SROG8Z_CDE1210598DK_AKD3HW1K04DL2-";

            string Valid_Key = md5sum(string.Format("{0}.{1}.{2}.{3}.{4}", UserJID, data.SilkOwn, data.SilkGift, data.Mileage, KeyString));

            SendResult(context.Response, string.Format("1:{0},{1},{2},{3}", data.SilkOwn, data.SilkGift, data.Mileage, Valid_Key));

            return(true);
        }