From 5563e4b4696bd3e1b833fb42c2cda5f9d85e91f0 Mon Sep 17 00:00:00 2001 From: Thierry FOURNIER Date: Fri, 14 Aug 2015 19:20:07 +0200 Subject: [PATCH] MINOR: actions: add "from" information This struct member is used to specify who is the rule caller. It permits to use one function for differents callers. --- include/types/action.h | 9 +++++++++ src/proto_http.c | 2 ++ src/proto_tcp.c | 8 ++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/types/action.h b/include/types/action.h index 84454e41e..77ce92814 100644 --- a/include/types/action.h +++ b/include/types/action.h @@ -24,10 +24,19 @@ #include +enum act_from { + ACT_F_TCP_REQ_CON, /* tcp-request connection */ + ACT_F_TCP_REQ_CNT, /* tcp-request content */ + ACT_F_TCP_RES_CNT, /* tcp-response content */ + ACT_F_HTTP_REQ, /* http-request */ + ACT_F_HTTP_RES, /* http-response */ +}; + struct act_rule { struct list list; struct acl_cond *cond; /* acl condition to meet */ unsigned int action; /* HTTP_REQ_* */ + enum act_from from; /* ACT_F_* */ 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 */ diff --git a/src/proto_http.c b/src/proto_http.c index aa01361f9..6571fdaef 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -9351,6 +9351,7 @@ struct act_rule *parse_http_req_cond(const char **args, const char *file, int li char *errmsg = NULL; cur_arg = 1; /* try in the module list */ + rule->from = ACT_F_HTTP_REQ; if (custom->parse(args, &cur_arg, proxy, rule, &errmsg) < 0) { Alert("parsing [%s:%d] : error detected in %s '%s' while parsing 'http-request %s' rule : %s.\n", file, linenum, proxy_type_str(proxy), proxy->id, args[0], errmsg); @@ -9706,6 +9707,7 @@ struct act_rule *parse_http_res_cond(const char **args, const char *file, int li char *errmsg = NULL; cur_arg = 1; /* try in the module list */ + rule->from = ACT_F_HTTP_RES; if (custom->parse(args, &cur_arg, proxy, rule, &errmsg) < 0) { Alert("parsing [%s:%d] : error detected in %s '%s' while parsing 'http-response %s' rule : %s.\n", file, linenum, proxy_type_str(proxy), proxy->id, args[0], errmsg); diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 42f561997..2dab423e8 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -1484,6 +1484,7 @@ static int tcp_parse_response_rule(char **args, int arg, int section_type, kw = tcp_res_cont_action(args[arg]); if (kw) { arg++; + rule->from = ACT_F_TCP_RES_CNT; if (!kw->parse((const char **)args, &arg, curpx, rule, err)) return -1; } else { @@ -1683,10 +1684,13 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type, } else { struct tcp_action_kw *kw; - if (where & SMP_VAL_FE_CON_ACC) + if (where & SMP_VAL_FE_CON_ACC) { kw = tcp_req_conn_action(args[arg]); - else + rule->from = ACT_F_TCP_REQ_CON; + } else { kw = tcp_req_cont_action(args[arg]); + rule->from = ACT_F_TCP_REQ_CNT; + } if (kw) { arg++; if (!kw->parse((const char **)args, &arg, curpx, rule, err))