Ejemplo n.º 1
0
		public void LogAccess( IPAddress ipAddress ) {
			if ( IPLimiter.IsExempt( ipAddress ) )
				return;

			if ( m_LoginIPs.Length == 0 ) {
				if ( AccountHandler.IPTable.ContainsKey( ipAddress ) )
					AccountHandler.IPTable[ipAddress]++;
				else
					AccountHandler.IPTable[ipAddress] = 1;
			}

			bool contains = false;

			for ( int i = 0; !contains && i < m_LoginIPs.Length; ++i )
				contains = m_LoginIPs[i].Equals( ipAddress );

			if ( contains )
				return;

			IPAddress[] old = m_LoginIPs;
			m_LoginIPs = new IPAddress[old.Length + 1];

			for ( int i = 0; i < old.Length; ++i )
				m_LoginIPs[i] = old[i];

			m_LoginIPs[old.Length] = ipAddress;
		}
Ejemplo n.º 2
0
		public bool HasAccess( IPAddress ipAddress ) {
			AccessLevel level = Misc.AccountHandler.LockdownLevel;

			if ( level > AccessLevel.Player )
			{
				bool hasAccess = false;

				if ( m_AccessLevel >= level )
				{
					hasAccess = true;
				}
				else
				{
					for ( int i = 0; !hasAccess && i < this.Length; ++i )
					{
						Mobile m = this[i];

						if ( m != null && m.AccessLevel >= level )
							hasAccess = true;
					}
				}

				if ( !hasAccess )
					return false;
			}

			bool accessAllowed = ( m_IPRestrictions.Length == 0 || IPLimiter.IsExempt( ipAddress ) );

			for ( int i = 0; !accessAllowed && i < m_IPRestrictions.Length; ++i )
				accessAllowed = Utility.IPMatch( m_IPRestrictions[i], ipAddress );

			return accessAllowed;
		}
Ejemplo n.º 3
0
        public void LogAccess(IPAddress ipAddress, bool loggedOut)
        {
            if (IPLimiter.IsExempt(ipAddress))
            {
                return;
            }

            if (LoginIPs.Count == 0)
            {
                if (AccountHandler.IPTable.ContainsKey(ipAddress))
                {
                    AccountHandler.IPTable[ipAddress]++;
                }
                else
                {
                    AccountHandler.IPTable[ipAddress] = 1;
                }
            }

            LogIPAccess(ipAddress, loggedOut);

            if (!LoginIPs.Contains(ipAddress))
            {
                LoginIPs.Add(ipAddress);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Checks if a specific NetState is allowed access to this account.
        /// </summary>
        /// <param name="ns">NetState instance to check.</param>
        /// <returns>True if allowed, false if not.</returns>
        public bool HasAccess(NetState ns)
        {
            if (ns == null)
            {
                return(false);
            }

            AccessLevel level = Misc.AccountHandler.LockdownLevel;

            if (level > AccessLevel.Player)
            {
                bool hasAccess = false;

                if (m_AccessLevel >= level)
                {
                    hasAccess = true;
                }
                else
                {
                    for (int i = 0; !hasAccess && i < this.Length; ++i)
                    {
                        Mobile m = this[i];

                        if (m != null && m.AccessLevel >= level)
                        {
                            hasAccess = true;
                        }
                    }
                }

                if (!hasAccess)
                {
                    return(false);
                }
            }

            IPAddress ipAddress;

            try { ipAddress = ((IPEndPoint)ns.Socket.RemoteEndPoint).Address; }
            catch { return(false); }

            bool accessAllowed = (m_IPRestrictions.Length == 0 || IPLimiter.IsExempt(ipAddress));

            for (int i = 0; !accessAllowed && i < m_IPRestrictions.Length; ++i)
            {
                accessAllowed = Utility.IPMatch(m_IPRestrictions[i], ipAddress);
            }

            return(accessAllowed);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Records the IP address of 'ns' in its 'LoginIPs' list.
        /// </summary>
        /// <param name="ns">NetState instance to record.</param>
        public void LogAccess(NetState ns)
        {
            if (ns == null)
            {
                return;
            }

            IPAddress ipAddress = ns.Address;

            if (IPLimiter.IsExempt(ipAddress))
            {
                return;
            }

            if (m_LoginIPs.Length == 0)
            {
                if (AccountHandler.IPTables[ipAddress] == null)
                {
                    AccountHandler.IPTables[ipAddress] = 1;
                }
                else
                {
                    AccountHandler.IPTables[ipAddress] = (int)AccountHandler.IPTables[ipAddress] + 1;
                }
            }

            bool contains = false;

            for (int i = 0; !contains && i < m_LoginIPs.Length; ++i)
            {
                contains = m_LoginIPs[i].Equals(ipAddress);
            }

            if (contains)
            {
                return;
            }

            IPAddress[] old = m_LoginIPs;
            m_LoginIPs = new IPAddress[old.Length + 1];

            for (int i = 0; i < old.Length; ++i)
            {
                m_LoginIPs[i] = old[i];
            }

            m_LoginIPs[old.Length] = ipAddress;
        }
Ejemplo n.º 6
0
        public void LogAccess(IPAddress ipAddress)
        {
            if (IPLimiter.IsExempt(ipAddress))
            {
                return;
            }

            if (m_LoginIPs.Count == 0)
            {
                if (AccountHandler.IPTable.ContainsKey(ipAddress))
                {
                    AccountHandler.IPTable[ipAddress]++;
                }
                else
                {
                    AccountHandler.IPTable[ipAddress] = 1;
                }
            }

/*
 *                      bool contains = false;
 *
 *                      for ( int i = 0; !contains && i < m_LoginIPs.Length; ++i )
 *                              contains = m_LoginIPs[i].Equals( ipAddress );
 *
 *                      if ( contains )
 *                              return;
 */
            if (!m_LoginIPs.Contains(ipAddress))
            {
                m_LoginIPs.Add(ipAddress);
            }

/*
 *                      IPAddress[] old = m_LoginIPs;
 *                      m_LoginIPs = new IPAddress[old.Length + 1];
 *
 *                      for ( int i = 0; i < old.Length; ++i )
 *                              m_LoginIPs[i] = old[i];
 *
 *                      m_LoginIPs[old.Length] = ipAddress;
 *
 */
        }
Ejemplo n.º 7
0
        public void LogAccess(IPAddress ipAddress)
        {
            if (IPLimiter.IsExempt(ipAddress))
            {
                return;
            }

            if (this.m_LoginIPs.Length == 0)
            {
                if (AccountHandler.IPTable.ContainsKey(ipAddress))
                {
                    AccountHandler.IPTable[ipAddress]++;
                }
                else
                {
                    AccountHandler.IPTable[ipAddress] = 1;
                }
            }

            bool contains = false;

            for (int i = 0; !contains && i < this.m_LoginIPs.Length; ++i)
            {
                contains = this.m_LoginIPs[i].Equals(ipAddress);
            }

            if (contains)
            {
                return;
            }

            IPAddress[] old = this.m_LoginIPs;
            this.m_LoginIPs = new IPAddress[old.Length + 1];

            for (int i = 0; i < old.Length; ++i)
            {
                this.m_LoginIPs[i] = old[i];
            }

            this.m_LoginIPs[old.Length] = ipAddress;
        }