paivana

HTTP paywall reverse proxy
Log | Files | Refs | Submodules | README | LICENSE

commit 700c4299dd54c41ce045c225f4dac79647090f26
parent b3a51664bef1f27d33a67ff8ff809c895175734b
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 23 Apr 2026 22:43:21 +0200

make max upload size an option

Diffstat:
Msrc/backend/paivana-httpd.c | 9+++++++++
Msrc/backend/paivana-httpd_reverse.c | 15+++++----------
2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/backend/paivana-httpd.c b/src/backend/paivana-httpd.c @@ -52,6 +52,8 @@ struct GNUNET_CURL_Context *PH_ctx; int PH_no_check; +unsigned long long PH_request_buffer_max = 1024 * 1024; + int PH_global_ret; /** @@ -307,6 +309,13 @@ main (int argc, gettext_noop ( "disables payment, useful for testing reverse-proxy only"), &PH_no_check), + GNUNET_GETOPT_option_ulong ( + 'u', + "max-upload", + "BYTES", + gettext_noop ( + "maximum request body size to buffer before forwarding (default: 1048576)"), + &PH_request_buffer_max), GNUNET_GETOPT_OPTION_END }; enum GNUNET_GenericReturnValue ret; diff --git a/src/backend/paivana-httpd_reverse.c b/src/backend/paivana-httpd_reverse.c @@ -30,14 +30,9 @@ #include <curl/curl.h> #include <gnunet/gnunet_util_lib.h> #include <taler/taler_mhd_lib.h> +#include "paivana-httpd.h" #include "paivana-httpd_reverse.h" -/** - * Maximum upload allowed. - * FIXME: make configurable via command-line option. - */ -#define REQUEST_BUFFER_MAX (1024 * 1024) - /** * Log curl error. @@ -232,7 +227,7 @@ struct HttpRequest bool accepted; /** - * Set when the request body exceeded `REQUEST_BUFFER_MAX`. We + * Set when the request body exceeded `PH_request_buffer_max`. We * must drain the rest of the upload silently and queue the 413 * response on the "final" access-handler call. * @@ -1094,13 +1089,13 @@ PAIVANA_HTTPD_reverse (struct HttpRequest *hr, request as over-limit, silently drain the remaining body, and queue the 413 on the "final" access-handler call. */ if (hr->reject_upload || - hr->io_len + *upload_data_size > REQUEST_BUFFER_MAX) + hr->io_len + *upload_data_size > PH_request_buffer_max) { if (! hr->reject_upload) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Upload exceeds %u byte limit, rejecting\n", - (unsigned int) REQUEST_BUFFER_MAX); + "Upload exceeds %llu byte limit, rejecting\n", + PH_request_buffer_max); hr->reject_upload = true; } *upload_data_size = 0;