mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-15 10:06:55 +00:00
MEDIUM: actions: Merge (http|tcp)-(request|reponse) action structs
This patch is the first of a serie which merge all the action structs. The function "tcp-request content", "tcp-response-content", "http-request" and "http-response" have the same values and the same process for some defined actions, but the struct and the prototype of the declared function are different. This patch try to unify all of these entries.
This commit is contained in:
parent
b2f8f087fc
commit
a28a9429b2
@ -117,8 +117,8 @@ void http_end_txn(struct stream *s);
|
||||
void http_reset_txn(struct stream *s);
|
||||
void http_adjust_conn_mode(struct stream *s, struct http_txn *txn, struct http_msg *msg);
|
||||
|
||||
struct http_req_rule *parse_http_req_cond(const char **args, const char *file, int linenum, struct proxy *proxy);
|
||||
struct http_res_rule *parse_http_res_cond(const char **args, const char *file, int linenum, struct proxy *proxy);
|
||||
struct act_rule *parse_http_req_cond(const char **args, const char *file, int linenum, struct proxy *proxy);
|
||||
struct act_rule *parse_http_res_cond(const char **args, const char *file, int linenum, struct proxy *proxy);
|
||||
void free_http_req_rules(struct list *r);
|
||||
void free_http_res_rules(struct list *r);
|
||||
struct chunk *http_error_message(struct stream *s, int msgnum);
|
||||
|
71
include/types/action.h
Normal file
71
include/types/action.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* include/types/action.h
|
||||
* This file contains TCP protocol definitions.
|
||||
*
|
||||
* Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu
|
||||
*
|
||||
* 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 _TYPES_ACTION_H
|
||||
#define _TYPES_ACTION_H
|
||||
|
||||
#include <types/stick_table.h>
|
||||
|
||||
struct capture_prm {
|
||||
struct sample_expr *expr; /* expression used as the key */
|
||||
struct cap_hdr *hdr; /* the capture storage */
|
||||
};
|
||||
|
||||
struct act_rule {
|
||||
struct list list;
|
||||
struct acl_cond *cond; /* acl condition to meet */
|
||||
unsigned int action; /* HTTP_REQ_* */
|
||||
short deny_status; /* HTTP status to return to user when denying */
|
||||
int (*action_ptr)(struct act_rule *rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s); /* ptr to custom action */
|
||||
union {
|
||||
struct {
|
||||
char *realm;
|
||||
} auth; /* arg used by "auth" */
|
||||
struct {
|
||||
char *name; /* header name */
|
||||
int name_len; /* header name's length */
|
||||
struct list fmt; /* log-format compatible expression */
|
||||
struct my_regex re; /* used by replace-header and replace-value */
|
||||
} hdr_add; /* args used by "add-header" and "set-header" */
|
||||
struct redirect_rule *redir; /* redirect rule or "http-request redirect" */
|
||||
int nice; /* nice value for HTTP_REQ_ACT_SET_NICE */
|
||||
int loglevel; /* log-level value for HTTP_REQ_ACT_SET_LOGL */
|
||||
int tos; /* tos value for HTTP_REQ_ACT_SET_TOS */
|
||||
int mark; /* nfmark value for HTTP_REQ_ACT_SET_MARK */
|
||||
void *data; /* generic pointer for module or external rule */
|
||||
struct {
|
||||
char *ref; /* MAP or ACL file name to update */
|
||||
struct list key; /* pattern to retrieve MAP or ACL key */
|
||||
struct list value; /* pattern to retrieve MAP value */
|
||||
} map;
|
||||
struct {
|
||||
void *p[4];
|
||||
} act; /* generic pointers to be used by custom actions */
|
||||
} arg; /* arguments used by some actions */
|
||||
|
||||
union {
|
||||
struct capture_prm cap;
|
||||
struct track_ctr_prm trk_ctr;
|
||||
} act_prm;
|
||||
};
|
||||
|
||||
#endif /* _TYPES_ACTION_H */
|
@ -27,8 +27,8 @@
|
||||
#include <common/mini-clist.h>
|
||||
#include <common/regex.h>
|
||||
|
||||
#include <types/action.h>
|
||||
#include <types/hdr_idx.h>
|
||||
#include <types/stick_table.h>
|
||||
|
||||
/* These are the flags that are found in txn->flags */
|
||||
|
||||
@ -406,72 +406,6 @@ struct proxy;
|
||||
struct http_txn;
|
||||
struct stream;
|
||||
|
||||
struct http_req_rule {
|
||||
struct list list;
|
||||
struct acl_cond *cond; /* acl condition to meet */
|
||||
unsigned int action; /* HTTP_REQ_* */
|
||||
short deny_status; /* HTTP status to return to user when denying */
|
||||
int (*action_ptr)(struct http_req_rule *rule, struct proxy *px, struct stream *s); /* ptr to custom action */
|
||||
union {
|
||||
struct {
|
||||
char *realm;
|
||||
} auth; /* arg used by "auth" */
|
||||
struct {
|
||||
char *name; /* header name */
|
||||
int name_len; /* header name's length */
|
||||
struct list fmt; /* log-format compatible expression */
|
||||
struct my_regex re; /* used by replace-header and replace-value */
|
||||
} hdr_add; /* args used by "add-header" and "set-header" */
|
||||
struct redirect_rule *redir; /* redirect rule or "http-request redirect" */
|
||||
int nice; /* nice value for HTTP_REQ_ACT_SET_NICE */
|
||||
int loglevel; /* log-level value for HTTP_REQ_ACT_SET_LOGL */
|
||||
int tos; /* tos value for HTTP_REQ_ACT_SET_TOS */
|
||||
int mark; /* nfmark value for HTTP_REQ_ACT_SET_MARK */
|
||||
void *data; /* generic pointer for module or external rule */
|
||||
struct {
|
||||
char *ref; /* MAP or ACL file name to update */
|
||||
struct list key; /* pattern to retrieve MAP or ACL key */
|
||||
struct list value; /* pattern to retrieve MAP value */
|
||||
} map;
|
||||
struct {
|
||||
void *p[4];
|
||||
} act; /* generic pointers to be used by custom actions */
|
||||
} arg; /* arguments used by some actions */
|
||||
|
||||
union {
|
||||
struct track_ctr_prm trk_ctr;
|
||||
} act_prm;
|
||||
};
|
||||
|
||||
struct http_res_rule {
|
||||
struct list list;
|
||||
struct acl_cond *cond; /* acl condition to meet */
|
||||
unsigned int action; /* HTTP_RES_* */
|
||||
int (*action_ptr)(struct http_res_rule *rule, struct proxy *px, struct stream *s); /* ptr to custom action */
|
||||
union {
|
||||
struct {
|
||||
char *name; /* header name */
|
||||
int name_len; /* header name's length */
|
||||
struct list fmt; /* log-format compatible expression */
|
||||
struct my_regex re; /* used by replace-header and replace-value */
|
||||
} hdr_add; /* args used by "add-header" and "set-header" */
|
||||
struct redirect_rule *redir; /* redirect rule or "http-request redirect" */
|
||||
int nice; /* nice value for HTTP_RES_ACT_SET_NICE */
|
||||
int loglevel; /* log-level value for HTTP_RES_ACT_SET_LOGL */
|
||||
int tos; /* tos value for HTTP_RES_ACT_SET_TOS */
|
||||
int mark; /* nfmark value for HTTP_RES_ACT_SET_MARK */
|
||||
void *data; /* generic pointer for module or external rule */
|
||||
struct {
|
||||
char *ref; /* MAP or ACL file name to update */
|
||||
struct list key; /* pattern to retrieve MAP or ACL key */
|
||||
struct list value; /* pattern to retrieve MAP value */
|
||||
} map;
|
||||
struct {
|
||||
void *p[4];
|
||||
} act; /* generic pointers to be used by custom actions */
|
||||
} arg; /* arguments used by some actions */
|
||||
};
|
||||
|
||||
/* This is an HTTP transaction. It contains both a request message and a
|
||||
* response message (which can be empty).
|
||||
*/
|
||||
@ -519,13 +453,13 @@ struct http_method_name {
|
||||
|
||||
struct http_req_action_kw {
|
||||
const char *kw;
|
||||
int (*parse)(const char **args, int *cur_arg, struct proxy *px, struct http_req_rule *rule, char **err);
|
||||
int (*parse)(const char **args, int *cur_arg, struct proxy *px, struct act_rule *rule, char **err);
|
||||
int match_pfx;
|
||||
};
|
||||
|
||||
struct http_res_action_kw {
|
||||
const char *kw;
|
||||
int (*parse)(const char **args, int *cur_arg, struct proxy *px, struct http_res_rule *rule, char **err);
|
||||
int (*parse)(const char **args, int *cur_arg, struct proxy *px, struct act_rule *rule, char **err);
|
||||
int match_pfx;
|
||||
};
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <common/config.h>
|
||||
#include <common/mini-clist.h>
|
||||
|
||||
#include <types/action.h>
|
||||
#include <types/acl.h>
|
||||
#include <types/stream.h>
|
||||
|
||||
@ -43,28 +44,10 @@ enum {
|
||||
TCP_ACT_CUSTOM_CONT, /* Use for custom registered keywords. */
|
||||
};
|
||||
|
||||
struct capture_prm {
|
||||
struct sample_expr *expr; /* expression used as the key */
|
||||
struct cap_hdr *hdr; /* the capture storage */
|
||||
};
|
||||
|
||||
struct tcp_rule {
|
||||
struct list list;
|
||||
struct acl_cond *cond;
|
||||
int action;
|
||||
int (*action_ptr)(struct tcp_rule *rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s);
|
||||
union {
|
||||
struct track_ctr_prm trk_ctr;
|
||||
struct capture_prm cap;
|
||||
void *data[4];
|
||||
} act_prm;
|
||||
};
|
||||
|
||||
struct tcp_action_kw {
|
||||
const char *kw;
|
||||
int (*parse)(const char **args, int *cur_arg, struct proxy *px,
|
||||
struct tcp_rule *rule, char **err);
|
||||
struct act_rule *rule, char **err);
|
||||
int match_pfx;
|
||||
};
|
||||
|
||||
|
@ -3540,7 +3540,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
curproxy->conn_retries = atol(args[1]);
|
||||
}
|
||||
else if (!strcmp(args[0], "http-request")) { /* request access control: allow/deny/auth */
|
||||
struct http_req_rule *rule;
|
||||
struct act_rule *rule;
|
||||
|
||||
if (curproxy == &defproxy) {
|
||||
Alert("parsing [%s:%d]: '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
|
||||
@ -3549,11 +3549,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
}
|
||||
|
||||
if (!LIST_ISEMPTY(&curproxy->http_req_rules) &&
|
||||
!LIST_PREV(&curproxy->http_req_rules, struct http_req_rule *, list)->cond &&
|
||||
(LIST_PREV(&curproxy->http_req_rules, struct http_req_rule *, list)->action == HTTP_REQ_ACT_ALLOW ||
|
||||
LIST_PREV(&curproxy->http_req_rules, struct http_req_rule *, list)->action == HTTP_REQ_ACT_DENY ||
|
||||
LIST_PREV(&curproxy->http_req_rules, struct http_req_rule *, list)->action == HTTP_REQ_ACT_REDIR ||
|
||||
LIST_PREV(&curproxy->http_req_rules, struct http_req_rule *, list)->action == HTTP_REQ_ACT_AUTH)) {
|
||||
!LIST_PREV(&curproxy->http_req_rules, struct act_rule *, list)->cond &&
|
||||
(LIST_PREV(&curproxy->http_req_rules, struct act_rule *, list)->action == HTTP_REQ_ACT_ALLOW ||
|
||||
LIST_PREV(&curproxy->http_req_rules, struct act_rule *, list)->action == HTTP_REQ_ACT_DENY ||
|
||||
LIST_PREV(&curproxy->http_req_rules, struct act_rule *, list)->action == HTTP_REQ_ACT_REDIR ||
|
||||
LIST_PREV(&curproxy->http_req_rules, struct act_rule *, list)->action == HTTP_REQ_ACT_AUTH)) {
|
||||
Warning("parsing [%s:%d]: previous '%s' action is final and has no condition attached, further entries are NOOP.\n",
|
||||
file, linenum, args[0]);
|
||||
err_code |= ERR_WARN;
|
||||
@ -3574,7 +3574,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
LIST_ADDQ(&curproxy->http_req_rules, &rule->list);
|
||||
}
|
||||
else if (!strcmp(args[0], "http-response")) { /* response access control */
|
||||
struct http_res_rule *rule;
|
||||
struct act_rule *rule;
|
||||
|
||||
if (curproxy == &defproxy) {
|
||||
Alert("parsing [%s:%d]: '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
|
||||
@ -3583,9 +3583,9 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
}
|
||||
|
||||
if (!LIST_ISEMPTY(&curproxy->http_res_rules) &&
|
||||
!LIST_PREV(&curproxy->http_res_rules, struct http_res_rule *, list)->cond &&
|
||||
(LIST_PREV(&curproxy->http_res_rules, struct http_res_rule *, list)->action == HTTP_RES_ACT_ALLOW ||
|
||||
LIST_PREV(&curproxy->http_res_rules, struct http_res_rule *, list)->action == HTTP_RES_ACT_DENY)) {
|
||||
!LIST_PREV(&curproxy->http_res_rules, struct act_rule *, list)->cond &&
|
||||
(LIST_PREV(&curproxy->http_res_rules, struct act_rule *, list)->action == HTTP_RES_ACT_ALLOW ||
|
||||
LIST_PREV(&curproxy->http_res_rules, struct act_rule *, list)->action == HTTP_RES_ACT_DENY)) {
|
||||
Warning("parsing [%s:%d]: previous '%s' action is final and has no condition attached, further entries are NOOP.\n",
|
||||
file, linenum, args[0]);
|
||||
err_code |= ERR_WARN;
|
||||
@ -3622,7 +3622,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
curproxy->server_id_hdr_len = strlen(curproxy->server_id_hdr_name);
|
||||
}
|
||||
else if (!strcmp(args[0], "block")) { /* early blocking based on ACLs */
|
||||
struct http_req_rule *rule;
|
||||
struct act_rule *rule;
|
||||
|
||||
if (curproxy == &defproxy) {
|
||||
Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
|
||||
@ -4144,7 +4144,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
goto out;
|
||||
}
|
||||
} else if (!strcmp(args[1], "http-request")) { /* request access control: allow/deny/auth */
|
||||
struct http_req_rule *rule;
|
||||
struct act_rule *rule;
|
||||
|
||||
if (curproxy == &defproxy) {
|
||||
Alert("parsing [%s:%d]: '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
|
||||
@ -4159,7 +4159,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
}
|
||||
|
||||
if (!LIST_ISEMPTY(&curproxy->uri_auth->http_req_rules) &&
|
||||
!LIST_PREV(&curproxy->uri_auth->http_req_rules, struct http_req_rule *, list)->cond) {
|
||||
!LIST_PREV(&curproxy->uri_auth->http_req_rules, struct act_rule *, list)->cond) {
|
||||
Warning("parsing [%s:%d]: previous '%s' action has no condition attached, further entries are NOOP.\n",
|
||||
file, linenum, args[0]);
|
||||
err_code |= ERR_WARN;
|
||||
@ -7152,8 +7152,8 @@ int check_config_validity()
|
||||
struct switching_rule *rule;
|
||||
struct server_rule *srule;
|
||||
struct sticking_rule *mrule;
|
||||
struct tcp_rule *trule;
|
||||
struct http_req_rule *hrqrule;
|
||||
struct act_rule *trule;
|
||||
struct act_rule *hrqrule;
|
||||
unsigned int next_id;
|
||||
int nbproc;
|
||||
|
||||
@ -7721,7 +7721,7 @@ int check_config_validity()
|
||||
|
||||
if (curproxy->uri_auth && curproxy->uri_auth->userlist && !(curproxy->uri_auth->flags & ST_CONVDONE)) {
|
||||
const char *uri_auth_compat_req[10];
|
||||
struct http_req_rule *rule;
|
||||
struct act_rule *rule;
|
||||
int i = 0;
|
||||
|
||||
/* build the ACL condition from scratch. We're relying on anonymous ACLs for that */
|
||||
|
@ -1130,7 +1130,7 @@ static void deinit_acl_cond(struct acl_cond *cond)
|
||||
|
||||
static void deinit_tcp_rules(struct list *rules)
|
||||
{
|
||||
struct tcp_rule *trule, *truleb;
|
||||
struct act_rule *trule, *truleb;
|
||||
|
||||
list_for_each_entry_safe(trule, truleb, rules, list) {
|
||||
LIST_DEL(&trule->list);
|
||||
|
28
src/hlua.c
28
src/hlua.c
@ -4379,20 +4379,20 @@ static int hlua_request_act_wrapper(struct hlua_rule *rule, struct proxy *px,
|
||||
/* Lua execution wrapper for "tcp-request". This function uses
|
||||
* "hlua_request_act_wrapper" for executing the LUA code.
|
||||
*/
|
||||
int hlua_tcp_req_act_wrapper(struct tcp_rule *tcp_rule, struct proxy *px,
|
||||
int hlua_tcp_req_act_wrapper(struct act_rule *act_rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s)
|
||||
{
|
||||
return hlua_request_act_wrapper((struct hlua_rule *)tcp_rule->act_prm.data[0],
|
||||
return hlua_request_act_wrapper((struct hlua_rule *)act_rule->arg.data,
|
||||
px, s, AN_REQ_INSPECT_FE);
|
||||
}
|
||||
|
||||
/* Lua execution wrapper for "tcp-response". This function uses
|
||||
* "hlua_request_act_wrapper" for executing the LUA code.
|
||||
*/
|
||||
int hlua_tcp_res_act_wrapper(struct tcp_rule *tcp_rule, struct proxy *px,
|
||||
int hlua_tcp_res_act_wrapper(struct act_rule *act_rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s)
|
||||
{
|
||||
return hlua_request_act_wrapper((struct hlua_rule *)tcp_rule->act_prm.data[0],
|
||||
return hlua_request_act_wrapper((struct hlua_rule *)act_rule->arg.data,
|
||||
px, s, AN_RES_INSPECT);
|
||||
}
|
||||
|
||||
@ -4400,8 +4400,8 @@ int hlua_tcp_res_act_wrapper(struct tcp_rule *tcp_rule, struct proxy *px,
|
||||
* This function uses "hlua_request_act_wrapper" for executing
|
||||
* the LUA code.
|
||||
*/
|
||||
int hlua_http_req_act_wrapper(struct http_req_rule *rule, struct proxy *px,
|
||||
struct stream *s)
|
||||
int hlua_http_req_act_wrapper(struct act_rule *rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s)
|
||||
{
|
||||
return hlua_request_act_wrapper((struct hlua_rule *)rule->arg.data, px,
|
||||
s, AN_REQ_HTTP_PROCESS_FE);
|
||||
@ -4411,8 +4411,8 @@ int hlua_http_req_act_wrapper(struct http_req_rule *rule, struct proxy *px,
|
||||
* This function uses "hlua_request_act_wrapper" for executing
|
||||
* the LUA code.
|
||||
*/
|
||||
int hlua_http_res_act_wrapper(struct http_res_rule *rule, struct proxy *px,
|
||||
struct stream *s)
|
||||
int hlua_http_res_act_wrapper(struct act_rule *rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s)
|
||||
{
|
||||
return hlua_request_act_wrapper((struct hlua_rule *)rule->arg.data, px,
|
||||
s, AN_RES_HTTP_PROCESS_BE);
|
||||
@ -4420,9 +4420,9 @@ int hlua_http_res_act_wrapper(struct http_res_rule *rule, struct proxy *px,
|
||||
|
||||
/* tcp-request <*> configuration wrapper. */
|
||||
static int tcp_req_action_register_lua(const char **args, int *cur_arg, struct proxy *px,
|
||||
struct tcp_rule *rule, char **err)
|
||||
struct act_rule *rule, char **err)
|
||||
{
|
||||
if (!hlua_parse_rule(args, cur_arg, px, (struct hlua_rule **)&rule->act_prm.data[0], err))
|
||||
if (!hlua_parse_rule(args, cur_arg, px, (struct hlua_rule **)&rule->arg.data, err))
|
||||
return 0;
|
||||
rule->action = TCP_ACT_CUSTOM_CONT;
|
||||
rule->action_ptr = hlua_tcp_req_act_wrapper;
|
||||
@ -4431,9 +4431,9 @@ static int tcp_req_action_register_lua(const char **args, int *cur_arg, struct p
|
||||
|
||||
/* tcp-response <*> configuration wrapper. */
|
||||
static int tcp_res_action_register_lua(const char **args, int *cur_arg, struct proxy *px,
|
||||
struct tcp_rule *rule, char **err)
|
||||
struct act_rule *rule, char **err)
|
||||
{
|
||||
if (!hlua_parse_rule(args, cur_arg, px, (struct hlua_rule **)&rule->act_prm.data[0], err))
|
||||
if (!hlua_parse_rule(args, cur_arg, px, (struct hlua_rule **)&rule->arg.data, err))
|
||||
return 0;
|
||||
rule->action = TCP_ACT_CUSTOM_CONT;
|
||||
rule->action_ptr = hlua_tcp_res_act_wrapper;
|
||||
@ -4442,7 +4442,7 @@ static int tcp_res_action_register_lua(const char **args, int *cur_arg, struct p
|
||||
|
||||
/* http-request <*> configuration wrapper. */
|
||||
static int http_req_action_register_lua(const char **args, int *cur_arg, struct proxy *px,
|
||||
struct http_req_rule *rule, char **err)
|
||||
struct act_rule *rule, char **err)
|
||||
{
|
||||
if (!hlua_parse_rule(args, cur_arg, px, (struct hlua_rule **)&rule->arg.data, err))
|
||||
return -1;
|
||||
@ -4453,7 +4453,7 @@ static int http_req_action_register_lua(const char **args, int *cur_arg, struct
|
||||
|
||||
/* http-response <*> configuration wrapper. */
|
||||
static int http_res_action_register_lua(const char **args, int *cur_arg, struct proxy *px,
|
||||
struct http_res_rule *rule, char **err)
|
||||
struct act_rule *rule, char **err)
|
||||
{
|
||||
if (!hlua_parse_rule(args, cur_arg, px, (struct hlua_rule **)&rule->arg.data, err))
|
||||
return -1;
|
||||
|
@ -3414,7 +3414,7 @@ http_req_get_intercept_rule(struct proxy *px, struct list *rules, struct stream
|
||||
struct session *sess = strm_sess(s);
|
||||
struct http_txn *txn = s->txn;
|
||||
struct connection *cli_conn;
|
||||
struct http_req_rule *rule;
|
||||
struct act_rule *rule;
|
||||
struct hdr_ctx ctx;
|
||||
const char *auth_realm;
|
||||
|
||||
@ -3631,14 +3631,14 @@ resume_execution:
|
||||
}
|
||||
|
||||
case HTTP_REQ_ACT_CUSTOM_CONT:
|
||||
if (!rule->action_ptr(rule, px, s)) {
|
||||
if (!rule->action_ptr(rule, px, s->sess, s)) {
|
||||
s->current_rule = rule;
|
||||
return HTTP_RULE_RES_YIELD;
|
||||
}
|
||||
break;
|
||||
|
||||
case HTTP_REQ_ACT_CUSTOM_STOP:
|
||||
rule->action_ptr(rule, px, s);
|
||||
rule->action_ptr(rule, px, s->sess, s);
|
||||
return HTTP_RULE_RES_DONE;
|
||||
|
||||
case HTTP_REQ_ACT_TRK_SC0 ... HTTP_REQ_ACT_TRK_SCMAX:
|
||||
@ -3718,7 +3718,7 @@ http_res_get_intercept_rule(struct proxy *px, struct list *rules, struct stream
|
||||
struct session *sess = strm_sess(s);
|
||||
struct http_txn *txn = s->txn;
|
||||
struct connection *cli_conn;
|
||||
struct http_res_rule *rule;
|
||||
struct act_rule *rule;
|
||||
struct hdr_ctx ctx;
|
||||
|
||||
/* If "the current_rule_list" match the executed rule list, we are in
|
||||
@ -3909,14 +3909,14 @@ resume_execution:
|
||||
return HTTP_RULE_RES_DONE;
|
||||
|
||||
case HTTP_RES_ACT_CUSTOM_CONT:
|
||||
if (!rule->action_ptr(rule, px, s)) {
|
||||
if (!rule->action_ptr(rule, px, s->sess, s)) {
|
||||
s->current_rule = rule;
|
||||
return HTTP_RULE_RES_YIELD;
|
||||
}
|
||||
break;
|
||||
|
||||
case HTTP_RES_ACT_CUSTOM_STOP:
|
||||
rule->action_ptr(rule, px, s);
|
||||
rule->action_ptr(rule, px, s->sess, s);
|
||||
return HTTP_RULE_RES_STOP;
|
||||
}
|
||||
}
|
||||
@ -8892,7 +8892,7 @@ void http_reset_txn(struct stream *s)
|
||||
|
||||
void free_http_res_rules(struct list *r)
|
||||
{
|
||||
struct http_res_rule *tr, *pr;
|
||||
struct act_rule *tr, *pr;
|
||||
|
||||
list_for_each_entry_safe(pr, tr, r, list) {
|
||||
LIST_DEL(&pr->list);
|
||||
@ -8903,7 +8903,7 @@ void free_http_res_rules(struct list *r)
|
||||
|
||||
void free_http_req_rules(struct list *r)
|
||||
{
|
||||
struct http_req_rule *tr, *pr;
|
||||
struct act_rule *tr, *pr;
|
||||
|
||||
list_for_each_entry_safe(pr, tr, r, list) {
|
||||
LIST_DEL(&pr->list);
|
||||
@ -8916,14 +8916,14 @@ void free_http_req_rules(struct list *r)
|
||||
}
|
||||
|
||||
/* parse an "http-request" rule */
|
||||
struct http_req_rule *parse_http_req_cond(const char **args, const char *file, int linenum, struct proxy *proxy)
|
||||
struct act_rule *parse_http_req_cond(const char **args, const char *file, int linenum, struct proxy *proxy)
|
||||
{
|
||||
struct http_req_rule *rule;
|
||||
struct act_rule *rule;
|
||||
struct http_req_action_kw *custom = NULL;
|
||||
int cur_arg;
|
||||
char *error;
|
||||
|
||||
rule = (struct http_req_rule*)calloc(1, sizeof(struct http_req_rule));
|
||||
rule = (struct act_rule*)calloc(1, sizeof(struct act_rule));
|
||||
if (!rule) {
|
||||
Alert("parsing [%s:%d]: out of memory.\n", file, linenum);
|
||||
goto out_err;
|
||||
@ -9389,9 +9389,9 @@ struct http_req_rule *parse_http_req_cond(const char **args, const char *file, i
|
||||
}
|
||||
|
||||
/* parse an "http-respose" rule */
|
||||
struct http_res_rule *parse_http_res_cond(const char **args, const char *file, int linenum, struct proxy *proxy)
|
||||
struct act_rule *parse_http_res_cond(const char **args, const char *file, int linenum, struct proxy *proxy)
|
||||
{
|
||||
struct http_res_rule *rule;
|
||||
struct act_rule *rule;
|
||||
struct http_res_action_kw *custom = NULL;
|
||||
int cur_arg;
|
||||
char *error;
|
||||
@ -12242,7 +12242,8 @@ int http_replace_req_line(int action, const char *replace, int len,
|
||||
* http_action_set_req_line_exec(). It always returns 1. If an error occurs
|
||||
* the action is canceled, but the rule processing continue.
|
||||
*/
|
||||
int http_action_set_req_line(struct http_req_rule *rule, struct proxy *px, struct stream *s)
|
||||
int http_action_set_req_line(struct act_rule *rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s)
|
||||
{
|
||||
chunk_reset(&trash);
|
||||
|
||||
@ -12266,7 +12267,7 @@ int http_action_set_req_line(struct http_req_rule *rule, struct proxy *px, struc
|
||||
* head, and p[2] to store the action as an int (0=method, 1=path, 2=query, 3=uri).
|
||||
* It returns 0 on success, < 0 on error.
|
||||
*/
|
||||
int parse_set_req_line(const char **args, int *orig_arg, struct proxy *px, struct http_req_rule *rule, char **err)
|
||||
int parse_set_req_line(const char **args, int *orig_arg, struct proxy *px, struct act_rule *rule, char **err)
|
||||
{
|
||||
int cur_arg = *orig_arg;
|
||||
|
||||
@ -12315,9 +12316,9 @@ int parse_set_req_line(const char **args, int *orig_arg, struct proxy *px, struc
|
||||
* returns 1. If an error occurs the action is cancelled, but the rule
|
||||
* processing continues.
|
||||
*/
|
||||
int http_action_req_capture(struct http_req_rule *rule, struct proxy *px, struct stream *s)
|
||||
int http_action_req_capture(struct act_rule *rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s)
|
||||
{
|
||||
struct session *sess = s->sess;
|
||||
struct sample *key;
|
||||
struct sample_expr *expr = rule->arg.act.p[0];
|
||||
struct cap_hdr *h = rule->arg.act.p[1];
|
||||
@ -12348,9 +12349,9 @@ int http_action_req_capture(struct http_req_rule *rule, struct proxy *px, struct
|
||||
* into a string and puts it in a capture slot. It always returns 1. If an
|
||||
* error occurs the action is cancelled, but the rule processing continues.
|
||||
*/
|
||||
int http_action_req_capture_by_id(struct http_req_rule *rule, struct proxy *px, struct stream *s)
|
||||
int http_action_req_capture_by_id(struct act_rule *rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s)
|
||||
{
|
||||
struct session *sess = s->sess;
|
||||
struct sample *key;
|
||||
struct sample_expr *expr = rule->arg.act.p[0];
|
||||
struct cap_hdr *h;
|
||||
@ -12391,7 +12392,7 @@ int http_action_req_capture_by_id(struct http_req_rule *rule, struct proxy *px,
|
||||
* the allocated hdr_cap struct or the preallocated "id" into arg->act.p[1].
|
||||
* It returns 0 on success, < 0 on error.
|
||||
*/
|
||||
int parse_http_req_capture(const char **args, int *orig_arg, struct proxy *px, struct http_req_rule *rule, char **err)
|
||||
int parse_http_req_capture(const char **args, int *orig_arg, struct proxy *px, struct act_rule *rule, char **err)
|
||||
{
|
||||
struct sample_expr *expr;
|
||||
struct cap_hdr *hdr;
|
||||
@ -12517,9 +12518,9 @@ int parse_http_req_capture(const char **args, int *orig_arg, struct proxy *px, s
|
||||
* into a string and puts it in a capture slot. It always returns 1. If an
|
||||
* error occurs the action is cancelled, but the rule processing continues.
|
||||
*/
|
||||
int http_action_res_capture_by_id(struct http_res_rule *rule, struct proxy *px, struct stream *s)
|
||||
int http_action_res_capture_by_id(struct act_rule *rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s)
|
||||
{
|
||||
struct session *sess = s->sess;
|
||||
struct sample *key;
|
||||
struct sample_expr *expr = rule->arg.act.p[0];
|
||||
struct cap_hdr *h;
|
||||
@ -12560,7 +12561,7 @@ int http_action_res_capture_by_id(struct http_res_rule *rule, struct proxy *px,
|
||||
* the allocated hdr_cap struct od the preallocated id into arg->act.p[1].
|
||||
* It returns 0 on success, < 0 on error.
|
||||
*/
|
||||
int parse_http_res_capture(const char **args, int *orig_arg, struct proxy *px, struct http_res_rule *rule, char **err)
|
||||
int parse_http_res_capture(const char **args, int *orig_arg, struct proxy *px, struct act_rule *rule, char **err)
|
||||
{
|
||||
struct sample_expr *expr;
|
||||
int cur_arg;
|
||||
|
@ -1102,7 +1102,7 @@ int tcp_pause_listener(struct listener *l)
|
||||
int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit)
|
||||
{
|
||||
struct session *sess = s->sess;
|
||||
struct tcp_rule *rule;
|
||||
struct act_rule *rule;
|
||||
struct stksess *ts;
|
||||
struct stktable *t;
|
||||
int partial;
|
||||
@ -1269,7 +1269,7 @@ resume_execution:
|
||||
int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
{
|
||||
struct session *sess = s->sess;
|
||||
struct tcp_rule *rule;
|
||||
struct act_rule *rule;
|
||||
int partial;
|
||||
|
||||
DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
|
||||
@ -1386,7 +1386,7 @@ resume_execution:
|
||||
*/
|
||||
int tcp_exec_req_rules(struct session *sess)
|
||||
{
|
||||
struct tcp_rule *rule;
|
||||
struct act_rule *rule;
|
||||
struct stksess *ts;
|
||||
struct stktable *t = NULL;
|
||||
struct connection *conn = objt_conn(sess->origin);
|
||||
@ -1457,7 +1457,7 @@ int tcp_exec_req_rules(struct session *sess)
|
||||
/* Parse a tcp-response rule. Return a negative value in case of failure */
|
||||
static int tcp_parse_response_rule(char **args, int arg, int section_type,
|
||||
struct proxy *curpx, struct proxy *defpx,
|
||||
struct tcp_rule *rule, char **err,
|
||||
struct act_rule *rule, char **err,
|
||||
unsigned int where,
|
||||
const char *file, int line)
|
||||
{
|
||||
@ -1516,7 +1516,7 @@ static int tcp_parse_response_rule(char **args, int arg, int section_type,
|
||||
/* Parse a tcp-request rule. Return a negative value in case of failure */
|
||||
static int tcp_parse_request_rule(char **args, int arg, int section_type,
|
||||
struct proxy *curpx, struct proxy *defpx,
|
||||
struct tcp_rule *rule, char **err,
|
||||
struct act_rule *rule, char **err,
|
||||
unsigned int where, const char *file, int line)
|
||||
{
|
||||
if (curpx == defpx) {
|
||||
@ -1729,7 +1729,7 @@ static int tcp_parse_tcp_rep(char **args, int section_type, struct proxy *curpx,
|
||||
unsigned int val;
|
||||
int warn = 0;
|
||||
int arg;
|
||||
struct tcp_rule *rule;
|
||||
struct act_rule *rule;
|
||||
unsigned int where;
|
||||
const struct acl *acl;
|
||||
const char *kw;
|
||||
@ -1835,7 +1835,7 @@ static int tcp_parse_tcp_req(char **args, int section_type, struct proxy *curpx,
|
||||
unsigned int val;
|
||||
int warn = 0;
|
||||
int arg;
|
||||
struct tcp_rule *rule;
|
||||
struct act_rule *rule;
|
||||
unsigned int where;
|
||||
const struct acl *acl;
|
||||
const char *kw;
|
||||
|
@ -1413,7 +1413,6 @@ static int sample_conv_table_trackers(const struct arg *arg_p, struct sample *sm
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Note: must not be declared <const> as its list will be overwritten */
|
||||
static struct sample_conv_kw_list sample_conv_kws = {ILH, {
|
||||
{ "in_table", sample_conv_in_table, ARG1(1,TAB), NULL, SMP_T_STR, SMP_T_BOOL },
|
||||
|
56
src/vars.c
56
src/vars.c
@ -499,30 +499,32 @@ static inline int action_store(struct sample_expr *expr, const char *name,
|
||||
}
|
||||
|
||||
/* Wrapper for action_store */
|
||||
static int action_tcp_req_store(struct tcp_rule *rule, struct proxy *px,
|
||||
static int action_tcp_req_store(struct act_rule *rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s)
|
||||
{
|
||||
return action_store(rule->act_prm.data[0], rule->act_prm.data[1],
|
||||
(long)rule->act_prm.data[2], px, s, SMP_OPT_DIR_REQ);
|
||||
}
|
||||
|
||||
/* Wrapper for action_store */
|
||||
static int action_tcp_res_store(struct tcp_rule *rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s)
|
||||
{
|
||||
return action_store(rule->act_prm.data[0], rule->act_prm.data[1],
|
||||
(long)rule->act_prm.data[2], px, s, SMP_OPT_DIR_RES);
|
||||
}
|
||||
|
||||
/* Wrapper for action_store */
|
||||
static int action_http_req_store(struct http_req_rule *rule, struct proxy *px, struct stream *s)
|
||||
{
|
||||
return action_store(rule->arg.act.p[0], rule->arg.act.p[1],
|
||||
(long)rule->arg.act.p[2], px, s, SMP_OPT_DIR_REQ);
|
||||
}
|
||||
|
||||
/* Wrapper for action_store */
|
||||
static int action_http_res_store(struct http_res_rule *rule, struct proxy *px, struct stream *s)
|
||||
static int action_tcp_res_store(struct act_rule *rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s)
|
||||
{
|
||||
return action_store(rule->arg.act.p[0], rule->arg.act.p[1],
|
||||
(long)rule->arg.act.p[2], px, s, SMP_OPT_DIR_RES);
|
||||
}
|
||||
|
||||
/* Wrapper for action_store */
|
||||
static int action_http_req_store(struct act_rule *rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s)
|
||||
{
|
||||
return action_store(rule->arg.act.p[0], rule->arg.act.p[1],
|
||||
(long)rule->arg.act.p[2], px, s, SMP_OPT_DIR_REQ);
|
||||
}
|
||||
|
||||
/* Wrapper for action_store */
|
||||
static int action_http_res_store(struct act_rule *rule, struct proxy *px,
|
||||
struct session *sess, struct stream *s)
|
||||
{
|
||||
return action_store(rule->arg.act.p[0], rule->arg.act.p[1],
|
||||
(long)rule->arg.act.p[2], px, s, SMP_OPT_DIR_RES);
|
||||
@ -601,12 +603,12 @@ static int parse_vars(const char **args, int *arg, struct proxy *px,
|
||||
|
||||
/* Wrapper for parse_vars */
|
||||
static int parse_tcp_req_store(const char **args, int *arg, struct proxy *px,
|
||||
struct tcp_rule *rule, char **err)
|
||||
struct act_rule *rule, char **err)
|
||||
{
|
||||
if (!parse_vars(args, arg, px, SMP_VAL_FE_REQ_CNT, err,
|
||||
(struct sample_expr **)&rule->act_prm.data[0],
|
||||
(char **)&rule->act_prm.data[1],
|
||||
(enum vars_scope *)&rule->act_prm.data[2]))
|
||||
(struct sample_expr **)&rule->arg.act.p[0],
|
||||
(char **)&rule->arg.act.p[1],
|
||||
(enum vars_scope *)&rule->arg.act.p[2]))
|
||||
return 0;
|
||||
rule->action = TCP_ACT_CUSTOM_CONT;
|
||||
rule->action_ptr = action_tcp_req_store;
|
||||
@ -615,12 +617,12 @@ static int parse_tcp_req_store(const char **args, int *arg, struct proxy *px,
|
||||
|
||||
/* Wrapper for parse_vars */
|
||||
static int parse_tcp_res_store(const char **args, int *arg, struct proxy *px,
|
||||
struct tcp_rule *rule, char **err)
|
||||
struct act_rule *rule, char **err)
|
||||
{
|
||||
if (!parse_vars(args, arg, px, SMP_VAL_BE_RES_CNT, err,
|
||||
(struct sample_expr **)&rule->act_prm.data[0],
|
||||
(char **)&rule->act_prm.data[1],
|
||||
(enum vars_scope *)&rule->act_prm.data[2]))
|
||||
(struct sample_expr **)&rule->arg.act.p[0],
|
||||
(char **)&rule->arg.act.p[1],
|
||||
(enum vars_scope *)&rule->arg.act.p[2]))
|
||||
return 0;
|
||||
rule->action = TCP_ACT_CUSTOM_CONT;
|
||||
rule->action_ptr = action_tcp_res_store;
|
||||
@ -629,7 +631,7 @@ static int parse_tcp_res_store(const char **args, int *arg, struct proxy *px,
|
||||
|
||||
/* Wrapper for parse_vars */
|
||||
static int parse_http_req_store(const char **args, int *arg, struct proxy *px,
|
||||
struct http_req_rule *rule, char **err)
|
||||
struct act_rule *rule, char **err)
|
||||
{
|
||||
if (!parse_vars(args, arg, px, SMP_VAL_FE_HRQ_HDR, err,
|
||||
(struct sample_expr **)&rule->arg.act.p[0],
|
||||
@ -643,7 +645,7 @@ static int parse_http_req_store(const char **args, int *arg, struct proxy *px,
|
||||
|
||||
/* Wrapper for parse_vars */
|
||||
static int parse_http_res_store(const char **args, int *arg, struct proxy *px,
|
||||
struct http_res_rule *rule, char **err)
|
||||
struct act_rule *rule, char **err)
|
||||
{
|
||||
if (!parse_vars(args, arg, px, SMP_VAL_BE_HRS_HDR, err,
|
||||
(struct sample_expr **)&rule->arg.act.p[0],
|
||||
|
Loading…
Reference in New Issue
Block a user