ftp: move listen handling to socket filter

Move the listen/accept handling of the FTP active data connection
into the socket filter and monitor 'connected' status of that as
with passive connections - more or less.

The advantage is that the socket filter now reports being connected
only when the server has actually called and accept() has been done.
This enables to bootstrap the filter chain on the data connection
just like any other. A require SSL filter can then be added right
at the start and does not need to be patched in later.

Still, the active connection keeps on needing special handling in
ftp.c as the control connection needs to be monitored while waiting
as the server might send error responses this way. So, things did
not turn out quite as squeaky clean as hoped for, but still seems
better to do that way.

Closes #14798
This commit is contained in:
Stefan Eissing 2024-09-05 16:41:53 +02:00 committed by Daniel Stenberg
parent 3455d360ce
commit a7ccd02614
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 225 additions and 298 deletions

View file

@ -147,12 +147,11 @@ CURLcode Curl_conn_tcp_listen_set(struct Curl_easy *data,
curl_socket_t *s);
/**
* Replace the listen socket with the accept()ed one.
* Return TRUE iff the last filter at `sockindex` was set via
* Curl_conn_tcp_listen_set().
*/
CURLcode Curl_conn_tcp_accepted_set(struct Curl_easy *data,
struct connectdata *conn,
int sockindex,
curl_socket_t *s);
bool Curl_conn_is_tcp_listen(struct Curl_easy *data,
int sockindex);
/**
* Peek at the socket and remote ip/port the socket filter is using.