From: David Carlier Date: Mon, 1 Jun 2015 11:54:29 +0000 (+0200) Subject: MEDIUM: sample: add the da-csv converter X-Git-Tag: v1.6-dev2~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4542b10ae198168a3b94213ef5a9b21a7646eb21;p=thirdparty%2Fhaproxy.git MEDIUM: sample: add the da-csv converter This diff declares the deviceatlas module and can accept up to 5 property names for the API lookup. [wt: this should probably be moved to its own file using the keyword registration mechanism] --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 9c78145273..adfb26f9c6 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -10728,6 +10728,20 @@ crc32([]) not be used for security purposes as a 32-bit hash is trivial to break. See also "djb2", "sdbm", "wt6" and the "hash-type" directive. +da-csv([,*]) + Asks the DeviceAtlas converter to identify the User Agent string passed on + input, and to emit a string made of the concatenation of the properties + enumerated in argument, delimited by the separator defined by the global + keyword "deviceatlas-property-separator", or by default the pipe character + ('|'). There's a limit of 5 different properties imposed by the haproxy + configuration language. + + Example: + frontend www + bind *:8881 + default_backend servers + http-request set-header X-DeviceAtlas-Data %[req.fhdr(User-Agent),da-csv(primaryHardwareType,osName,osVersion,browserName,browserVersion)] + div() Divides the input value of type unsigned integer by , and returns the result as an unsigned integer. If is null, the largest unsigned diff --git a/src/sample.c b/src/sample.c index 47d48c8ba9..59fa15812a 100644 --- a/src/sample.c +++ b/src/sample.c @@ -32,6 +32,10 @@ #include #include +#ifdef USE_DEVICEATLAS +#include +#endif + /* sample type names */ const char *smp_to_type[SMP_TYPES] = { [SMP_T_BOOL] = "bool", @@ -2278,6 +2282,9 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, { { "div", sample_conv_arith_div, ARG1(1,UINT), NULL, SMP_T_UINT, SMP_T_UINT }, { "mod", sample_conv_arith_mod, ARG1(1,UINT), NULL, SMP_T_UINT, SMP_T_UINT }, { "neg", sample_conv_arith_neg, 0, NULL, SMP_T_UINT, SMP_T_UINT }, +#ifdef USE_DEVICEATLAS + { "da-csv", da_haproxy, ARG5(1,STR,STR,STR,STR,STR), NULL, SMP_T_STR, SMP_T_STR }, +#endif { NULL, NULL, 0, 0, 0 }, }};