commit 1d94954ac3b7aad37b74278de6a0621ebcfe94c9
parent e661b59dc681f66f2e3b799a934c979161e0d200
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 26 Apr 2026 22:04:14 +0200
add new -f command-line option
Diffstat:
2 files changed, 17 insertions(+), 0 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;
+int PH_respect_forwarded_headers;
+
unsigned long long PH_request_buffer_max = 1024 * 1024;
int PH_global_ret;
@@ -316,6 +318,12 @@ main (int argc,
gettext_noop (
"maximum request body size to buffer before forwarding (default: 1048576)"),
&PH_request_buffer_max),
+ GNUNET_GETOPT_option_flag (
+ 'f',
+ "respect-forwarded-headers",
+ gettext_noop (
+ "trust X-Forwarded-For for the client address (only safe behind a trusted reverse proxy)"),
+ &PH_respect_forwarded_headers),
GNUNET_GETOPT_OPTION_END
};
enum GNUNET_GenericReturnValue ret;
diff --git a/src/backend/paivana-httpd.h b/src/backend/paivana-httpd.h
@@ -65,6 +65,15 @@ extern struct GNUNET_CURL_Context *PH_ctx;
extern int PH_no_check;
/**
+ * If set, derive the client address from the leftmost entry of the
+ * "X-Forwarded-For" request header (falling back to the socket
+ * address only when the header is absent). Only enable this when
+ * paivana-httpd is itself behind a trusted reverse proxy that
+ * sanitizes that header — otherwise clients can spoof their address.
+ */
+extern int PH_respect_forwarded_headers;
+
+/**
* Value to return from main()
*/
extern int PH_global_ret;