コード例 #1
0
 internal void StoreNutInternal(string nut, NutInfo info, bool authorized, HttpContext context)
 {
     if (StoreNut != null)
     {
         StoreNut.Invoke(nut, info, authorized, context);
     }
     else if (StoreNutAsync != null)
     {
         StoreNutAsync.Invoke(nut, info, authorized, context).Wait();
     }
     else
     {
         StoreNutMethod(nut, info, authorized, context);
     }
 }
コード例 #2
0
        private NutInfo NewNutInfo()
        {
            NutInfo currentNut = null;

            if (Request.Query.ContainsKey("nut"))
            {
                currentNut = Options.GetAndRemoveNutInternal(Request.Query["nut"], Request.HttpContext);
            }
            return(new NutInfo
            {
                CreatedDate = DateTime.UtcNow,
                IpAddress = currentNut != null ? currentNut?.IpAddress : Request.HttpContext.Connection.RemoteIpAddress.ToString(),
                Idk = currentNut != null && currentNut.Idk != null ? currentNut?.Idk : Request.Query.ContainsKey("nut") ? GetClientParams()["idk"] : null,
                FirstNut = string.IsNullOrEmpty(currentNut?.FirstNut) ? Request.Query["nut"].ToString() : currentNut.FirstNut
            });
        }
コード例 #3
0
 private void StoreNutMethod(string nut, NutInfo info, bool authorized, HttpContext arg4)
 {
     ClearOldNuts();
     if (authorized)
     {
         lock (AuthorizedNutList)
         {
             AuthorizedNutList.Add(nut, info);
         }
     }
     else
     {
         lock (NutList)
         {
             NutList.Add(nut, info);
         }
     }
 }
コード例 #4
0
        private bool AuthorizeNut(string nut)
        {
            var opts = ParseOpts();

            if (!opts[OptKey.cps])
            {
                var nutInfo     = Options.GetAndRemoveNutInternal(nut, Request.HttpContext);
                var authNutInfo = new NutInfo
                {
                    FirstNut    = nutInfo.FirstNut,
                    CreatedDate = DateTime.UtcNow.AddSeconds(Options.NutExpiresInSeconds),
                    IpAddress   = nutInfo.IpAddress,
                    Idk         = nutInfo.Idk
                };
                Options.StoreNutInternal(nut, authNutInfo, true, Request.HttpContext);
                return(true);
            }
            return(false);
        }