]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: actions: add "from" information
authorThierry FOURNIER <tfournier@arpalert.org>
Fri, 14 Aug 2015 17:20:07 +0000 (19:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 20 Aug 2015 15:13:47 +0000 (17:13 +0200)
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
src/proto_http.c
src/proto_tcp.c

index 84454e41e3feb3a62f76f9672426950d15407938..77ce92814e709916872e0e4f06688bcf620c82fd 100644 (file)
 
 #include <types/stick_table.h>
 
+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 */
index aa01361f9b2b850168c220608b3b8adafb1d2d21..6571fdaef79df1e8b7715bac142c68abd69918a8 100644 (file)
@@ -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);
index 42f5619978875c2315359249e5e41befdb7196a2..2dab423e8374da796df9c49205940263fdcfe8d7 100644 (file)
@@ -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))