]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] add the 'acl' keyword to the config language
authorWilly Tarreau <w@1wt.eu>
Sun, 6 May 2007 22:53:22 +0000 (00:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 May 2007 21:24:50 +0000 (23:24 +0200)
The 'acl' keyword allows one to declare a new ACL. It is an important part
of the ACL framework.

include/types/proxy.h
src/cfgparse.c

index e446ed9e114dad5e9716eda87bd90e4503fb52d9..6a96f94b9c354084eac60ec3ac26b585f4556d7a 100644 (file)
@@ -34,6 +34,7 @@
 #include <common/regex.h>
 #include <common/tools.h>
 
+#include <types/acl.h>
 #include <types/buffers.h>
 #include <types/httperr.h>
 #include <types/session.h>
@@ -82,6 +83,7 @@ struct proxy {
                struct proxy *be;               /* default backend, or NULL if none set */
                char *name;                     /* default backend name during config parse */
        } defbe;
+       struct list acl;                        /* ACL declared on this proxy */
        struct server *srv;                     /* known servers */
        int srv_act, srv_bck;                   /* # of running servers */
        int tot_wact, tot_wbck;                 /* total weights of active and backup servers */
index c5d17440f5ed98de76e2791eab52cd7450b300f4..c4c6c8c273aff786f4b4ac85edf764bdf892a9b9 100644 (file)
@@ -33,6 +33,7 @@
 #include <types/proxy.h>
 #include <types/queue.h>
 
+#include <proto/acl.h>
 #include <proto/backend.h>
 #include <proto/buffers.h>
 #include <proto/checks.h>
@@ -492,6 +493,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args)
                curproxy->next = proxy;
                proxy = curproxy;
                LIST_INIT(&curproxy->pendconns);
+               LIST_INIT(&curproxy->acl);
 
                curproxy->id = strdup(args[1]);
                curproxy->cap = rc;
@@ -667,6 +669,13 @@ int cfg_parse_listen(const char *file, int linenum, char **args)
        else if (!strcmp(args[0], "enabled")) {  /* enables this proxy (used to revert a disabled default) */
                curproxy->state = PR_STNEW;
        }
+       else if (!strcmp(args[0], "acl")) {  /* add an ACL */
+               if (parse_acl((const char **)args + 1, &curproxy->acl) == NULL) {
+                       Alert("parsing [%s:%d] : error detected while parsing ACL '%s'.\n",
+                             file, linenum, args[1]);
+                       return -1;
+               }
+       }
        else if (!strcmp(args[0], "cookie")) {  /* cookie name */
                int cur_arg;
                //        if (curproxy == &defproxy) {