cf: replace the method get_host with query

Connection filters had a method `get_host()` which had not really been
documented. Since then, the cf had the `query()` method added. Replace
the separate get_host with query.

Add `CF_QUERY_HOST_PORT` as query to connection filters to retrieve
which remote hostname and port the filter (or its sub-filter) is talking
to. The query is implemented by HTTP and SOCKS filters, all others pass
it through.

Add `Curl_conn_get_current_host()` to retrieve the remote host and port
for a connection. During connect, this will return the host the
connection is talking to right now. Before/After connect, this will
return `conn->host.name`.

This is used by SASL authentication.

Closes #17419
This commit is contained in:
Stefan Eissing 2025-05-22 15:09:58 +02:00 committed by Daniel Stenberg
parent 779937f840
commit 70779199f3
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
19 changed files with 76 additions and 125 deletions

View file

@ -995,11 +995,11 @@ static CURLcode cf_he_connect(struct Curl_cfilter *cf,
struct ip_quadruple ipquad;
int is_ipv6;
if(!Curl_conn_cf_get_ip_info(cf->next, data, &is_ipv6, &ipquad)) {
const char *host, *disphost;
const char *host;
int port;
cf->next->cft->get_host(cf->next, data, &host, &disphost, &port);
Curl_conn_get_current_host(data, cf->sockindex, &host, &port);
CURL_TRC_CF(data, cf, "Connected to %s (%s) port %u",
disphost, ipquad.remote_ip, ipquad.remote_port);
host, ipquad.remote_ip, ipquad.remote_port);
}
}
data->info.numconnects++; /* to track the # of connections made */
@ -1136,7 +1136,6 @@ struct Curl_cftype Curl_cft_happy_eyeballs = {
cf_he_connect,
cf_he_close,
cf_he_shutdown,
Curl_cf_def_get_host,
cf_he_adjust_pollset,
cf_he_data_pending,
Curl_cf_def_send,
@ -1400,7 +1399,6 @@ struct Curl_cftype Curl_cft_setup = {
cf_setup_connect,
cf_setup_close,
Curl_cf_def_shutdown,
Curl_cf_def_get_host,
Curl_cf_def_adjust_pollset,
Curl_cf_def_data_pending,
Curl_cf_def_send,