fCraft.IPAddressUtil.IsLocal C# (CSharp) Method

IsLocal() public static method

Checks whether an IP address may belong to LAN or localhost (192.168.0.0/16, 10.0.0.0/24, or 127.0.0.0/24).
addr is null.
public static IsLocal ( [ addr ) : bool
addr [ IPv4 address to check.
return bool
        public static bool IsLocal( [NotNull] this IPAddress addr ) {
            if( addr == null ) throw new ArgumentNullException( "addr" );
            byte[] bytes = addr.GetAddressBytes();
            return ( bytes[0] == 192 && bytes[1] == 168 ) ||
                   ( bytes[0] == 10 ) ||
                   ( bytes[0] == 127 );
        }