System.Net.NclUtilities.IsAddressLocal C# (CSharp) Method

IsAddressLocal() static private method

static private IsAddressLocal ( IPAddress ipAddress ) : bool
ipAddress IPAddress
return bool
        internal static bool IsAddressLocal(IPAddress ipAddress) {
            IPAddress[] localAddresses = NclUtilities.LocalAddresses;
            for (int i = 0; i < localAddresses.Length; i++)
            {
                if (ipAddress.Equals(localAddresses[i], false))
                {
                    return true;
                }
            }
            return false;
        }

Usage Example

示例#1
0
        /// <devdoc>
        /// Determines if the host Uri should be routed locally or go through the proxy.
        /// </devdoc>
        private bool IsLocal(Uri host)
        {
            string hostString = host.Host;

            IPAddress hostAddress;

            if (IPAddress.TryParse(hostString, out hostAddress))
            {
                return(IPAddress.IsLoopback(hostAddress) || NclUtilities.IsAddressLocal(hostAddress));
            }

            int dot = hostString.IndexOf('.');

            // No dot?  Local.
            if (dot == -1)
            {
                return(true);
            }

            // If it matches the primary domain, it's local.  (Whether or not the hostname matches.)
            string local = "." + IPGlobalProperties.InternalGetIPGlobalProperties().DomainName;

            if (local != null && local.Length == (hostString.Length - dot) &&
                string.Compare(local, 0, hostString, dot, local.Length, StringComparison.OrdinalIgnoreCase) == 0)
            {
                return(true);
            }
            return(false);
        }
All Usage Examples Of System.Net.NclUtilities::IsAddressLocal