Re: [squid-users] How to determine if URL in HttpRequest is an Ip address

From: Sachin Gupta <chingupt_at_gmail.com>
Date: Wed, 16 Oct 2013 12:18:34 +0530

We are using squid 3.1.6 and every time i access a IP Based URL, i get
1 for GetHostIsNumeric(). There is a limitation from client for
upgradation of the release :(

Searched the net and found that IsAnyAddr() had bugs and Address.cc in
ip was modified.

Applied the patch and modified the functions IsAnyAddr to

bool
Ip::Address::IsAnyAddr() const
{
    return IN6_IS_ADDR_UNSPECIFIED(&m_SocketAddr.sin6_addr) ||
IN6_ARE_ADDR_EQUAL(&m_SocketAddr.sin6_addr, &v4_anyaddr);
}

IsIPv4() to

bool
Ip::Address::IsIPv4() const
{
    return IN6_IS_ADDR_V4MAPPED( &m_SocketAddr.sin6_addr );
}

IsIPv6 to:

bool
Ip::Address::IsIPv6() const
{
    return !IsIPv4();
}

Still i keep on getting 1 for IP Based urls.

Please suggest.

Regards
Sachin

On Wed, Oct 16, 2013 at 10:44 AM, Amos Jeffries <squid3_at_treenet.co.nz> wrote:
> On 16/10/2013 4:13 p.m., Sachin Gupta wrote:
>>
>> Yes. I intent to check the host portion only.
>>
>> In HttpRequest.h, a check is being made:
>>
>> if ( host_addr.IsAnyAddr() ) {
>> xstrncpy(host, src, SQUIDHOSTNAMELEN);
>> host_is_numeric = 0;
>>
>> Does host_addr mean the host part of the destination URL?
>
>
> No. It means the results of attempting to parse the host portion of URL as
> an IP address.
>
> Please use the accessor I mentioned earlier.
>
> Amos
Received on Wed Oct 16 2013 - 06:48:42 MDT

This archive was generated by hypermail 2.2.0 : Wed Oct 16 2013 - 12:00:05 MDT