cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLOPT_IPRESOLVE

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Wed, 14 Apr 2004 13:59:43 +0200 (CEST)

On Wed, 14 Apr 2004, Gisle Vanem wrote:

> How is this option to be handled? The curl manual on '-6' indicated it
> should fail if we cannot resolve to an IPv6 address. The man-page for
> curl_easy_setopt seems to take this option only as a hint.

It should resolve to an IPv6 address only. If there is none for the given
name, then it should fail.

> Looking at hostip.c it doesn't seem to enforce either on a non-IPv6 machine.

True. It should probably just return an error if CURL_IPRESOLVE_V6 is set on a
ipv4-only host.

Aha, you meant a host with getaddrinfo() that can't resolve ipv6! True. That's
a bug indeed.

> But does a fallback to AF_INET if socket(AF_INET6) fails. Shouldn't the
> resolver be decoupled from what socket() accepts? On Win-XP at least, it's
> possible to resolve a name to an IPv6 address w/o an IPv6 stack installed.

Gosh. The reason for that socket(PF_INET6) check there is that some platforms
(Linux is one) perform drasticly slower name resolves if attempting to resolve
getaddrinfo(PF_UNSPEC) without having an ipv6-enabled stack.

> IMHO the resolver code should fail if '-6' was specified and an IPv6 address
> was given or getaddrinfo() doesn't returns any AF_INET6 addresses.

I agree. But having -6 (CURL_IPRESOLVE_V6) should enforce PF_INET6 to
getaddrinfo() and then it should fail if no v6 address is available.

Or have I missed something?

> Not sure if the last part should fail in url.c (ConnectPlease?).

I think we can just fix the flaws in hostip.c to make it work as I've meant it
to.

> And this option isn't used in src/main.c. Proposed patch:

Uh. How embarrasing! ;-) Thanks. Committed!

> BTW. Does SOCKS5 handle IPv6 addresses?

Nope - this is a limitation in the SOCK5 protocol as it seems. The IP address
is stored in 4 bytes in one of the packages that get sent to the proxy.

It is even so bad that if you build libcurl with ipv6-support, we don't
support SOCKS at all since we haven't made the url.c:handleSock5Proxy()
function extract the address properly for this case.

-- 
     Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
      Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2004-04-14