/// <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);
}