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); } }
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 }); }
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); } } }
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); }