"Fossies" - the Fresh Open Source Software Archive

Member "Pound-3.0.2/include/pound.h.in" (28 Nov 2021, 5602 Bytes) of package /linux/www/Pound-3.0.2.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "pound.h.in": 3.0.1_vs_3.0.2.

    1 /*
    2  * Pound - the reverse-proxy load-balancer
    3  * Copyright (C) 2002-2020 Apsis GmbH
    4  *
    5  * This file is part of Pound.
    6  *
    7  * Pound is free software; you can redistribute it and/or modify
    8  * it under the terms of the GNU General Public License as published by
    9  * the Free Software Foundation; either version 3 of the License, or
   10  * (at your option) any later version.
   11  *
   12  * Pound is distributed in the hope that it will be useful,
   13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15  * GNU General Public License for more details.
   16  *
   17  * You should have received a copy of the GNU General Public License
   18  * along with this program.  If not, see <http://www.gnu.org/licenses/> .
   19  *
   20  * Contact information:
   21  * Apsis GmbH
   22  * P.O.Box
   23  * 8707 Uetikon am See
   24  * Switzerland
   25  * EMail: roseg@apsis.ch
   26  */
   27 
   28 #cmakedefine HAVE_MANDATORY_INCLUDES
   29 #cmakedefine HAVE_PCRE2POSIX_H
   30 #cmakedefine HAVE_PCRE_PCRE2POSIX_H
   31 #cmakedefine HAVE_PCREPOSIX_H
   32 #cmakedefine HAVE_PCRE_PCREPOSIX_H
   33 #cmakedefine HAVE_REGEX_H
   34 #cmakedefine HAVE_STDARG_H
   35 
   36 #cmakedefine VERSION            "@VERSION@"
   37 #cmakedefine MAXBUF             @MAXBUF@
   38 #cmakedefine MAXHEADERS         @MAXHEADERS@
   39 #cmakedefine RESURRECT_TO       @RESURRECT_TO@
   40 #cmakedefine RESURRECT_CYCLE    @RESURRECT_CYCLE@
   41 #cmakedefine HASH_FUNCTION      @HASH_FUNCTION@
   42 #cmakedefine LOG_FACILITY       @LOG_FACILITY@
   43 #cmakedefine H2TABSIZE          @H2TABSIZE@
   44 #cmakedefine H2FRAMESIZE        @H2FRAMESIZE@
   45 
   46 #ifdef  HAVE_MANDATORY_INCLUDES
   47 #include    <stdio.h>
   48 #include    <pthread.h>
   49 #include    <yaml.h>
   50 #include    <nanomsg/nn.h>
   51 #include    <nanomsg/inproc.h>
   52 #include    <nanomsg/pipeline.h>
   53 #include    <nanomsg/pair.h>
   54 #include    <nanomsg/reqrep.h>
   55 #include    <stdlib.h>
   56 #include    <unistd.h>
   57 #include    <fcntl.h>
   58 #include    <ctype.h>
   59 #include    <getopt.h>
   60 #include    <string.h>
   61 #include    <syslog.h>
   62 #include    <sys/types.h>
   63 #include    <sys/socket.h>
   64 #include    <netdb.h>
   65 #include    <sys/stat.h>
   66 #include    <time.h>
   67 #include    <poll.h>
   68 #include    <semaphore.h>
   69 #include    <pwd.h>
   70 #include    <grp.h>
   71 #include    <signal.h>
   72 #include    <setjmp.h>
   73 #include    <mbedtls/config.h>
   74 #include    <mbedtls/certs.h>
   75 #include    <mbedtls/oid.h>
   76 #include    <mbedtls/asn1.h>
   77 #include    <mbedtls/x509.h>
   78 #include    <mbedtls/entropy.h>
   79 #include    <mbedtls/ctr_drbg.h>
   80 #include    <mbedtls/net_sockets.h>
   81 #include    <mbedtls/ssl.h>
   82 #include    <mbedtls/error.h>
   83 #endif
   84 
   85 #ifdef  HAVE_STDARG_H
   86 #include    <stdarg.h>
   87 #else
   88 #include    <varargs.h>
   89 #endif
   90 
   91 #ifdef  HAVE_PCRE2POSIX_H
   92 #include    <pcre2posix.h>
   93 #else
   94 #ifdef HAVE_PCRE_PCRE2POSIX_H
   95 #include    <pcre/pcre2posix.h>
   96 #else
   97 #ifdef  HAVE_PCREPOSIX_H
   98 #include    <pcreposix.h>
   99 #else
  100 #ifdef HAVE_PCRE_PCREPOSIX_H
  101 #include    <pcre/pcreposix.h>
  102 #else
  103 #ifdef HAVE_REGEX_H
  104 #include    <regex.h>
  105 #endif
  106 #endif
  107 #endif
  108 #endif
  109 #endif
  110 
  111 
  112 #include    "uthash.h"
  113 #include    "utarray.h"
  114 #include    "hpack.h"
  115 
  116 #define F_CONF      "/etc/pound/pound.yaml"
  117 #define F_PID       "/var/run/pound.pid"
  118 
  119 #ifndef NI_MAXHOST
  120 #define NI_MAXHOST  1025
  121 #endif
  122 
  123 #ifndef NI_MAXSERV
  124 #define NI_MAXSERV  32
  125 #endif
  126 
  127 /* Data structures */
  128 
  129 typedef struct {
  130     char    *root_jail;
  131     uid_t   user;
  132     gid_t   group;
  133     char    *pid;
  134     char    *err404;
  135     char    *err405;
  136     char    *err500;
  137     char    *http2_preamble[5];
  138     int     log_facility;
  139     int     log_level;
  140 } GLOBAL;
  141 
  142 extern GLOBAL   global;
  143 
  144 typedef struct _backend_ {
  145     yaml_node_item_t    id;
  146     struct addrinfo *addr;
  147     /* int          rewriteLocation; */
  148     /* int          rewriteDestination; */
  149     char            *add_header;
  150     int             alive;
  151     int             timeout;
  152     int             threads;
  153     int             is_dead;
  154     int             sock_in;
  155     int             sock;
  156 } BACKEND;
  157 
  158 extern BACKEND  *backends;
  159 extern int      backends_len;
  160 
  161 typedef struct _service_ {
  162     regex_t             *url;
  163     int                 session;
  164     regex_t             *head_require;
  165     regex_t             *head_deny;
  166     BACKEND             **backends;
  167     int                 backends_len;
  168     int                 sock_in;
  169     int                 sock;
  170 } SERVICE;
  171 
  172 typedef struct {
  173     mbedtls_x509_crt    certificate;
  174     mbedtls_pk_context  key;
  175     regex_t             *host;
  176     int                 host_len;
  177 } SNI;
  178 
  179 typedef struct _http_listener_ {
  180     struct addrinfo         *addr;
  181     int                     client;
  182     int                     threads;
  183     SERVICE                 **services;
  184     int                     services_len;
  185     mbedtls_ssl_config      *conf;
  186     SNI                     **sni;
  187     int                     sock_in;
  188     int                     sock_fan;
  189 } HTTP_LISTENER;
  190 
  191 extern HTTP_LISTENER    *http_listeners;
  192 extern int              http_len;
  193 extern mbedtls_ctr_drbg_context tls_ctr_drbg;
  194 
  195 extern regex_t rex_Response, rex_Expect, rex_ContentLength, rex_Chunked, rex_Connection_Closed, rex_Connection_HTTP2, rex_Upgrade_HTTP2;
  196 
  197 extern sem_t    sem_start;
  198 
  199 /* config.c */
  200 extern void config(const int, char **);
  201 
  202 /* util.c */
  203 extern void logmsg(int, const char *, ...);
  204 extern void *thr_resurrect(void *);
  205 extern void time_stamp(char *);
  206 extern int  do_sni(void *, mbedtls_ssl_context *, const unsigned char *, size_t);
  207 
  208 /* backend.c */
  209 extern void *thr_backend(void *);
  210 
  211 /* http.c */
  212 extern void *thr_service(void *);
  213 extern int get_be(HTTP_LISTENER *, char *, char *, char *[], struct hpack_headerblock *);
  214 extern void *thr_http(void *);
  215 
  216 /* http2.c */
  217 extern void do_http2(HTTP_LISTENER *, FILE *, char *, char *, int);