From 5579550b8da66ad61e3490e3534516e1af85b947 Mon Sep 17 00:00:00 2001 From: ading2210 Date: Thu, 24 Oct 2024 04:54:00 -0400 Subject: [PATCH] update curl/wolfssl, add per host connection limit --- README.md | 2 +- client/fragments/fix_socket_limit.js | 5 +++++ client/javascript/http.js | 2 +- client/javascript/session.js | 4 ++-- client/libcurl/session.c | 3 ++- client/tools/curl.sh | 2 +- client/tools/wolfssl.sh | 4 ++-- server/wisp_server | 2 +- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9360016..d2db609 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ The valid HTTP session settings are: Each HTTP session has the following methods available: - `fetch` - Identical to the `libcurl.fetch` function but only creates connections in this session. -- `set_connections` - Set the connection limits. This takes two arguments, the first being the limit for the connection cache, and the second being the max number of active connections. +- `set_connections` - Set the connection limits. This takes three arguments: the first [is the hard limit of active connections](https://curl.se/libcurl/c/CURLMOPT_MAX_TOTAL_CONNECTIONS.html) (default 60), the second is limit for the connection cache (default 50), and the third is the [max connections per host](https://curl.se/libcurl/c/CURLMOPT_MAXCONNECTS.html) (default 6). - `export_cookies` - Export any cookies which were recorded in the session. This will return an empty string if cookies are disabled or no cookies have been set yet. - `close` - Close all connections and clean up the session. You must call this after you are done using the session, otherwise it will leak memory. diff --git a/client/fragments/fix_socket_limit.js b/client/fragments/fix_socket_limit.js index e3af9ae..85f576c 100644 --- a/client/fragments/fix_socket_limit.js +++ b/client/fragments/fix_socket_limit.js @@ -1,3 +1,8 @@ /* DELETE assert\(sock\.stream\.fd ?< ?64\); */ + + +/* DELETE +assert\(!exceptfds, ?['"]exceptfds not supported['"]\); +*/ diff --git a/client/javascript/http.js b/client/javascript/http.js index fa36f4b..64273fb 100644 --- a/client/javascript/http.js +++ b/client/javascript/http.js @@ -4,7 +4,7 @@ class HTTPSession extends CurlSession { this.options = options; this.base_url = undefined; - this.set_connections(50, 40); + this.set_connections(50, 40, 6); this.import_cookies(); } diff --git a/client/javascript/session.js b/client/javascript/session.js index 3d7fce5..c6c8d9a 100644 --- a/client/javascript/session.js +++ b/client/javascript/session.js @@ -28,9 +28,9 @@ class CurlSession { } } - set_connections(connections_limit, cache_limit) { + set_connections(connections_limit, cache_limit, host_conn_limit=0) { this.assert_ready(); - _session_set_options(this.session_ptr, connections_limit, cache_limit); + _session_set_options(this.session_ptr, connections_limit, cache_limit, host_conn_limit); } end_callback(request_id, error) { diff --git a/client/libcurl/session.c b/client/libcurl/session.c index fc28b09..f20948f 100644 --- a/client/libcurl/session.c +++ b/client/libcurl/session.c @@ -27,9 +27,10 @@ void session_perform(struct SessionInfo *session) { } } -void session_set_options(struct SessionInfo *session, int connections_limit, int cache_limit) { +void session_set_options(struct SessionInfo *session, int connections_limit, int cache_limit, int host_conn_limit) { curl_multi_setopt(session->multi_handle, CURLMOPT_MAX_TOTAL_CONNECTIONS, connections_limit); curl_multi_setopt(session->multi_handle, CURLMOPT_MAXCONNECTS, cache_limit); + curl_multi_setopt(session->multi_handle, CURLMOPT_MAX_HOST_CONNECTIONS, host_conn_limit); } void session_add_request(struct SessionInfo *session, CURL* http_handle) { diff --git a/client/tools/curl.sh b/client/tools/curl.sh index 4b9255a..7f7282f 100755 --- a/client/tools/curl.sh +++ b/client/tools/curl.sh @@ -14,7 +14,7 @@ NGHTTP2_PREFIX=$(realpath build/nghttp2-wasm) cd build rm -rf curl -git clone -b curl-8_9_1 --depth=1 https://github.com/curl/curl +git clone -b curl-8_10_1 --depth=1 https://github.com/curl/curl cd curl autoreconf -fi diff --git a/client/tools/wolfssl.sh b/client/tools/wolfssl.sh index 897da09..20b78a9 100755 --- a/client/tools/wolfssl.sh +++ b/client/tools/wolfssl.sh @@ -12,11 +12,11 @@ mkdir -p $PREFIX cd build rm -rf wolfssl -git clone -b v5.6.6-stable --depth=1 https://github.com/wolfSSL/wolfssl wolfssl +git clone -b v5.7.2-stable --depth=1 https://github.com/wolfSSL/wolfssl wolfssl cd wolfssl autoreconf -fi -export CFLAGS="-Oz -DSP_WORD_SIZE=32 -DWOLFSSL_NO_ATOMICS -DWOLFSSL_TICKET_NONCE_MALLOC" +export CFLAGS="-Oz -DSP_WORD_SIZE=32 -DWOLFSSL_NO_ATOMICS -DWOLFSSL_MAX_ALT_NAMES=1024" emconfigure ./configure --prefix=$PREFIX --enable-curl --enable-static --disable-shared --host=i686-linux --disable-examples --disable-asm --enable-sni --enable-alpn --enable-truncatedhmac --enable-oldtls --enable-tlsv12 --enable-all-crypto --disable-asyncthreads --disable-threadlocal --enable-tlsx emmake make -j$CORE_COUNT make install diff --git a/server/wisp_server b/server/wisp_server index 78f872c..f931adf 160000 --- a/server/wisp_server +++ b/server/wisp_server @@ -1 +1 @@ -Subproject commit 78f872c8e5b180e26ec09cc126e841e12ac75c36 +Subproject commit f931adf9fea476fefffb1f0c3789cafda58d54ba