Aselia.Server.IsKLined C# (CSharp) Method

IsKLined() public method

public IsKLined ( IPAddress fullIp ) : bool
fullIp System.Net.IPAddress
return bool
        public unsafe override bool IsKLined(IPAddress fullIp)
        {
            byte[] bytes = fullIp.GetAddressBytes();
            if (bytes.Length < 4)
            {
                return true;
            }

            unchecked
            {
                uint ip;
                fixed (byte* pBytes = bytes)
                {
                    int offset = bytes.Length - 4;
                    ip = *(uint*)&pBytes[offset];
                }

                Cidr[] ks = Lines.K;
                for (int i = 0; i < ks.Length; i++)
                {
                    Cidr cidr = ks[i];
                    uint mask = cidr.Ip >> (32 - cidr.Mask);
                    uint match = ip >> (32 - cidr.Mask);
                    if (match == mask)
                    {
                        return true;
                    }
                }
            }

            return false;
        }