paivana

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

commit 5b0299ab685c7a467f3c0fa7d15f7c94fb9ab087
parent c3866ab2ebe13cb74cc3fe154cdb9e318cd339d1
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 23 Apr 2026 19:30:55 +0200

only initialize templates if we are actually in paywall mode

Diffstat:
Msrc/backend/paivana-httpd.c | 70++++++++++++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 46 insertions(+), 24 deletions(-)

diff --git a/src/backend/paivana-httpd.c b/src/backend/paivana-httpd.c @@ -126,12 +126,15 @@ run (void *cls, (void) cfgfile; PH_cfg = c; - if (GNUNET_OK != - TALER_TEMPLATING_init (PAIVANA_project_data ())) + if (! PH_no_check) { - GNUNET_break (0); - GNUNET_SCHEDULER_shutdown (); - return; + if (GNUNET_OK != + TALER_TEMPLATING_init (PAIVANA_project_data ())) + { + GNUNET_break (0); + GNUNET_SCHEDULER_shutdown (); + return; + } } if (! PAIVANA_HTTPD_reverse_init ()) { @@ -164,27 +167,37 @@ run (void *cls, GNUNET_SCHEDULER_shutdown (); return; } - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string ( - c, - "paivana", - "MERCHANT_BACKEND_URL", - &PH_merchant_base_url)) { - GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - "paivana", - "MERCHANT_BACKEND_URL"); - GNUNET_SCHEDULER_shutdown (); - return; + size_t tlen = strlen (PH_target_server_base_url); + + if ( (tlen > 0) && + ('/' == PH_target_server_base_url[tlen - 1]) ) + PH_target_server_base_url[tlen - 1] = '\0'; } - if (! TALER_is_web_url (PH_merchant_base_url)) + if (! PH_no_check) { - GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, - "paivana", - "MERCHANT_BACKEND_URL", - "not a web url"); - GNUNET_SCHEDULER_shutdown (); - return; + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string ( + c, + "paivana", + "MERCHANT_BACKEND_URL", + &PH_merchant_base_url)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "paivana", + "MERCHANT_BACKEND_URL"); + GNUNET_SCHEDULER_shutdown (); + return; + } + if (! TALER_is_web_url (PH_merchant_base_url)) + { + GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, + "paivana", + "MERCHANT_BACKEND_URL", + "not a web url"); + GNUNET_SCHEDULER_shutdown (); + return; + } } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string ( @@ -237,6 +250,7 @@ run (void *cls, NULL); PH_ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule, &ctx_rc); + if (! PH_no_check) { char *merchant_access_token; char *auth_header; @@ -266,7 +280,15 @@ run (void *cls, } ctx_rc = GNUNET_CURL_gnunet_rc_create (PH_ctx); /* Once templates are done loading, this will - start the daemon as well */ + start the daemon as well. In -n (no-payment) mode we skip + the merchant round-trip entirely. */ + if (PH_no_check) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Paywall disabled (-n), skipping template load\n"); + PAIVANA_HTTPD_serve_requests (); + return; + } PAIVANA_HTTPD_load_templates (); }