blob: 701709553bf4f47e5e9dee02d40a0631174836ed [file] [log] [blame]
Dragan Dosen93b38d92015-06-29 16:43:25 +02001#include <stdio.h>
2
3#include <common/cfgparse.h>
4#include <common/chunk.h>
James Rosewella28bbd52015-09-18 18:28:52 +01005#include <common/buffer.h>
Willy Tarreau9f3f2542016-12-21 20:30:05 +01006#include <common/errors.h>
Ben51Degrees4ddf59d2019-02-05 13:24:00 +00007#include <common/hathreads.h>
Willy Tarreau0108d902018-11-25 19:14:37 +01008#include <common/initcall.h>
Willy Tarreau80713382018-11-26 10:19:54 +01009#include <types/global.h>
Dragan Dosen93b38d92015-06-29 16:43:25 +020010#include <proto/arg.h>
Willy Tarreau79e57332018-10-02 16:01:16 +020011#include <proto/http_fetch.h>
Dragan Dosen93b38d92015-06-29 16:43:25 +020012#include <proto/log.h>
James Rosewella28bbd52015-09-18 18:28:52 +010013#include <proto/proto_http.h>
Dragan Dosen93b38d92015-06-29 16:43:25 +020014#include <proto/sample.h>
15#include <import/xxhash.h>
Dragan Dosen105c8e62015-06-29 16:43:26 +020016#include <import/lru.h>
Willy Tarreaub7a67142016-12-21 21:18:44 +010017#include <51Degrees.h>
Dragan Dosen93b38d92015-06-29 16:43:25 +020018
19struct _51d_property_names {
20 struct list list;
21 char *name;
22};
23
James Rosewella28bbd52015-09-18 18:28:52 +010024#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
Dragan Dosen105c8e62015-06-29 16:43:26 +020025static struct lru64_head *_51d_lru_tree = NULL;
26static unsigned long long _51d_lru_seed;
Ben51Degrees4ddf59d2019-02-05 13:24:00 +000027
28__decl_spinlock(_51d_lru_lock);
James Rosewella28bbd52015-09-18 18:28:52 +010029#endif
Dragan Dosen105c8e62015-06-29 16:43:26 +020030
Willy Tarreaub7a67142016-12-21 21:18:44 +010031static struct {
32 char property_separator; /* the separator to use in the response for the values. this is taken from 51degrees-property-separator from config. */
33 struct list property_names; /* list of properties to load into the data set. this is taken from 51degrees-property-name-list from config. */
34 char *data_file_path;
35 int header_count; /* number of HTTP headers related to device detection. */
Willy Tarreau83061a82018-07-13 11:56:34 +020036 struct buffer *header_names; /* array of HTTP header names. */
Willy Tarreaub7a67142016-12-21 21:18:44 +010037 fiftyoneDegreesDataSet data_set; /* data set used with the pattern and trie detection methods. */
38#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
39 fiftyoneDegreesWorksetPool *pool; /* pool of worksets to avoid creating a new one for each request. */
40#endif
41#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
42 int32_t *header_offsets; /* offsets to the HTTP header name string. */
Ben51Degrees4ddf59d2019-02-05 13:24:00 +000043#ifdef FIFTYONEDEGREES_NO_THREADING
Willy Tarreaub7a67142016-12-21 21:18:44 +010044 fiftyoneDegreesDeviceOffsets device_offsets; /* Memory used for device offsets. */
45#endif
Ben51Degrees4ddf59d2019-02-05 13:24:00 +000046#endif
Willy Tarreaub7a67142016-12-21 21:18:44 +010047 int cache_size;
48} global_51degrees = {
49 .property_separator = ',',
50 .property_names = LIST_HEAD_INIT(global_51degrees.property_names),
51 .data_file_path = NULL,
52#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
53 .data_set = { },
54#endif
55 .cache_size = 0,
56};
57
Dragan Dosen93b38d92015-06-29 16:43:25 +020058static int _51d_data_file(char **args, int section_type, struct proxy *curpx,
59 struct proxy *defpx, const char *file, int line,
60 char **err)
61{
62 if (*(args[1]) == 0) {
63 memprintf(err,
64 "'%s' expects a filepath to a 51Degrees trie or pattern data file.",
65 args[0]);
66 return -1;
67 }
68
Willy Tarreaub7a67142016-12-21 21:18:44 +010069 if (global_51degrees.data_file_path)
70 free(global_51degrees.data_file_path);
71 global_51degrees.data_file_path = strdup(args[1]);
Dragan Dosen93b38d92015-06-29 16:43:25 +020072
73 return 0;
74}
75
76static int _51d_property_name_list(char **args, int section_type, struct proxy *curpx,
James Rosewella28bbd52015-09-18 18:28:52 +010077 struct proxy *defpx, const char *file, int line,
78 char **err)
Dragan Dosen93b38d92015-06-29 16:43:25 +020079{
80 int cur_arg = 1;
81 struct _51d_property_names *name;
82
83 if (*(args[cur_arg]) == 0) {
84 memprintf(err,
85 "'%s' expects at least one 51Degrees property name.",
86 args[0]);
87 return -1;
88 }
89
90 while (*(args[cur_arg])) {
Vincent Bernat02779b62016-04-03 13:48:43 +020091 name = calloc(1, sizeof(*name));
Dragan Dosen93b38d92015-06-29 16:43:25 +020092 name->name = strdup(args[cur_arg]);
Willy Tarreaub7a67142016-12-21 21:18:44 +010093 LIST_ADDQ(&global_51degrees.property_names, &name->list);
Dragan Dosen93b38d92015-06-29 16:43:25 +020094 ++cur_arg;
95 }
96
97 return 0;
98}
99
100static int _51d_property_separator(char **args, int section_type, struct proxy *curpx,
101 struct proxy *defpx, const char *file, int line,
102 char **err)
103{
104 if (*(args[1]) == 0) {
105 memprintf(err,
106 "'%s' expects a single character.",
107 args[0]);
108 return -1;
109 }
110 if (strlen(args[1]) > 1) {
111 memprintf(err,
112 "'%s' expects a single character, got '%s'.",
113 args[0], args[1]);
114 return -1;
115 }
116
Willy Tarreaub7a67142016-12-21 21:18:44 +0100117 global_51degrees.property_separator = *args[1];
Dragan Dosen93b38d92015-06-29 16:43:25 +0200118
119 return 0;
120}
121
Dragan Dosen105c8e62015-06-29 16:43:26 +0200122static int _51d_cache_size(char **args, int section_type, struct proxy *curpx,
123 struct proxy *defpx, const char *file, int line,
124 char **err)
125{
126 if (*(args[1]) == 0) {
127 memprintf(err,
128 "'%s' expects a positive numeric value.",
129 args[0]);
130 return -1;
131 }
132
Willy Tarreaub7a67142016-12-21 21:18:44 +0100133 global_51degrees.cache_size = atoi(args[1]);
134 if (global_51degrees.cache_size < 0) {
Dragan Dosen105c8e62015-06-29 16:43:26 +0200135 memprintf(err,
136 "'%s' expects a positive numeric value, got '%s'.",
137 args[0], args[1]);
138 return -1;
139 }
140
James Rosewella28bbd52015-09-18 18:28:52 +0100141 return 0;
142}
143
144static int _51d_fetch_check(struct arg *arg, char **err_msg)
145{
Willy Tarreaub7a67142016-12-21 21:18:44 +0100146 if (global_51degrees.data_file_path)
James Rosewella28bbd52015-09-18 18:28:52 +0100147 return 1;
148
149 memprintf(err_msg, "51Degrees data file is not specified (parameter '51degrees-data-file')");
Dragan Dosen105c8e62015-06-29 16:43:26 +0200150 return 0;
151}
152
Dragan Dosen9373fc52015-08-07 16:41:23 +0200153static int _51d_conv_check(struct arg *arg, struct sample_conv *conv,
James Rosewella28bbd52015-09-18 18:28:52 +0100154 const char *file, int line, char **err_msg)
Dragan Dosen9373fc52015-08-07 16:41:23 +0200155{
Willy Tarreaub7a67142016-12-21 21:18:44 +0100156 if (global_51degrees.data_file_path)
Dragan Dosen9373fc52015-08-07 16:41:23 +0200157 return 1;
158
James Rosewella28bbd52015-09-18 18:28:52 +0100159 memprintf(err_msg, "51Degrees data file is not specified (parameter '51degrees-data-file')");
Dragan Dosen9373fc52015-08-07 16:41:23 +0200160 return 0;
161}
162
James Rosewella28bbd52015-09-18 18:28:52 +0100163#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
ben@51degrees.comc9dfa242016-01-08 13:47:46 +0000164static void _51d_lru_free(void *cache_entry)
165{
Willy Tarreau83061a82018-07-13 11:56:34 +0200166 struct buffer *ptr = cache_entry;
ben@51degrees.comc9dfa242016-01-08 13:47:46 +0000167
168 if (!ptr)
169 return;
170
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200171 free(ptr->area);
ben@51degrees.comc9dfa242016-01-08 13:47:46 +0000172 free(ptr);
173}
174
175/* Allocates memory freeing space in the cache if necessary.
176*/
177static void *_51d_malloc(int size)
178{
179 void *ptr = malloc(size);
180
181 if (!ptr) {
182 /* free the oldest 10 entries from lru to free up some memory
183 * then try allocating memory again */
184 lru64_kill_oldest(_51d_lru_tree, 10);
185 ptr = malloc(size);
186 }
187
188 return ptr;
189}
190
James Rosewell63426cb2015-09-18 19:53:05 +0100191/* Insert the data associated with the sample into the cache as a fresh item.
192 */
ben@51degrees.com82a9d762016-01-08 13:42:41 +0000193static void _51d_insert_cache_entry(struct sample *smp, struct lru64 *lru, void* domain)
James Rosewell63426cb2015-09-18 19:53:05 +0100194{
Willy Tarreau83061a82018-07-13 11:56:34 +0200195 struct buffer *cache_entry = _51d_malloc(sizeof(*cache_entry));
James Rosewell63426cb2015-09-18 19:53:05 +0100196
197 if (!cache_entry)
198 return;
199
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200200 cache_entry->area = _51d_malloc(smp->data.u.str.data + 1);
201 if (!cache_entry->area) {
ben@51degrees.comc9dfa242016-01-08 13:47:46 +0000202 free(cache_entry);
James Rosewell63426cb2015-09-18 19:53:05 +0100203 return;
ben@51degrees.comc9dfa242016-01-08 13:47:46 +0000204 }
James Rosewell63426cb2015-09-18 19:53:05 +0100205
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200206 memcpy(cache_entry->area, smp->data.u.str.area, smp->data.u.str.data);
207 cache_entry->area[smp->data.u.str.data] = 0;
208 cache_entry->data = smp->data.u.str.data;
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000209 HA_SPIN_LOCK(OTHER_LOCK, &_51d_lru_lock);
ben@51degrees.comc9dfa242016-01-08 13:47:46 +0000210 lru64_commit(lru, cache_entry, domain, 0, _51d_lru_free);
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000211 HA_SPIN_UNLOCK(OTHER_LOCK, &_51d_lru_lock);
James Rosewell63426cb2015-09-18 19:53:05 +0100212}
213
214/* Retrieves the data from the cache and sets the sample data to this string.
215 */
216static void _51d_retrieve_cache_entry(struct sample *smp, struct lru64 *lru)
217{
Willy Tarreau83061a82018-07-13 11:56:34 +0200218 struct buffer *cache_entry = lru->data;
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200219 smp->data.u.str.area = cache_entry->area;
220 smp->data.u.str.data = cache_entry->data;
James Rosewell63426cb2015-09-18 19:53:05 +0100221}
222#endif
223
224#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
James Rosewella28bbd52015-09-18 18:28:52 +0100225/* Sets the important HTTP headers ahead of the detection
226 */
227static void _51d_set_headers(struct sample *smp, fiftyoneDegreesWorkset *ws)
Dragan Dosen93b38d92015-06-29 16:43:25 +0200228{
James Rosewella28bbd52015-09-18 18:28:52 +0100229 struct hdr_idx *idx;
230 struct hdr_ctx ctx;
231 const struct http_msg *msg;
Dragan Dosen93b38d92015-06-29 16:43:25 +0200232 int i;
James Rosewella28bbd52015-09-18 18:28:52 +0100233
234 idx = &smp->strm->txn->hdr_idx;
235 msg = &smp->strm->txn->req;
236
237 ws->importantHeadersCount = 0;
238
Willy Tarreaub7a67142016-12-21 21:18:44 +0100239 for (i = 0; i < global_51degrees.header_count; i++) {
James Rosewella28bbd52015-09-18 18:28:52 +0100240 ctx.idx = 0;
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200241 if (http_find_full_header2((global_51degrees.header_names + i)->area,
242 (global_51degrees.header_names + i)->data,
Ben51Degreesdaa356b2019-01-16 10:19:15 +0000243#ifndef BUF_NULL
244 msg->chn->buf->p,
245#else
246 ci_head(msg->chn),
247#endif
248 idx,
249 &ctx) == 1) {
James Rosewella28bbd52015-09-18 18:28:52 +0100250 ws->importantHeaders[ws->importantHeadersCount].header = ws->dataSet->httpHeaders + i;
251 ws->importantHeaders[ws->importantHeadersCount].headerValue = ctx.line + ctx.val;
252 ws->importantHeaders[ws->importantHeadersCount].headerValueLength = ctx.vlen;
253 ws->importantHeadersCount++;
254 }
255 }
256}
Dragan Dosen93b38d92015-06-29 16:43:25 +0200257#endif
James Rosewella28bbd52015-09-18 18:28:52 +0100258
Dragan Dosen93b38d92015-06-29 16:43:25 +0200259#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000260static void _51d_init_device_offsets(fiftyoneDegreesDeviceOffsets *offsets) {
261 int i;
262 for (i = 0; i < global_51degrees.data_set.uniqueHttpHeaders.count; i++) {
263 offsets->firstOffset[i].userAgent = NULL;
264 }
265}
266
267static void _51d_set_device_offsets(struct sample *smp, fiftyoneDegreesDeviceOffsets *offsets)
James Rosewella28bbd52015-09-18 18:28:52 +0100268{
269 struct hdr_idx *idx;
270 struct hdr_ctx ctx;
271 const struct http_msg *msg;
272 int index;
Dragan Dosen105c8e62015-06-29 16:43:26 +0200273
James Rosewella28bbd52015-09-18 18:28:52 +0100274 idx = &smp->strm->txn->hdr_idx;
275 msg = &smp->strm->txn->req;
276 offsets->size = 0;
Dragan Dosen105c8e62015-06-29 16:43:26 +0200277
Willy Tarreaub7a67142016-12-21 21:18:44 +0100278 for (index = 0; index < global_51degrees.header_count; index++) {
James Rosewella28bbd52015-09-18 18:28:52 +0100279 ctx.idx = 0;
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200280 if (http_find_full_header2((global_51degrees.header_names + index)->area,
281 (global_51degrees.header_names + index)->data,
Ben51Degreesdaa356b2019-01-16 10:19:15 +0000282#ifndef BUF_NULL
283 msg->chn->buf->p,
284#else
285 ci_head(msg->chn),
286#endif
287 idx,
288 &ctx) == 1) {
289
Willy Tarreaub7a67142016-12-21 21:18:44 +0100290 (offsets->firstOffset + offsets->size)->httpHeaderOffset = *(global_51degrees.header_offsets + index);
291 (offsets->firstOffset + offsets->size)->deviceOffset = fiftyoneDegreesGetDeviceOffset(&global_51degrees.data_set, ctx.line + ctx.val);
James Rosewella28bbd52015-09-18 18:28:52 +0100292 offsets->size++;
Dragan Dosen105c8e62015-06-29 16:43:26 +0200293 }
294 }
James Rosewella28bbd52015-09-18 18:28:52 +0100295}
296#endif
Dragan Dosen93b38d92015-06-29 16:43:25 +0200297
298#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
James Rosewella28bbd52015-09-18 18:28:52 +0100299/* Provides a hash code for the important HTTP headers.
300 */
301unsigned long long _51d_req_hash(const struct arg *args, fiftyoneDegreesWorkset* ws)
302{
303 unsigned long long seed = _51d_lru_seed ^ (long)args;
304 unsigned long long hash = 0;
305 int i;
306 for(i = 0; i < ws->importantHeadersCount; i++) {
307 hash ^= ws->importantHeaders[i].header->headerNameOffset;
308 hash ^= XXH64(ws->importantHeaders[i].headerValue,
309 ws->importantHeaders[i].headerValueLength,
310 seed);
311 }
312 return hash;
313}
Dragan Dosen93b38d92015-06-29 16:43:25 +0200314#endif
315
Dragan Dosen93b38d92015-06-29 16:43:25 +0200316#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
James Rosewella28bbd52015-09-18 18:28:52 +0100317static void _51d_process_match(const struct arg *args, struct sample *smp, fiftyoneDegreesWorkset* ws)
318{
319 char *methodName;
Dragan Dosen93b38d92015-06-29 16:43:25 +0200320#endif
321#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000322static void _51d_process_match(const struct arg *args, struct sample *smp, fiftyoneDegreesDeviceOffsets *offsets)
James Rosewella28bbd52015-09-18 18:28:52 +0100323{
324 char valuesBuffer[1024];
Willy Tarreaub7a67142016-12-21 21:18:44 +0100325 const char **requiredProperties = fiftyoneDegreesGetRequiredPropertiesNames(&global_51degrees.data_set);
326 int requiredPropertiesCount = fiftyoneDegreesGetRequiredPropertiesCount(&global_51degrees.data_set);
Dragan Dosen93b38d92015-06-29 16:43:25 +0200327#endif
328
James Rosewella28bbd52015-09-18 18:28:52 +0100329 char no_data[] = "NoData"; /* response when no data could be found */
Willy Tarreau83061a82018-07-13 11:56:34 +0200330 struct buffer *temp = get_trash_chunk();
James Rosewella28bbd52015-09-18 18:28:52 +0100331 int j, i = 0, found;
332 const char* property_name;
Dragan Dosen93b38d92015-06-29 16:43:25 +0200333
334 /* Loop through property names passed to the filter and fetch them from the dataset. */
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200335 while (args[i].data.str.area) {
Dragan Dosen93b38d92015-06-29 16:43:25 +0200336 /* Try to find request property in dataset. */
Dragan Dosen93b38d92015-06-29 16:43:25 +0200337 found = 0;
James Rosewella28bbd52015-09-18 18:28:52 +0100338#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200339 if (strcmp("Method", args[i].data.str.area) == 0) {
James Rosewella28bbd52015-09-18 18:28:52 +0100340 switch(ws->method) {
341 case EXACT: methodName = "Exact"; break;
342 case NUMERIC: methodName = "Numeric"; break;
343 case NEAREST: methodName = "Nearest"; break;
344 case CLOSEST: methodName = "Closest"; break;
345 default:
346 case NONE: methodName = "None"; break;
Dragan Dosen93b38d92015-06-29 16:43:25 +0200347 }
James Rosewella28bbd52015-09-18 18:28:52 +0100348 chunk_appendf(temp, "%s", methodName);
349 found = 1;
Dragan Dosen93b38d92015-06-29 16:43:25 +0200350 }
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200351 else if (strcmp("Difference", args[i].data.str.area) == 0) {
James Rosewella28bbd52015-09-18 18:28:52 +0100352 chunk_appendf(temp, "%d", ws->difference);
353 found = 1;
354 }
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200355 else if (strcmp("Rank", args[i].data.str.area) == 0) {
James Rosewella28bbd52015-09-18 18:28:52 +0100356 chunk_appendf(temp, "%d", fiftyoneDegreesGetSignatureRank(ws));
357 found = 1;
358 }
359 else {
360 for (j = 0; j < ws->dataSet->requiredPropertyCount; j++) {
361 property_name = fiftyoneDegreesGetPropertyName(ws->dataSet, ws->dataSet->requiredProperties[j]);
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200362 if (strcmp(property_name, args[i].data.str.area) == 0) {
James Rosewella28bbd52015-09-18 18:28:52 +0100363 found = 1;
364 fiftyoneDegreesSetValues(ws, j);
365 chunk_appendf(temp, "%s", fiftyoneDegreesGetValueName(ws->dataSet, *ws->values));
366 break;
367 }
368 }
Dragan Dosen93b38d92015-06-29 16:43:25 +0200369 }
370#endif
371#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
James Rosewella28bbd52015-09-18 18:28:52 +0100372 found = 0;
373 for (j = 0; j < requiredPropertiesCount; j++) {
374 property_name = requiredProperties[j];
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200375 if (strcmp(property_name, args[i].data.str.area) == 0 &&
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000376 fiftyoneDegreesGetValueFromOffsets(&global_51degrees.data_set, offsets, j, valuesBuffer, 1024) > 0) {
James Rosewella28bbd52015-09-18 18:28:52 +0100377 found = 1;
378 chunk_appendf(temp, "%s", valuesBuffer);
379 break;
380 }
Dragan Dosen93b38d92015-06-29 16:43:25 +0200381 }
James Rosewella28bbd52015-09-18 18:28:52 +0100382#endif
ben@51degrees.comd3842522016-01-08 13:52:32 +0000383 if (!found)
Dragan Dosen93b38d92015-06-29 16:43:25 +0200384 chunk_appendf(temp, "%s", no_data);
ben@51degrees.comd3842522016-01-08 13:52:32 +0000385
Dragan Dosen93b38d92015-06-29 16:43:25 +0200386 /* Add separator. */
Willy Tarreaub7a67142016-12-21 21:18:44 +0100387 chunk_appendf(temp, "%c", global_51degrees.property_separator);
Dragan Dosen93b38d92015-06-29 16:43:25 +0200388 ++i;
389 }
390
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200391 if (temp->data) {
392 --temp->data;
393 temp->area[temp->data] = '\0';
Dragan Dosen93b38d92015-06-29 16:43:25 +0200394 }
395
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200396 smp->data.u.str.area = temp->area;
397 smp->data.u.str.data = temp->data;
James Rosewella28bbd52015-09-18 18:28:52 +0100398}
399
400static int _51d_fetch(const struct arg *args, struct sample *smp, const char *kw, void *private)
401{
402#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
403 fiftyoneDegreesWorkset* ws; /* workset for detection */
404 struct lru64 *lru = NULL;
405#endif
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000406#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
407 fiftyoneDegreesDeviceOffsets *offsets; /* Offsets for detection */
408#endif
James Rosewella28bbd52015-09-18 18:28:52 +0100409
Joseph Herlant31019ee2018-11-25 13:15:13 -0800410 /* Needed to ensure that the HTTP message has been fully received when
James Rosewella28bbd52015-09-18 18:28:52 +0100411 * used with TCP operation. Not required for HTTP operation.
412 * Data type has to be reset to ensure the string output is processed
413 * correctly.
414 */
415 CHECK_HTTP_MESSAGE_FIRST();
416 smp->data.type = SMP_T_STR;
417
ben@51degrees.com82a9d762016-01-08 13:42:41 +0000418 /* Flags the sample to show it uses constant memory*/
419 smp->flags |= SMP_F_CONST;
420
James Rosewella28bbd52015-09-18 18:28:52 +0100421#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
422
423 /* Get only the headers needed for device detection so they can be used
424 * with the cache to return previous results. Pattern is slower than
425 * Trie so caching will help improve performance.
426 */
427
428 /* Get a workset from the pool which will later contain detection results. */
Willy Tarreaub7a67142016-12-21 21:18:44 +0100429 ws = fiftyoneDegreesWorksetPoolGet(global_51degrees.pool);
James Rosewella28bbd52015-09-18 18:28:52 +0100430 if (!ws)
431 return 0;
432
433 /* Set the important HTTP headers for this request in the workset. */
434 _51d_set_headers(smp, ws);
435
436 /* Check the cache to see if there's results for these headers already. */
437 if (_51d_lru_tree) {
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000438 HA_SPIN_LOCK(OTHER_LOCK, &_51d_lru_lock);
439
James Rosewella28bbd52015-09-18 18:28:52 +0100440 lru = lru64_get(_51d_req_hash(args, ws),
ben@51degrees.com82a9d762016-01-08 13:42:41 +0000441 _51d_lru_tree, (void*)args, 0);
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000442
James Rosewella28bbd52015-09-18 18:28:52 +0100443 if (lru && lru->domain) {
Willy Tarreaub7a67142016-12-21 21:18:44 +0100444 fiftyoneDegreesWorksetPoolRelease(global_51degrees.pool, ws);
James Rosewell63426cb2015-09-18 19:53:05 +0100445 _51d_retrieve_cache_entry(smp, lru);
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000446 HA_SPIN_UNLOCK(OTHER_LOCK, &_51d_lru_lock);
James Rosewella28bbd52015-09-18 18:28:52 +0100447 return 1;
448 }
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000449 HA_SPIN_UNLOCK(OTHER_LOCK, &_51d_lru_lock);
James Rosewella28bbd52015-09-18 18:28:52 +0100450 }
451
452 fiftyoneDegreesMatchForHttpHeaders(ws);
453
454 _51d_process_match(args, smp, ws);
455
456#endif
457
458#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000459#ifndef FIFTYONEDEGREES_NO_THREADING
460 offsets = fiftyoneDegreesCreateDeviceOffsets(&global_51degrees.data_set);
461 _51d_init_device_offsets(offsets);
462#else
463 offsets = &global_51degrees.device_offsets;
464#endif
James Rosewella28bbd52015-09-18 18:28:52 +0100465
466 /* Trie is very fast so all the headers can be passed in and the result
467 * returned faster than the hashing algorithm process.
468 */
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000469 _51d_set_device_offsets(smp, offsets);
470 _51d_process_match(args, smp, offsets);
James Rosewella28bbd52015-09-18 18:28:52 +0100471
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000472#ifndef FIFTYONEDEGREES_NO_THREADING
473 fiftyoneDegreesFreeDeviceOffsets(offsets);
James Rosewella28bbd52015-09-18 18:28:52 +0100474#endif
475
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000476#endif
477
James Rosewella28bbd52015-09-18 18:28:52 +0100478#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
Willy Tarreaub7a67142016-12-21 21:18:44 +0100479 fiftyoneDegreesWorksetPoolRelease(global_51degrees.pool, ws);
ben@51degrees.comd3842522016-01-08 13:52:32 +0000480 if (lru)
ben@51degrees.com82a9d762016-01-08 13:42:41 +0000481 _51d_insert_cache_entry(smp, lru, (void*)args);
James Rosewella28bbd52015-09-18 18:28:52 +0100482#endif
483
484 return 1;
485}
Dragan Dosen93b38d92015-06-29 16:43:25 +0200486
James Rosewella28bbd52015-09-18 18:28:52 +0100487static int _51d_conv(const struct arg *args, struct sample *smp, void *private)
488{
Dragan Dosen93b38d92015-06-29 16:43:25 +0200489#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
James Rosewella28bbd52015-09-18 18:28:52 +0100490 fiftyoneDegreesWorkset* ws; /* workset for detection */
491 struct lru64 *lru = NULL;
Dragan Dosen93b38d92015-06-29 16:43:25 +0200492#endif
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000493#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
494 fiftyoneDegreesDeviceOffsets *offsets; /* Offsets for detection */
495#endif
ben@51degrees.com82a9d762016-01-08 13:42:41 +0000496 /* Flags the sample to show it uses constant memory*/
497 smp->flags |= SMP_F_CONST;
498
James Rosewella28bbd52015-09-18 18:28:52 +0100499#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
500
501 /* Look in the list. */
502 if (_51d_lru_tree) {
503 unsigned long long seed = _51d_lru_seed ^ (long)args;
504
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000505 HA_SPIN_LOCK(OTHER_LOCK, &_51d_lru_lock);
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200506 lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
ben@51degrees.com82a9d762016-01-08 13:42:41 +0000507 _51d_lru_tree, (void*)args, 0);
James Rosewella28bbd52015-09-18 18:28:52 +0100508 if (lru && lru->domain) {
James Rosewell63426cb2015-09-18 19:53:05 +0100509 _51d_retrieve_cache_entry(smp, lru);
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000510 HA_SPIN_UNLOCK(OTHER_LOCK, &_51d_lru_lock);
James Rosewella28bbd52015-09-18 18:28:52 +0100511 return 1;
512 }
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000513 HA_SPIN_UNLOCK(OTHER_LOCK, &_51d_lru_lock);
James Rosewella28bbd52015-09-18 18:28:52 +0100514 }
515
516 /* Create workset. This will later contain detection results. */
Willy Tarreaub7a67142016-12-21 21:18:44 +0100517 ws = fiftyoneDegreesWorksetPoolGet(global_51degrees.pool);
James Rosewella28bbd52015-09-18 18:28:52 +0100518 if (!ws)
519 return 0;
520#endif
521
522 /* Duplicate the data and remove the "const" flag before device detection. */
523 if (!smp_dup(smp))
524 return 0;
525
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200526 smp->data.u.str.area[smp->data.u.str.data] = '\0';
James Rosewella28bbd52015-09-18 18:28:52 +0100527
528 /* Perform detection. */
529#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200530 fiftyoneDegreesMatch(ws, smp->data.u.str.area);
James Rosewella28bbd52015-09-18 18:28:52 +0100531 _51d_process_match(args, smp, ws);
532#endif
533#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000534#ifndef FIFTYONEDEGREES_NO_THREADING
535 offsets = fiftyoneDegreesCreateDeviceOffsets(&global_51degrees.data_set);
536 _51d_init_device_offsets(offsets);
537#else
538 offsets = &global_51degrees.device_offsets;
539#endif
540
541 offsets->firstOffset->deviceOffset = fiftyoneDegreesGetDeviceOffset(&global_51degrees.data_set,
542 smp->data.u.str.area);
543 offsets->size = 1;
544 _51d_process_match(args, smp, offsets);
James Rosewella28bbd52015-09-18 18:28:52 +0100545#endif
546
547#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
Willy Tarreaub7a67142016-12-21 21:18:44 +0100548 fiftyoneDegreesWorksetPoolRelease(global_51degrees.pool, ws);
ben@51degrees.comd3842522016-01-08 13:52:32 +0000549 if (lru)
ben@51degrees.com82a9d762016-01-08 13:42:41 +0000550 _51d_insert_cache_entry(smp, lru, (void*)args);
James Rosewella28bbd52015-09-18 18:28:52 +0100551#endif
Dragan Dosen105c8e62015-06-29 16:43:26 +0200552
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000553#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
554#ifndef FIFTYONEDEGREES_NO_THREADING
555 fiftyoneDegreesFreeDeviceOffsets(offsets);
556#endif
557#endif
558
Dragan Dosen93b38d92015-06-29 16:43:25 +0200559 return 1;
560}
561
James Rosewella28bbd52015-09-18 18:28:52 +0100562#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
563void _51d_init_http_headers()
564{
565 int index = 0;
566 const fiftyoneDegreesAsciiString *headerName;
Willy Tarreaub7a67142016-12-21 21:18:44 +0100567 fiftyoneDegreesDataSet *ds = &global_51degrees.data_set;
568 global_51degrees.header_count = ds->httpHeadersCount;
Willy Tarreau83061a82018-07-13 11:56:34 +0200569 global_51degrees.header_names = malloc(global_51degrees.header_count * sizeof(struct buffer));
Willy Tarreaub7a67142016-12-21 21:18:44 +0100570 for (index = 0; index < global_51degrees.header_count; index++) {
James Rosewella28bbd52015-09-18 18:28:52 +0100571 headerName = fiftyoneDegreesGetString(ds, ds->httpHeaders[index].headerNameOffset);
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200572 (global_51degrees.header_names + index)->area = (char*)&headerName->firstByte;
573 (global_51degrees.header_names + index)->data = headerName->length - 1;
574 (global_51degrees.header_names + index)->size = (global_51degrees.header_names + index)->data;
James Rosewella28bbd52015-09-18 18:28:52 +0100575 }
576}
577#endif
578
579#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
580void _51d_init_http_headers()
581{
582 int index = 0;
Willy Tarreaub7a67142016-12-21 21:18:44 +0100583 fiftyoneDegreesDataSet *ds = &global_51degrees.data_set;
584 global_51degrees.header_count = fiftyoneDegreesGetHttpHeaderCount(ds);
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000585#ifdef FIFTYONEDEGREES_NO_THREADING
Willy Tarreaub7a67142016-12-21 21:18:44 +0100586 global_51degrees.device_offsets.firstOffset = malloc(
587 global_51degrees.header_count * sizeof(fiftyoneDegreesDeviceOffset));
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000588 _51d_init_device_offsets(&global_51degrees.device_offsets);
589#endif
Willy Tarreau83061a82018-07-13 11:56:34 +0200590 global_51degrees.header_names = malloc(global_51degrees.header_count * sizeof(struct buffer));
Willy Tarreaub7a67142016-12-21 21:18:44 +0100591 global_51degrees.header_offsets = malloc(global_51degrees.header_count * sizeof(int32_t));
592 for (index = 0; index < global_51degrees.header_count; index++) {
593 global_51degrees.header_offsets[index] = fiftyoneDegreesGetHttpHeaderNameOffset(ds, index);
Ben51Degreese0f6a2a2019-02-05 13:23:06 +0000594 global_51degrees.header_names[index].area = (char*)fiftyoneDegreesGetHttpHeaderNamePointer(ds, index);
595 global_51degrees.header_names[index].data = strlen(global_51degrees.header_names[index].area);
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200596 global_51degrees.header_names[index].size = global_51degrees.header_names->data;
James Rosewella28bbd52015-09-18 18:28:52 +0100597 }
598}
599#endif
600
Willy Tarreau9f3f2542016-12-21 20:30:05 +0100601/*
602 * module init / deinit functions. Returns 0 if OK, or a combination of ERR_*.
603 */
604static int init_51degrees(void)
Dragan Dosen93b38d92015-06-29 16:43:25 +0200605{
606 int i = 0;
Willy Tarreau83061a82018-07-13 11:56:34 +0200607 struct buffer *temp;
Dragan Dosen93b38d92015-06-29 16:43:25 +0200608 struct _51d_property_names *name;
609 char **_51d_property_list = NULL;
610 fiftyoneDegreesDataSetInitStatus _51d_dataset_status = DATA_SET_INIT_STATUS_NOT_SET;
611
Willy Tarreaub7a67142016-12-21 21:18:44 +0100612 if (!global_51degrees.data_file_path)
Willy Tarreau9f3f2542016-12-21 20:30:05 +0100613 return 0;
Dragan Dosen9373fc52015-08-07 16:41:23 +0200614
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000615 if (global.nbthread < 1) {
616 ha_alert("51Degrees: The thread count cannot be zero or negative.\n");
Christopher Faulete8ca4342017-10-25 17:23:02 +0200617 return (ERR_FATAL | ERR_ALERT);
618 }
619
Willy Tarreaub7a67142016-12-21 21:18:44 +0100620 if (!LIST_ISEMPTY(&global_51degrees.property_names)) {
Dragan Dosen93b38d92015-06-29 16:43:25 +0200621 i = 0;
Willy Tarreaub7a67142016-12-21 21:18:44 +0100622 list_for_each_entry(name, &global_51degrees.property_names, list)
Dragan Dosen93b38d92015-06-29 16:43:25 +0200623 ++i;
624 _51d_property_list = calloc(i, sizeof(char *));
625
626 i = 0;
Willy Tarreaub7a67142016-12-21 21:18:44 +0100627 list_for_each_entry(name, &global_51degrees.property_names, list)
Dragan Dosen93b38d92015-06-29 16:43:25 +0200628 _51d_property_list[i++] = name->name;
629 }
630
Willy Tarreaub7a67142016-12-21 21:18:44 +0100631 _51d_dataset_status = fiftyoneDegreesInitWithPropertyArray(global_51degrees.data_file_path, &global_51degrees.data_set, (const char**)_51d_property_list, i);
Dragan Dosen93b38d92015-06-29 16:43:25 +0200632
633 temp = get_trash_chunk();
634 chunk_reset(temp);
635
636 switch (_51d_dataset_status) {
637 case DATA_SET_INIT_STATUS_SUCCESS:
James Rosewella28bbd52015-09-18 18:28:52 +0100638#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000639 global_51degrees.pool = fiftyoneDegreesWorksetPoolCreate(&global_51degrees.data_set, NULL, global.nbthread);
James Rosewella28bbd52015-09-18 18:28:52 +0100640#endif
641 _51d_init_http_headers();
Dragan Dosen93b38d92015-06-29 16:43:25 +0200642 break;
643 case DATA_SET_INIT_STATUS_INSUFFICIENT_MEMORY:
644 chunk_printf(temp, "Insufficient memory.");
645 break;
646 case DATA_SET_INIT_STATUS_CORRUPT_DATA:
647#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
648 chunk_printf(temp, "Corrupt data file. Check that the data file provided is uncompressed and Pattern data format.");
649#endif
650#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
651 chunk_printf(temp, "Corrupt data file. Check that the data file provided is uncompressed and Trie data format.");
652#endif
653 break;
654 case DATA_SET_INIT_STATUS_INCORRECT_VERSION:
655#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
656 chunk_printf(temp, "Incorrect version. Check that the data file provided is uncompressed and Pattern data format.");
657#endif
658#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
659 chunk_printf(temp, "Incorrect version. Check that the data file provided is uncompressed and Trie data format.");
660#endif
661 break;
662 case DATA_SET_INIT_STATUS_FILE_NOT_FOUND:
663 chunk_printf(temp, "File not found.");
664 break;
ben51degrees1f077eb2016-07-06 12:07:21 +0100665 case DATA_SET_INIT_STATUS_NULL_POINTER:
666 chunk_printf(temp, "Null pointer to the existing dataset or memory location.");
667 break;
668 case DATA_SET_INIT_STATUS_POINTER_OUT_OF_BOUNDS:
669 chunk_printf(temp, "Allocated continuous memory containing 51Degrees data file appears to be smaller than expected. Most likely"
670 " because the data file was not fully loaded into the allocated memory.");
671 break;
Dragan Dosen93b38d92015-06-29 16:43:25 +0200672 case DATA_SET_INIT_STATUS_NOT_SET:
673 chunk_printf(temp, "Data set not initialised.");
674 break;
Dragan Dosen483b93c2017-09-27 12:46:44 +0200675 default:
676 chunk_printf(temp, "Other error.");
677 break;
Dragan Dosen93b38d92015-06-29 16:43:25 +0200678 }
679 if (_51d_dataset_status != DATA_SET_INIT_STATUS_SUCCESS) {
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200680 if (temp->data)
681 ha_alert("51Degrees Setup - Error reading 51Degrees data file. %s\n",
682 temp->area);
Dragan Dosen93b38d92015-06-29 16:43:25 +0200683 else
Christopher Faulet767a84b2017-11-24 16:50:31 +0100684 ha_alert("51Degrees Setup - Error reading 51Degrees data file.\n");
Willy Tarreau9f3f2542016-12-21 20:30:05 +0100685 return ERR_ALERT | ERR_FATAL;
Dragan Dosen93b38d92015-06-29 16:43:25 +0200686 }
687 free(_51d_property_list);
688
James Rosewella28bbd52015-09-18 18:28:52 +0100689#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
Dragan Dosen105c8e62015-06-29 16:43:26 +0200690 _51d_lru_seed = random();
Willy Tarreaub7a67142016-12-21 21:18:44 +0100691 if (global_51degrees.cache_size) {
692 _51d_lru_tree = lru64_new(global_51degrees.cache_size);
James Rosewella28bbd52015-09-18 18:28:52 +0100693 }
694#endif
Dragan Dosen105c8e62015-06-29 16:43:26 +0200695
Dragan Dosen93b38d92015-06-29 16:43:25 +0200696 return 0;
697}
698
Willy Tarreau7ac4c202016-12-21 20:59:01 +0100699static void deinit_51degrees(void)
Dragan Dosen93b38d92015-06-29 16:43:25 +0200700{
701 struct _51d_property_names *_51d_prop_name, *_51d_prop_nameb;
702
Willy Tarreaub7a67142016-12-21 21:18:44 +0100703 free(global_51degrees.header_names);
Dragan Dosen93b38d92015-06-29 16:43:25 +0200704#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
Willy Tarreaub7a67142016-12-21 21:18:44 +0100705 fiftyoneDegreesWorksetPoolFree(global_51degrees.pool);
Dragan Dosen93b38d92015-06-29 16:43:25 +0200706#endif
707#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000708#ifdef FIFTYONEDEGREES_NO_THREADING
Willy Tarreaub7a67142016-12-21 21:18:44 +0100709 free(global_51degrees.device_offsets.firstOffset);
Ben51Degrees4ddf59d2019-02-05 13:24:00 +0000710#endif
Willy Tarreaub7a67142016-12-21 21:18:44 +0100711 free(global_51degrees.header_offsets);
Dragan Dosen93b38d92015-06-29 16:43:25 +0200712#endif
Willy Tarreaub7a67142016-12-21 21:18:44 +0100713 fiftyoneDegreesDataSetFree(&global_51degrees.data_set);
Dragan Dosen93b38d92015-06-29 16:43:25 +0200714
Willy Tarreaub7a67142016-12-21 21:18:44 +0100715 free(global_51degrees.data_file_path); global_51degrees.data_file_path = NULL;
716 list_for_each_entry_safe(_51d_prop_name, _51d_prop_nameb, &global_51degrees.property_names, list) {
Dragan Dosen93b38d92015-06-29 16:43:25 +0200717 LIST_DEL(&_51d_prop_name->list);
718 free(_51d_prop_name);
719 }
Dragan Dosen105c8e62015-06-29 16:43:26 +0200720
James Rosewella28bbd52015-09-18 18:28:52 +0100721#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
Dragan Dosen105c8e62015-06-29 16:43:26 +0200722 while (lru64_destroy(_51d_lru_tree));
James Rosewella28bbd52015-09-18 18:28:52 +0100723#endif
Dragan Dosen93b38d92015-06-29 16:43:25 +0200724}
725
726static struct cfg_kw_list _51dcfg_kws = {{ }, {
727 { CFG_GLOBAL, "51degrees-data-file", _51d_data_file },
728 { CFG_GLOBAL, "51degrees-property-name-list", _51d_property_name_list },
729 { CFG_GLOBAL, "51degrees-property-separator", _51d_property_separator },
Dragan Dosen105c8e62015-06-29 16:43:26 +0200730 { CFG_GLOBAL, "51degrees-cache-size", _51d_cache_size },
Dragan Dosen93b38d92015-06-29 16:43:25 +0200731 { 0, NULL, NULL },
732}};
733
Willy Tarreau0108d902018-11-25 19:14:37 +0100734INITCALL1(STG_REGISTER, cfg_register_keywords, &_51dcfg_kws);
735
Dragan Dosen93b38d92015-06-29 16:43:25 +0200736/* Note: must not be declared <const> as its list will be overwritten */
James Rosewella28bbd52015-09-18 18:28:52 +0100737static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
738 { "51d.all", _51d_fetch, ARG5(1,STR,STR,STR,STR,STR), _51d_fetch_check, SMP_T_STR, SMP_USE_HRQHV },
739 { NULL, NULL, 0, 0, 0 },
740}};
741
Willy Tarreau0108d902018-11-25 19:14:37 +0100742INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords);
743
James Rosewella28bbd52015-09-18 18:28:52 +0100744/* Note: must not be declared <const> as its list will be overwritten */
Dragan Dosen93b38d92015-06-29 16:43:25 +0200745static struct sample_conv_kw_list conv_kws = {ILH, {
James Rosewella28bbd52015-09-18 18:28:52 +0100746 { "51d.single", _51d_conv, ARG5(1,STR,STR,STR,STR,STR), _51d_conv_check, SMP_T_STR, SMP_T_STR },
Dragan Dosen93b38d92015-06-29 16:43:25 +0200747 { NULL, NULL, 0, 0, 0 },
748}};
749
Willy Tarreau0108d902018-11-25 19:14:37 +0100750INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws);
751
Willy Tarreau172f5ce2018-11-26 11:21:50 +0100752REGISTER_POST_CHECK(init_51degrees);
753REGISTER_POST_DEINIT(deinit_51degrees);
Willy Tarreau80713382018-11-26 10:19:54 +0100754REGISTER_BUILD_OPTS("Built with 51Degrees support.");