MINOR: acl/pattern: Acl "-M" option force to load file as map file with two columns

This commit is contained in:
Thierry FOURNIER 2014-01-29 14:23:29 +01:00 committed by Willy Tarreau
parent c0bd9100eb
commit 9860c41258
2 changed files with 13 additions and 1 deletions

View File

@ -8909,6 +8909,7 @@ The following ACL flags are currently supported :
-i : ignore case during matching of all subsequent patterns.
-f : load patterns from a file.
-m : use a specific pattern matching method
-M : load the file pointed by -f like a map file.
-u : force the unique id of the ACL
-- : force end of flags. Useful when a string looks like one of the flags.
@ -8922,6 +8923,12 @@ a comment. Depending on the data type and match method, haproxy may load the
lines into a binary tree, allowing very fast lookups. This is true for IPv4 and
exact string matching. In this case, duplicates will automatically be removed.
The "-M" flag allows an ACL to use a map file. If this flag is set, the file is
parsed as two column file. The first column contains the patterns used by the
ACL, and the second column contain the samples. The sample can be used later by
a map. This can be useful in some rare cases where an ACL would just be used to
check for the existence of a pattern in a map before a mapping is applied.
The "-u" flag forces the unique id of the ACL. This unique id is used with the
socket interface to identify ACL and dynamically change its values. Note that a
file is always identified by its name even if an id is set.

View File

@ -160,6 +160,7 @@ struct acl_expr *parse_acl_expr(const char **args, char **err, struct arg_list *
char *error;
struct pat_ref *ref;
struct pattern_expr *pattern_expr;
int load_as_map = 0;
/* First, we look for an ACL keyword. And if we don't find one, then
* we look for a sample fetch expression starting with a sample fetch
@ -417,6 +418,7 @@ struct acl_expr *parse_acl_expr(const char **args, char **err, struct arg_list *
* -i : ignore case for all patterns by default
* -f : read patterns from those files
* -m : force matching method (must be used before -f)
* -M : load the file as map file
* -u : force the unique id of the acl
* -- : everything after this is not an option
*/
@ -451,7 +453,7 @@ struct acl_expr *parse_acl_expr(const char **args, char **err, struct arg_list *
snprintf(trash.str, trash.size, "acl(s) loaded from file '%s'", args[1]);
trash.str[trash.size - 1] = '\0';
if (!pattern_read_from_file(&expr->pat, PAT_REF_ACL, args[1], patflags | PAT_F_FROM_FILE, 0, err, trash.str))
if (!pattern_read_from_file(&expr->pat, PAT_REF_ACL, args[1], patflags | PAT_F_FROM_FILE, load_as_map, err, trash.str))
goto out_free_expr;
is_loaded = 1;
args++;
@ -483,6 +485,9 @@ struct acl_expr *parse_acl_expr(const char **args, char **err, struct arg_list *
expr->pat.expect_type = pat_match_types[idx];
args++;
}
else if ((*args)[1] == 'M') {
load_as_map = 1;
}
else if ((*args)[1] == '-') {
args++;
break;