CURLOPT_IPRESOLVE: preventing wrong IP version from being used

In some situations, it was possible that a transfer was setup to
use an specific IP version, but due do DNS caching or connection
reuse, it ended up using a different IP version from requested.

This commit changes the effect of CURLOPT_IPRESOLVE from simply
restricting address resolution to preventing the wrong connection
type being used, when choosing a connection from the pool, and
to restricting what addresses could be used when establishing
a new connection.

It is important that all addresses versions are resolved, even if
not used in that transfer in particular, because the result is
cached, and could be useful for a different transfer with a
different CURLOPT_IPRESOLVE setting.

Closes #6853
This commit is contained in:
Lucas Clemente Vella 2021-04-24 20:04:53 +01:00 committed by Daniel Stenberg
parent ac54b10933
commit 84d2839740
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
11 changed files with 69 additions and 100 deletions

View file

@ -32,7 +32,7 @@ http
HTTP GET with localhost --interface
</name>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -4 --interface localhost
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -4 --interface 127.0.0.1
</command>
<precheck>
perl -e "print 'Test requires default test client host address' if ( '%CLIENTIP' ne '127.0.0.1' );"