mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:51:53 +03:00
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:
parent
779937f840
commit
70779199f3
19 changed files with 76 additions and 125 deletions
|
|
@ -53,23 +53,6 @@ typedef CURLcode Curl_cft_connect(struct Curl_cfilter *cf,
|
|||
struct Curl_easy *data,
|
||||
bool *done);
|
||||
|
||||
/* Return the hostname and port the connection goes to.
|
||||
* This may change with the connection state of filters when tunneling
|
||||
* is involved.
|
||||
* @param cf the filter to ask
|
||||
* @param data the easy handle currently active
|
||||
* @param phost on return, points to the relevant, real hostname.
|
||||
* this is owned by the connection.
|
||||
* @param pdisplay_host on return, points to the printable hostname.
|
||||
* this is owned by the connection.
|
||||
* @param pport on return, contains the port number
|
||||
*/
|
||||
typedef void Curl_cft_get_host(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
const char **phost,
|
||||
const char **pdisplay_host,
|
||||
int *pport);
|
||||
|
||||
struct easy_pollset;
|
||||
|
||||
/* Passing in an easy_pollset for monitoring of sockets, let
|
||||
|
|
@ -166,6 +149,7 @@ typedef CURLcode Curl_cft_cntrl(struct Curl_cfilter *cf,
|
|||
* - CF_QUERY_NEED_FLUSH: TRUE iff any of the filters have unsent data
|
||||
* - CF_QUERY_IP_INFO: res1 says if connection used IPv6, res2 is the
|
||||
* ip quadruple
|
||||
* - CF_QUERY_HOST_PORT: the remote hostname and port a filter talks to
|
||||
*/
|
||||
/* query res1 res2 */
|
||||
#define CF_QUERY_MAX_CONCURRENT 1 /* number - */
|
||||
|
|
@ -180,6 +164,7 @@ typedef CURLcode Curl_cft_cntrl(struct Curl_cfilter *cf,
|
|||
/* pass in a `const struct Curl_sockaddr_ex **` as `pres2`. Gets set
|
||||
* to NULL when not connected. */
|
||||
#define CF_QUERY_REMOTE_ADDR 10 /* - `Curl_sockaddr_ex *` */
|
||||
#define CF_QUERY_HOST_PORT 11 /* port const char * */
|
||||
|
||||
/**
|
||||
* Query the cfilter for properties. Filters ignorant of a query will
|
||||
|
|
@ -216,7 +201,6 @@ struct Curl_cftype {
|
|||
Curl_cft_connect *do_connect; /* establish connection */
|
||||
Curl_cft_close *do_close; /* close conn */
|
||||
Curl_cft_shutdown *do_shutdown; /* shutdown conn */
|
||||
Curl_cft_get_host *get_host; /* host filter talks to */
|
||||
Curl_cft_adjust_pollset *adjust_pollset; /* adjust transfer poll set */
|
||||
Curl_cft_data_pending *has_data_pending;/* conn has data pending */
|
||||
Curl_cft_send *do_send; /* send data */
|
||||
|
|
@ -244,9 +228,6 @@ void Curl_cf_def_destroy_this(struct Curl_cfilter *cf,
|
|||
|
||||
/* Default implementations for the type functions, implementing pass-through
|
||||
* the filter chain. */
|
||||
void Curl_cf_def_get_host(struct Curl_cfilter *cf, struct Curl_easy *data,
|
||||
const char **phost, const char **pdisplay_host,
|
||||
int *pport);
|
||||
void Curl_cf_def_adjust_pollset(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
struct easy_pollset *ps);
|
||||
|
|
@ -541,9 +522,17 @@ CURLcode Curl_conn_keep_alive(struct Curl_easy *data,
|
|||
#ifdef UNITTESTS
|
||||
void Curl_cf_def_close(struct Curl_cfilter *cf, struct Curl_easy *data);
|
||||
#endif
|
||||
void Curl_conn_get_host(struct Curl_easy *data, int sockindex,
|
||||
const char **phost, const char **pdisplay_host,
|
||||
int *pport);
|
||||
|
||||
/**
|
||||
* Get the remote hostname and port that the connection is currently
|
||||
* talking to (or will talk to).
|
||||
* Once connected or before connect starts,
|
||||
* it is `conn->host.name` and `conn->remote_port`.
|
||||
* During connect, when tunneling proxies are involved (http or socks),
|
||||
* it will be the name and port the proxy currently negotiates with.
|
||||
*/
|
||||
void Curl_conn_get_current_host(struct Curl_easy *data, int sockindex,
|
||||
const char **phost, int *pport);
|
||||
|
||||
/**
|
||||
* Get the maximum number of parallel transfers the connection
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue