Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 1 | /* |
| 2 | * include/types/fcgi-app.h |
| 3 | * This file defines everything related to FCGI applications. |
| 4 | * |
| 5 | * Copyright (C) 2019 HAProxy Technologies, Christopher Faulet <cfaulet@haproxy.com> |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation, version 2.1 |
| 10 | * exclusively. |
| 11 | * |
| 12 | * This library 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 GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #ifndef _TYPES_HTTP_FCGI_H |
| 23 | #define _TYPES_HTTP_FCGI_H |
| 24 | |
Willy Tarreau | 4c7e4b7 | 2020-05-27 12:58:42 +0200 | [diff] [blame] | 25 | #include <haproxy/api-t.h> |
Willy Tarreau | eb6f701 | 2020-05-27 16:21:26 +0200 | [diff] [blame] | 26 | #include <import/ist.h> |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 27 | #include <common/fcgi.h> |
Willy Tarreau | 853b297 | 2020-05-27 18:01:47 +0200 | [diff] [blame] | 28 | #include <haproxy/list-t.h> |
Willy Tarreau | 7cd8b6e | 2020-06-02 17:32:26 +0200 | [diff] [blame] | 29 | #include <haproxy/regex-t.h> |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 30 | |
Willy Tarreau | 8d2b777 | 2020-05-27 10:58:19 +0200 | [diff] [blame] | 31 | #include <import/ebistree.h> |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 32 | |
| 33 | #include <types/acl.h> |
| 34 | #include <types/filters.h> |
| 35 | |
| 36 | #define FCGI_APP_FL_KEEP_CONN 0x00000001 /* Keep the connection alive */ |
| 37 | #define FCGI_APP_FL_GET_VALUES 0x00000002 /* Retrieve FCGI variables on connection establishment */ |
| 38 | #define FCGI_APP_FL_MPXS_CONNS 0x00000004 /* FCGI APP supports connection multiplexing */ |
| 39 | |
| 40 | |
| 41 | enum fcgi_rule_type { |
| 42 | FCGI_RULE_SET_PARAM = 0, |
| 43 | FCGI_RULE_UNSET_PARAM, |
| 44 | FCGI_RULE_PASS_HDR, |
| 45 | FCGI_RULE_HIDE_HDR, |
| 46 | }; |
| 47 | |
| 48 | /* Used during configuration parsing only and converted into fcgi_rule when |
| 49 | * filter is created. |
| 50 | */ |
| 51 | struct fcgi_rule_conf { |
| 52 | enum fcgi_rule_type type; |
| 53 | char *name; |
| 54 | char *value; |
| 55 | struct acl_cond *cond; /* acl condition to set/unset the param */ |
| 56 | struct list list; |
| 57 | }; |
| 58 | |
| 59 | /* parameter rule evaluated during request analyzis */ |
| 60 | struct fcgi_rule { |
| 61 | enum fcgi_rule_type type; |
| 62 | struct ist name; /* name of the parameter/header */ |
| 63 | struct list value; /* log-format compatible expression, may be empty */ |
| 64 | struct acl_cond *cond; /* acl condition to set the param */ |
| 65 | struct list list; |
| 66 | }; |
| 67 | |
| 68 | /* parameter rule to set/unset a param at the end of the analyzis */ |
| 69 | struct fcgi_param_rule { |
| 70 | struct ist name; |
| 71 | struct list *value; /* if empty , unset the parameter */ |
| 72 | struct ebpt_node node; |
| 73 | }; |
| 74 | |
| 75 | /* header rule to pass/hide a header at the end of the analyzis */ |
| 76 | struct fcgi_hdr_rule { |
| 77 | struct ist name; |
| 78 | int pass; /* 1 to pass the header, 0 Otherwise */ |
| 79 | struct ebpt_node node; |
| 80 | }; |
| 81 | |
| 82 | struct fcgi_app { |
| 83 | char *name; /* name to identify this set of params */ |
| 84 | struct ist docroot; /* FCGI docroot */ |
| 85 | struct ist index; /* filename to append to URI ending by a '/' */ |
| 86 | struct my_regex *pathinfo_re; /* Regex to use to split scriptname and path-info */ |
| 87 | unsigned int flags; /* FCGI_APP_FL_* */ |
| 88 | struct list logsrvs; /* log servers */ |
| 89 | unsigned int maxreqs; /* maximum number of concurrent requests */ |
| 90 | |
| 91 | struct list acls; /* list of acls declared for this application */ |
| 92 | |
| 93 | struct { |
| 94 | char *file; /* file where the section appears */ |
| 95 | int line; /* line where the section appears */ |
| 96 | struct list rules; /* list of rules used during config parsing */ |
| 97 | struct arg_list args; /* sample arg list that need to be resolved */ |
| 98 | } conf; /* config information */ |
| 99 | struct fcgi_app *next; /* used to chain fcgi-app */ |
| 100 | }; |
| 101 | |
| 102 | /* FCGI config attached to backend proxies */ |
| 103 | struct fcgi_flt_conf { |
| 104 | char *name; /* fcgi-app name used during config parsing */ |
| 105 | struct fcgi_app *app; /* configuration of the fcgi application */ |
| 106 | |
| 107 | struct list param_rules; /* list of set/unset rules */ |
| 108 | struct list hdr_rules; /* list of pass/add rules */ |
| 109 | }; |
| 110 | |
| 111 | /* FCGI context attached to streames */ |
| 112 | struct fcgi_flt_ctx { |
| 113 | struct filter *filter; |
| 114 | struct fcgi_app *app; |
| 115 | }; |
| 116 | |
| 117 | #endif /* _TYPES_HTTP_FCGI_H */ |
| 118 | |
| 119 | /* |
| 120 | * Local variables: |
| 121 | * c-indent-level: 8 |
| 122 | * c-basic-offset: 8 |
| 123 | * End: |
| 124 | */ |