]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] cookie: add options "maxidle" and "maxlife"
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Oct 2010 14:59:56 +0000 (16:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 30 Oct 2010 17:04:32 +0000 (19:04 +0200)
Add two new arguments to the "cookie" keyword, to be able to
fix a max idle and max life on them. Right now only the parameter
parsing is implemented.
(cherry picked from commit 9ad5dec4c3bb8f29129f292cb22d3fc495fcc98a)

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

index 46b61a2e3e494173246230d22d1dbf1e94fd95ff..246a9bed8e986155ffd1d93de2e5368bf726a083 100644 (file)
@@ -200,6 +200,8 @@ struct proxy {
        char *cookie_domain;                    /* domain used to insert the cookie */
        char *cookie_name;                      /* name of the cookie to look for */
        int  cookie_len;                        /* strlen(cookie_name), computed only once */
+       unsigned int cookie_maxidle;            /* max idle time for this cookie */
+       unsigned int cookie_maxlife;            /* max life time for this cookie */
        char *rdp_cookie_name;                  /* name of the RDP cookie to look for */
        int  rdp_cookie_len;                    /* strlen(rdp_cookie_name), computed only once */
        char *url_param_name;                   /* name of the URL parameter used for hashing */
index 3cf1e4af0d424b66836f5c3b8202920686a6d5c3..ef2d9ca10c2dae7018eec7adc41a8e1633c577eb 100644 (file)
@@ -1179,6 +1179,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                        if (defproxy.cookie_domain)
                                curproxy->cookie_domain = strdup(defproxy.cookie_domain);
 
+                       if (defproxy.cookie_maxidle)
+                               curproxy->cookie_maxidle = defproxy.cookie_maxidle;
+
+                       if (defproxy.cookie_maxlife)
+                               curproxy->cookie_maxlife = defproxy.cookie_maxlife;
+
                        if (defproxy.rdp_cookie_name)
                                 curproxy->rdp_cookie_name = strdup(defproxy.rdp_cookie_name);
                        curproxy->rdp_cookie_len = defproxy.rdp_cookie_len;
@@ -1719,8 +1725,50 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                                }
                                cur_arg++;
                        }
+                       else if (!strcmp(args[cur_arg], "maxidle")) {
+                               unsigned int maxidle;
+                               const char *res;
+
+                               if (!*args[cur_arg + 1]) {
+                                       Alert("parsing [%s:%d]: '%s' expects <idletime> in seconds as argument.\n",
+                                               file, linenum, args[cur_arg]);
+                                       err_code |= ERR_ALERT | ERR_FATAL;
+                                       goto out;
+                               }
+
+                               res = parse_time_err(args[cur_arg + 1], &maxidle, TIME_UNIT_S);
+                               if (res) {
+                                       Alert("parsing [%s:%d]: unexpected character '%c' in argument to <%s>.\n",
+                                             file, linenum, *res, args[cur_arg]);
+                                       err_code |= ERR_ALERT | ERR_FATAL;
+                                       goto out;
+                               }
+                               curproxy->cookie_maxidle = maxidle;
+                               cur_arg++;
+                       }
+                       else if (!strcmp(args[cur_arg], "maxlife")) {
+                               unsigned int maxlife;
+                               const char *res;
+
+                               if (!*args[cur_arg + 1]) {
+                                       Alert("parsing [%s:%d]: '%s' expects <lifetime> in seconds as argument.\n",
+                                               file, linenum, args[cur_arg]);
+                                       err_code |= ERR_ALERT | ERR_FATAL;
+                                       goto out;
+                               }
+
+                               res = parse_time_err(args[cur_arg + 1], &maxlife, TIME_UNIT_S);
+                               if (res) {
+                                       Alert("parsing [%s:%d]: unexpected character '%c' in argument to <%s>.\n",
+                                             file, linenum, *res, args[cur_arg]);
+                                       err_code |= ERR_ALERT | ERR_FATAL;
+                                       goto out;
+                               }
+                               curproxy->cookie_maxlife = maxlife;
+                               cur_arg++;
+                       }
                        else {
-                               Alert("parsing [%s:%d] : '%s' supports 'rewrite', 'insert', 'prefix', 'indirect', 'nocache' and 'postonly', 'domain' options.\n",
+                               Alert("parsing [%s:%d] : '%s' supports 'rewrite', 'insert', 'prefix', 'indirect', 'nocache', 'postonly', 'domain', 'maxidle, and 'maxlife' options.\n",
                                      file, linenum, args[0]);
                                err_code |= ERR_ALERT | ERR_FATAL;
                                goto out;