paivana

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

paivana-httpd.h (3348B)


      1 /*
      2      This file is part of GNUnet.
      3      Copyright (C) 2026 Taler Systems SA
      4 
      5      Paivana is free software; you can redistribute it and/or
      6      modify it under the terms of the GNU General Public License
      7      as published by the Free Software Foundation; either version
      8      3, or (at your option) any later version.
      9 
     10      Paivana is distributed in the hope that it will be useful,
     11      but WITHOUT ANY WARRANTY; without even the implied warranty
     12      of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
     13      the GNU General Public License for more details.
     14 
     15      You should have received a copy of the GNU General Public
     16      License along with Paivana; see the file COPYING.  If not,
     17      write to the Free Software Foundation, Inc., 51 Franklin
     18      Street, Fifth Floor, Boston, MA 02110-1301, USA.
     19 */
     20 
     21 /**
     22  * @author Christian Grothoff
     23  * @file paivana-httpd.h
     24  *
     25  * @brief
     26  */
     27 #ifndef PAIVANA_HTTPD_H
     28 #define PAIVANA_HTTPD_H
     29 
     30 #include <regex.h>
     31 #include <stdbool.h>
     32 
     33 #define PAIVANA_LOG_INFO(...)                                  \
     34         GNUNET_log (GNUNET_ERROR_TYPE_INFO, __VA_ARGS__)
     35 #define PAIVANA_LOG_DEBUG(...)                                  \
     36         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
     37 #define PAIVANA_LOG_WARNING(...)                                  \
     38         GNUNET_log (GNUNET_ERROR_TYPE_WARNING, __VA_ARGS__)
     39 #define PAIVANA_LOG_ERROR(...)                                  \
     40         GNUNET_log (GNUNET_ERROR_TYPE_ERROR, __VA_ARGS__)
     41 
     42 /**
     43  * Destination to which HTTP server we forward requests to.
     44  * Of the format "http://servername:PORT"
     45  */
     46 extern char *PH_target_server_base_url;
     47 
     48 /**
     49  * Replace the connection to target server.
     50  * File path to the unix socket
     51  */
     52 extern char *PH_target_server_unixpath;
     53 
     54 /**
     55  * Merchant backend base URL.
     56  */
     57 extern char *PH_merchant_base_url;
     58 
     59 /**
     60  * Base URL of this site as seen by the client. If not set,
     61  * we will try to determine it from "X-Forwarded-Host" and
     62  * "Host" and "X-Forwarded-Port" headers.
     63  */
     64 extern char *PH_base_url;
     65 
     66 /**
     67  * Curl context for making HTTP requests.
     68  */
     69 extern struct GNUNET_CURL_Context *PH_ctx;
     70 
     71 /**
     72  * Pre-compiled regular expression for sites that are whitelisted
     73  * and never paywalled.
     74  */
     75 extern regex_t PH_whitelist_ex;
     76 
     77 /**
     78  * True if whitelist_ex was set.
     79  */
     80 extern bool PH_have_whitelist_ex;
     81 
     82 /**
     83  * Set to true if the cookie applies globally to all sites
     84  * and not per-page.
     85  */
     86 extern int PH_global_cookie;
     87 
     88 /**
     89  * Disable paywall check.
     90  */
     91 extern int PH_no_check;
     92 
     93 /**
     94  * If set, derive the client address from the leftmost entry of the
     95  * "X-Forwarded-For" request header (falling back to the socket
     96  * address only when the header is absent).  Only enable this when
     97  * paivana-httpd is itself behind a trusted reverse proxy that
     98  * sanitizes that header — otherwise clients can spoof their address.
     99  */
    100 extern int PH_respect_forwarded_headers;
    101 
    102 /**
    103  * Value to return from main()
    104  */
    105 extern int PH_global_ret;
    106 
    107 /**
    108  * Our configuration.
    109  */
    110 extern const struct GNUNET_CONFIGURATION_Handle *PH_cfg;
    111 
    112 /**
    113  * Maximum size (in bytes) of a request body that we will buffer
    114  * before forwarding it upstream.  Requests exceeding this are
    115  * rejected with HTTP 413.  Settable via the `-u` / `--max-upload`
    116  * command-line option; defaults to 1 MiB.
    117  */
    118 extern unsigned long long PH_request_buffer_max;
    119 
    120 
    121 #endif