Exemplo n.º 1
0
        public static InvalidAccountAccessLog FindAccessLog(NetState ns)
        {
            if (ns == null)
            {
                return(null);
            }

            IPAddress ipAddress = ns.Address;

            for (int i = 0; i < m_List.Count; ++i)
            {
                InvalidAccountAccessLog accessLog = m_List[i];

                if (accessLog.HasExpired)
                {
                    m_List.RemoveAt(i--);
                }
                else if (accessLog.Address.Equals(ipAddress))
                {
                    return(accessLog);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        public static void RegisterInvalidAccess(NetState ns)
        {
            if (ns == null || !Enabled)
            {
                return;
            }

            InvalidAccountAccessLog accessLog = FindAccessLog(ns);

            if (accessLog == null)
            {
                m_List.Add(accessLog = new InvalidAccountAccessLog(ns.Address));
            }

            accessLog.Counts += 1;
            accessLog.RefreshAccessTime();

            if (accessLog.Counts >= 3)
            {
                try
                {
                    using (StreamWriter op = new StreamWriter("throttle.log", true))
                    {
                        op.WriteLine(
                            "{0}\t{1}\t{2}",
                            DateTime.UtcNow,
                            ns,
                            accessLog.Counts);
                    }
                }
                catch
                {
                }
            }
        }
Exemplo n.º 3
0
		public static void RegisterInvalidAccess( NetState ns )
		{
			if( ns == null || !Enabled )
				return;

			InvalidAccountAccessLog accessLog = FindAccessLog( ns );

			if( accessLog == null )
				m_List.Add( accessLog = new InvalidAccountAccessLog( ns.Address ) );

			accessLog.Counts += 1;
			accessLog.RefreshAccessTime();

			if ( accessLog.Counts >= 3 ) {
				try {
					using ( StreamWriter op = new StreamWriter( "throttle.log", true ) ) {
						op.WriteLine(
							"{0}\t{1}\t{2}",
							DateTime.Now,
							ns,
							accessLog.Counts
						);
					}
				}
				catch {
				}
			}
		}
Exemplo n.º 4
0
        public static bool Throttle_Callback(NetState ns)
        {
            InvalidAccountAccessLog accessLog = FindAccessLog(ns);

            if (accessLog == null)
            {
                return(true);
            }

            return(DateTime.UtcNow >= (accessLog.LastAccessTime + ComputeThrottle(accessLog.Counts)));
        }
		public static void RegisterInvalidAccess( NetState ns )
		{
			if ( ns == null || !Enabled )
				return;

			InvalidAccountAccessLog accessLog = FindAccessLog( ns );

			if ( accessLog == null )
				m_List.Add( accessLog = new InvalidAccountAccessLog( ns.Address ) );

			accessLog.Counts += 1;
			accessLog.RefreshAccessTime();
		}
Exemplo n.º 6
0
        public static TimeSpan Throttle_Callback(NetState ns)
        {
            InvalidAccountAccessLog accessLog = FindAccessLog(ns);

            if (accessLog == null)
            {
                return(TimeSpan.Zero);
            }

            DateTime date   = DateTime.UtcNow;
            DateTime access = accessLog.LastAccessTime + ComputeThrottle(accessLog.Counts);

            return(date >= access ? TimeSpan.Zero : date - access);
        }
Exemplo n.º 7
0
        public static void RegisterInvalidAccess(NetState ns)
        {
            if (ns == null || !Enabled)
            {
                return;
            }

            InvalidAccountAccessLog accessLog = FindAccessLog(ns);

            if (accessLog == null)
            {
                m_List.Add(accessLog = new InvalidAccountAccessLog(ns.Address));
            }

            accessLog.Counts += 1;
            accessLog.RefreshAccessTime();
        }