]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: sample: add the da-csv converter
authorDavid Carlier <dcarlier@afilias.info>
Mon, 1 Jun 2015 11:54:29 +0000 (13:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 2 Jun 2015 11:24:50 +0000 (13:24 +0200)
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]

doc/configuration.txt
src/sample.c

index 9c781452738af77162e36817b93a55d470332a52..adfb26f9c609bc469eeaadd36a9f35b353e3649b 100644 (file)
@@ -10728,6 +10728,20 @@ crc32([<avalanche>])
   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(<prop>[,<prop>*])
+  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(<value>)
   Divides the input value of type unsigned integer by <value>, and returns the
   result as an unsigned integer. If <value> is null, the largest unsigned
index 47d48c8ba9e526bc1f605b3f2d5b1b61e2d07e01..59fa15812a2ec7c8e51527c1d18279c7dcd7a066 100644 (file)
 #include <proto/sample.h>
 #include <proto/stick_table.h>
 
+#ifdef USE_DEVICEATLAS
+#include <import/da.h>
+#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 },
 }};