[MEDIUM] add support for URI hash depth and length limits
This patch adds two optional arguments "len" and "depth" to
"balance uri". They are used to limit the length in characters
of the analysis, as well as the number of directory components
it applies to.
diff --git a/include/proto/backend.h b/include/proto/backend.h
index 03fa518..aa27654 100644
--- a/include/proto/backend.h
+++ b/include/proto/backend.h
@@ -159,6 +159,7 @@
{
unsigned long hash = 0;
int c;
+ int slashes = 0;
if (px->lbprm.tot_weight == 0)
return NULL;
@@ -166,10 +167,19 @@
if (px->lbprm.map.state & PR_MAP_RECALC)
recalc_server_map(px);
+ if (px->uri_len_limit)
+ uri_len = MIN(uri_len, px->uri_len_limit);
+
while (uri_len--) {
c = *uri++;
- if (c == '?')
+ if (c == '/') {
+ slashes++;
+ if (slashes == px->uri_dirs_depth1) /* depth+1 */
+ break;
+ }
+ else if (c == '?')
break;
+
hash = c + (hash << 6) + (hash << 16) - hash;
}
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 091be57..fe69b08 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -166,6 +166,8 @@
char *url_param_name; /* name of the URL parameter used for hashing */
int url_param_len; /* strlen(url_param_name), computed only once */
unsigned url_param_post_limit; /* if checking POST body for URI parameter, max body to wait for */
+ int uri_len_limit; /* character limit for uri balancing algorithm */
+ int uri_dirs_depth1; /* directories+1 (slashes) limit for uri balancing algorithm */
char *appsession_name; /* name of the cookie to look for */
int appsession_name_len; /* strlen(appsession_name), computed only once */
int appsession_len; /* length of the appsession cookie value to be used */