Closed bagder closed 6 days ago
@icing I'm not too happy with how I get the port number in Curl_cf_tcp_create
, maybe you have a better idea there? It needs to get the secondary port number for FTP and otherwise pass on the primary.
@icing I'm not too happy with how I get the port number in
Curl_cf_tcp_create
, maybe you have a better idea there? It needs to get the secondary port number for FTP and otherwise pass on the primary.
Yeah, this looks a bit ugly. As I understand it, the Curl_resolve() always gave a Curl_dns_entry
that contained a Curl_addrinfo
that carried the ip address and port. And that port was always the port that was asked for when resolving.
Now we have a wildport(?) Curl_dns_entry
with port -1 and the information about the port we want to resolve is lost when that is passed on. That's why you added the extra port parameter to overwrite that later when the actual socket is being created for addr
.
I think it would be better if hostip.c
's fetch_addr()
returns a copy of a wildport dns entry that carries the correct port in its address infos.
I think it would be better if hostip.c's fetch_addr() returns a copy of a wildport dns entry that carries the correct port in its address infos.
Right, I was pondering on that as well. I'll try that, even if that means having to copy the buffer there instead of just referencing it.
Thanks!
As was pointed out to me, this can already be accomplished with --connect-to
:
curl --connect-to ::127.0.0.1: example.com
Maybe I could still support this syntax on the cmdline, and convert it to this --connect-to
version under the hood. Also saves us from having to change libcurl.
Or maybe I just document it better...
Let's ditch this PR since we can accomplish this already!
Allow resolves for a hostname independent of port number, to a fixed address. Resolves to a fixed port number have priority.
Also works if the hostname itself is using "*" to catch all hostnames.
A key to this change is to no longer use the port number from the DNS struct stored in the cache when connecting since it is not the correct one when a wildcard port is used for CURLOPT_RESOLVE.
Removes TODO item 1.8
Verified by test 1488 and 1489