mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-05 22:56:57 +02:00
log format expressions are broadly used within the code: once they are parsed from input string, they are converted to a linked list of logformat nodes. We're starting to face some limitations because we're simply storing the converted expression as a generic logformat_node list. The first issue we're facing is that storing logformat expressions that way doesn't allow us to add metadata alongside the list, which is part of the prerequites for implementing log-profiles. Another issue with storing logformat expressions as generic lists of logformat_node elements is that it's starting to become really hard to tell when we rely on logformat expressions or not in the code given that there isn't always a comment near the list declaration or manipulation to indicate that it's relying on logformat expressions under the hood, so this adds some complexity for code maintenance. This patch looks quite impressive due to changes in a lot of header and source files (since logformat expressions are broadly used), but it does a simple thing: it defines the lf_expr structure which itself holds a generic list of logformat nodes, and then declares some helpers to manipulate lf_expr elements and fixes the code so that we now exclusively manipulate logformat_node lists as lf_expr elements outside of log.c. For now, lf_expr struct only contains the list of logformat nodes (no additional metadata), but now that we have dedicated type and helpers, doing so in the future won't be problematic at all and won't require extensive code changes.
125 lines
4.1 KiB
C
125 lines
4.1 KiB
C
/*
|
|
* include/haproxy/fcgi-app-t.h
|
|
* This file defines everything related to FCGI applications.
|
|
*
|
|
* Copyright (C) 2019 HAProxy Technologies, Christopher Faulet <cfaulet@haproxy.com>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
* exclusively.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef _HAPROXY_HTTP_FCGI_T_H
|
|
#define _HAPROXY_HTTP_FCGI_T_H
|
|
|
|
#include <import/ebtree-t.h>
|
|
#include <import/ist.h>
|
|
|
|
#include <haproxy/acl-t.h>
|
|
#include <haproxy/api-t.h>
|
|
#include <haproxy/arg-t.h>
|
|
#include <haproxy/log-t.h>
|
|
#include <haproxy/fcgi.h>
|
|
#include <haproxy/filters-t.h>
|
|
#include <haproxy/regex-t.h>
|
|
|
|
#define FCGI_APP_FL_KEEP_CONN 0x00000001 /* Keep the connection alive */
|
|
#define FCGI_APP_FL_GET_VALUES 0x00000002 /* Retrieve FCGI variables on connection establishment */
|
|
#define FCGI_APP_FL_MPXS_CONNS 0x00000004 /* FCGI APP supports connection multiplexing */
|
|
|
|
|
|
enum fcgi_rule_type {
|
|
FCGI_RULE_SET_PARAM = 0,
|
|
FCGI_RULE_UNSET_PARAM,
|
|
FCGI_RULE_PASS_HDR,
|
|
FCGI_RULE_HIDE_HDR,
|
|
};
|
|
|
|
/* Used during configuration parsing only and converted into fcgi_rule when
|
|
* filter is created.
|
|
*/
|
|
struct fcgi_rule_conf {
|
|
enum fcgi_rule_type type;
|
|
char *name;
|
|
char *value;
|
|
struct acl_cond *cond; /* acl condition to set/unset the param */
|
|
struct list list;
|
|
};
|
|
|
|
/* parameter rule evaluated during request analyzis */
|
|
struct fcgi_rule {
|
|
enum fcgi_rule_type type;
|
|
struct ist name; /* name of the parameter/header */
|
|
struct lf_expr value; /* log-format compatible expression, may be empty */
|
|
struct acl_cond *cond; /* acl condition to set the param */
|
|
struct list list;
|
|
};
|
|
|
|
/* parameter rule to set/unset a param at the end of the analyzis */
|
|
struct fcgi_param_rule {
|
|
struct ist name;
|
|
struct lf_expr *value; /* if empty , unset the parameter */
|
|
struct ebpt_node node;
|
|
};
|
|
|
|
/* header rule to pass/hide a header at the end of the analyzis */
|
|
struct fcgi_hdr_rule {
|
|
struct ist name;
|
|
int pass; /* 1 to pass the header, 0 Otherwise */
|
|
struct ebpt_node node;
|
|
};
|
|
|
|
struct fcgi_app {
|
|
char *name; /* name to identify this set of params */
|
|
struct ist docroot; /* FCGI docroot */
|
|
struct ist index; /* filename to append to URI ending by a '/' */
|
|
struct my_regex *pathinfo_re; /* Regex to use to split scriptname and path-info */
|
|
unsigned int flags; /* FCGI_APP_FL_* */
|
|
struct list loggers; /* one per 'log' directive */
|
|
unsigned int maxreqs; /* maximum number of concurrent requests */
|
|
|
|
struct list acls; /* list of acls declared for this application */
|
|
|
|
struct {
|
|
char *file; /* file where the section appears */
|
|
int line; /* line where the section appears */
|
|
struct list rules; /* list of rules used during config parsing */
|
|
struct arg_list args; /* sample arg list that need to be resolved */
|
|
} conf; /* config information */
|
|
struct fcgi_app *next; /* used to chain fcgi-app */
|
|
};
|
|
|
|
/* FCGI config attached to backend proxies */
|
|
struct fcgi_flt_conf {
|
|
char *name; /* fcgi-app name used during config parsing */
|
|
struct fcgi_app *app; /* configuration of the fcgi application */
|
|
|
|
struct list param_rules; /* list of set/unset rules */
|
|
struct list hdr_rules; /* list of pass/add rules */
|
|
};
|
|
|
|
/* FCGI context attached to streames */
|
|
struct fcgi_flt_ctx {
|
|
struct filter *filter;
|
|
struct fcgi_app *app;
|
|
};
|
|
|
|
#endif /* _HAPROXY_HTTP_FCGI_T_H */
|
|
|
|
/*
|
|
* Local variables:
|
|
* c-indent-level: 8
|
|
* c-basic-offset: 8
|
|
* End:
|
|
*/
|