socks: rewwork, cleaning up socks state handling

Restructured the code in the following ways:

* add terminal states SUCCESS and FAILED
* split SOCK4 and SOCK5 states to be more clear
* use `bufq` for send/recv of SOCK messages
* reduce SOCKS4 states, more speaking names
* for most states, move code into static function
* reduce SOCKS5 states, more speaking names
* add helpers for traversing to FAILED state
* add helper to flush bufq
* add hepler to read minimum amount into bufq

Closes #18401
This commit is contained in:
Stefan Eissing 2025-08-26 15:54:32 +02:00 committed by Daniel Stenberg
parent b3fc692568
commit ccd2b03b0d
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 970 additions and 833 deletions

View file

@ -225,7 +225,7 @@ typedef CURLcode Curl_bufq_reader(void *reader_ctx,
size_t *pnread);
/**
* Read date and append it to the end of the buffer queue until the
* Read bytes and append them to the end of the buffer queue until the
* reader returns blocking or the queue is full. A reader returns
* CURLE_AGAIN to indicate blocking.
* Returns the total amount of buf read (may be 0) in `pnread` on success.

File diff suppressed because it is too large Load diff

View file

@ -23,6 +23,7 @@
***************************************************************************/
#include "first.h"
#include "testtrace.h"
#include "memdebug.h"
static CURLcode test_lib564(const char *URL)
@ -32,6 +33,9 @@ static CURLcode test_lib564(const char *URL)
int running;
CURLM *m = NULL;
debug_config.nohex = TRUE;
debug_config.tracetime = TRUE;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
@ -39,6 +43,8 @@ static CURLcode test_lib564(const char *URL)
easy_init(curl);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_DEBUGDATA, &debug_config);
easy_setopt(curl, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);