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 | |
| 25 | #include <common/config.h> |
| 26 | #include <common/ist.h> |
| 27 | #include <common/fcgi.h> |
| 28 | #include <common/mini-clist.h> |
| 29 | #include <common/regex.h> |
| 30 | |
| 31 | #include <ebistree.h> |
| 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 | */ |