MINOR: http: add the urlp_val ACL match

It's derived from other urlp_* matches, but there was no way to check for
an integer value and it seems like it's significantly used.
This commit is contained in:
Willy Tarreau 2012-07-31 07:51:48 +02:00
parent 491c498d97
commit a9fddca778
2 changed files with 24 additions and 0 deletions

View File

@ -8342,6 +8342,12 @@ urlp_sub(<name>) <string>
can be used to detect particular patterns in query strings for example. See can be used to detect particular patterns in query strings for example. See
also "path_sub" and other "urlp_" criteria. also "path_sub" and other "urlp_" criteria.
urlp_val(<name>) <integer>
Returns true when the URL parameter "<name>" starts with a number matching
the values or ranges specified. Note that the absence of the parameter does
not match anything. Integers are unsigned so it is not possible to match
negative data.
7.6. Pre-defined ACLs 7.6. Pre-defined ACLs
--------------------- ---------------------

View File

@ -8548,6 +8548,23 @@ smp_fetch_url_param(struct proxy *px, struct session *l4, void *l7, unsigned int
return 1; return 1;
} }
/* Return the signed integer value for the specified url parameter (see url_param
* above).
*/
static int
smp_fetch_url_param_val(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
int ret = smp_fetch_url_param(px, l4, l7, opt, args, smp);
if (ret > 0) {
smp->type = SMP_T_UINT;
smp->data.uint = strl2ic(smp->data.str.str, smp->data.str.len);
}
return ret;
}
/* This function is used to validate the arguments passed to any "hdr" fetch /* This function is used to validate the arguments passed to any "hdr" fetch
* keyword. These keywords support an optional positive or negative occurrence * keyword. These keywords support an optional positive or negative occurrence
* number. We must ensure that the number is greater than -MAX_HDR_HISTORY. It * number. We must ensure that the number is greater than -MAX_HDR_HISTORY. It
@ -8670,6 +8687,7 @@ static struct acl_kw_list acl_kws = {{ },{
{ "urlp_len", acl_parse_int, smp_fetch_url_param, acl_match_len, ACL_USE_L7REQ_VOLATILE, ARG1(1,STR) }, { "urlp_len", acl_parse_int, smp_fetch_url_param, acl_match_len, ACL_USE_L7REQ_VOLATILE, ARG1(1,STR) },
{ "urlp_reg", acl_parse_reg, smp_fetch_url_param, acl_match_reg, ACL_USE_L7REQ_VOLATILE, ARG1(1,STR) }, { "urlp_reg", acl_parse_reg, smp_fetch_url_param, acl_match_reg, ACL_USE_L7REQ_VOLATILE, ARG1(1,STR) },
{ "urlp_sub", acl_parse_str, smp_fetch_url_param, acl_match_sub, ACL_USE_L7REQ_VOLATILE, ARG1(1,STR) }, { "urlp_sub", acl_parse_str, smp_fetch_url_param, acl_match_sub, ACL_USE_L7REQ_VOLATILE, ARG1(1,STR) },
{ "urlp_val", acl_parse_int, smp_fetch_url_param_val, acl_match_int, ACL_USE_L7REQ_VOLATILE, ARG1(1,STR) },
{ NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL },
}}; }};