2015-06-01 11:50:06 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <common/cfgparse.h>
|
2016-12-21 19:39:16 +00:00
|
|
|
#include <common/errors.h>
|
2018-10-02 16:37:27 +00:00
|
|
|
#include <common/http.h>
|
2018-11-25 18:14:37 +00:00
|
|
|
#include <common/initcall.h>
|
2018-11-26 09:19:54 +00:00
|
|
|
#include <types/global.h>
|
2015-06-01 13:39:50 +00:00
|
|
|
#include <proto/arg.h>
|
2018-10-02 14:01:16 +00:00
|
|
|
#include <proto/http_fetch.h>
|
2019-04-24 19:41:53 +00:00
|
|
|
#include <proto/http_htx.h>
|
2015-06-01 11:50:06 +00:00
|
|
|
#include <proto/log.h>
|
2019-07-16 12:54:53 +00:00
|
|
|
#include <proto/http_ana.h>
|
2015-06-01 13:39:50 +00:00
|
|
|
#include <proto/sample.h>
|
2016-12-21 20:25:06 +00:00
|
|
|
#include <dac.h>
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
void *atlasimgptr;
|
|
|
|
char *jsonpath;
|
|
|
|
char *cookiename;
|
|
|
|
size_t cookienamelen;
|
|
|
|
da_atlas_t atlas;
|
|
|
|
da_evidence_id_t useragentid;
|
|
|
|
da_severity_t loglevel;
|
|
|
|
char separator;
|
|
|
|
unsigned char daset:1;
|
|
|
|
} global_deviceatlas = {
|
|
|
|
.loglevel = 0,
|
|
|
|
.jsonpath = 0,
|
|
|
|
.cookiename = 0,
|
|
|
|
.cookienamelen = 0,
|
|
|
|
.useragentid = 0,
|
|
|
|
.daset = 0,
|
|
|
|
.separator = '|',
|
|
|
|
};
|
2015-06-01 11:50:06 +00:00
|
|
|
|
|
|
|
static int da_json_file(char **args, int section_type, struct proxy *curpx,
|
|
|
|
struct proxy *defpx, const char *file, int line,
|
|
|
|
char **err)
|
|
|
|
{
|
|
|
|
if (*(args[1]) == 0) {
|
|
|
|
memprintf(err, "deviceatlas json file : expects a json path.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2016-12-21 20:25:06 +00:00
|
|
|
global_deviceatlas.jsonpath = strdup(args[1]);
|
2015-06-01 11:50:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int da_log_level(char **args, int section_type, struct proxy *curpx,
|
|
|
|
struct proxy *defpx, const char *file, int line,
|
|
|
|
char **err)
|
|
|
|
{
|
|
|
|
int loglevel;
|
|
|
|
if (*(args[1]) == 0) {
|
|
|
|
memprintf(err, "deviceatlas log level : expects an integer argument.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
loglevel = atol(args[1]);
|
|
|
|
if (loglevel < 0 || loglevel > 3) {
|
|
|
|
memprintf(err, "deviceatlas log level : expects a log level between 0 and 3, %s given.\n", args[1]);
|
|
|
|
} else {
|
2016-12-21 20:25:06 +00:00
|
|
|
global_deviceatlas.loglevel = (da_severity_t)loglevel;
|
2015-06-01 11:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int da_property_separator(char **args, int section_type, struct proxy *curpx,
|
|
|
|
struct proxy *defpx, const char *file, int line,
|
|
|
|
char **err)
|
|
|
|
{
|
|
|
|
if (*(args[1]) == 0) {
|
|
|
|
memprintf(err, "deviceatlas property separator : expects a character argument.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2016-12-21 20:25:06 +00:00
|
|
|
global_deviceatlas.separator = *args[1];
|
2015-06-01 11:50:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-09-25 13:16:30 +00:00
|
|
|
static int da_properties_cookie(char **args, int section_type, struct proxy *curpx,
|
|
|
|
struct proxy *defpx, const char *file, int line,
|
|
|
|
char **err)
|
|
|
|
{
|
|
|
|
if (*(args[1]) == 0) {
|
|
|
|
memprintf(err, "deviceatlas cookie name : expects a string argument.\n");
|
|
|
|
return -1;
|
|
|
|
} else {
|
2016-12-21 20:25:06 +00:00
|
|
|
global_deviceatlas.cookiename = strdup(args[1]);
|
2015-09-25 13:16:30 +00:00
|
|
|
}
|
2016-12-21 20:25:06 +00:00
|
|
|
global_deviceatlas.cookienamelen = strlen(global_deviceatlas.cookiename);
|
2015-09-25 13:16:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-01 11:50:06 +00:00
|
|
|
static size_t da_haproxy_read(void *ctx, size_t len, char *buf)
|
|
|
|
{
|
|
|
|
return fread(buf, 1, len, ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static da_status_t da_haproxy_seek(void *ctx, off_t off)
|
|
|
|
{
|
|
|
|
return fseek(ctx, off, SEEK_SET) != -1 ? DA_OK : DA_SYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void da_haproxy_log(da_severity_t severity, da_status_t status,
|
|
|
|
const char *fmt, va_list args)
|
|
|
|
{
|
2016-12-21 20:25:06 +00:00
|
|
|
if (global_deviceatlas.loglevel && severity <= global_deviceatlas.loglevel) {
|
2015-06-01 11:50:06 +00:00
|
|
|
char logbuf[256];
|
|
|
|
vsnprintf(logbuf, sizeof(logbuf), fmt, args);
|
2017-11-24 15:50:31 +00:00
|
|
|
ha_warning("deviceatlas : %s.\n", logbuf);
|
2015-06-01 11:50:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-25 13:16:30 +00:00
|
|
|
#define DA_COOKIENAME_DEFAULT "DAPROPS"
|
|
|
|
|
2016-12-21 19:39:16 +00:00
|
|
|
/*
|
|
|
|
* module init / deinit functions. Returns 0 if OK, or a combination of ERR_*.
|
|
|
|
*/
|
|
|
|
static int init_deviceatlas(void)
|
2015-06-01 11:50:06 +00:00
|
|
|
{
|
2016-12-21 19:39:16 +00:00
|
|
|
int err_code = 0;
|
|
|
|
|
2016-12-21 20:25:06 +00:00
|
|
|
if (global_deviceatlas.jsonpath != 0) {
|
2015-06-01 11:50:06 +00:00
|
|
|
FILE *jsonp;
|
|
|
|
da_property_decl_t extraprops[] = {{0, 0}};
|
|
|
|
size_t atlasimglen;
|
|
|
|
da_status_t status;
|
|
|
|
|
2016-12-21 20:25:06 +00:00
|
|
|
jsonp = fopen(global_deviceatlas.jsonpath, "r");
|
2015-06-01 11:50:06 +00:00
|
|
|
if (jsonp == 0) {
|
2017-11-24 15:50:31 +00:00
|
|
|
ha_alert("deviceatlas : '%s' json file has invalid path or is not readable.\n",
|
|
|
|
global_deviceatlas.jsonpath);
|
2016-12-21 19:39:16 +00:00
|
|
|
err_code |= ERR_ALERT | ERR_FATAL;
|
2015-06-01 11:50:06 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
da_init();
|
|
|
|
da_seterrorfunc(da_haproxy_log);
|
|
|
|
status = da_atlas_compile(jsonp, da_haproxy_read, da_haproxy_seek,
|
2016-12-21 20:25:06 +00:00
|
|
|
&global_deviceatlas.atlasimgptr, &atlasimglen);
|
2015-06-01 11:50:06 +00:00
|
|
|
fclose(jsonp);
|
|
|
|
if (status != DA_OK) {
|
2017-11-24 15:50:31 +00:00
|
|
|
ha_alert("deviceatlas : '%s' json file is invalid.\n",
|
|
|
|
global_deviceatlas.jsonpath);
|
2016-12-21 19:39:16 +00:00
|
|
|
err_code |= ERR_ALERT | ERR_FATAL;
|
2015-06-01 11:50:06 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2016-12-21 20:25:06 +00:00
|
|
|
status = da_atlas_open(&global_deviceatlas.atlas, extraprops,
|
|
|
|
global_deviceatlas.atlasimgptr, atlasimglen);
|
2015-06-01 11:50:06 +00:00
|
|
|
|
|
|
|
if (status != DA_OK) {
|
2017-11-24 15:50:31 +00:00
|
|
|
ha_alert("deviceatlas : data could not be compiled.\n");
|
2016-12-21 19:39:16 +00:00
|
|
|
err_code |= ERR_ALERT | ERR_FATAL;
|
2015-06-01 11:50:06 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2016-12-21 20:25:06 +00:00
|
|
|
if (global_deviceatlas.cookiename == 0) {
|
|
|
|
global_deviceatlas.cookiename = strdup(DA_COOKIENAME_DEFAULT);
|
|
|
|
global_deviceatlas.cookienamelen = strlen(global_deviceatlas.cookiename);
|
2015-09-25 13:16:30 +00:00
|
|
|
}
|
|
|
|
|
2016-12-21 20:25:06 +00:00
|
|
|
global_deviceatlas.useragentid = da_atlas_header_evidence_id(&global_deviceatlas.atlas,
|
2015-06-01 11:50:06 +00:00
|
|
|
"user-agent");
|
2016-12-21 20:25:06 +00:00
|
|
|
global_deviceatlas.daset = 1;
|
2015-06-01 11:50:06 +00:00
|
|
|
|
|
|
|
fprintf(stdout, "Deviceatlas module loaded.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2016-12-21 19:39:16 +00:00
|
|
|
return err_code;
|
2015-06-01 11:50:06 +00:00
|
|
|
}
|
|
|
|
|
2016-12-21 20:03:49 +00:00
|
|
|
static void deinit_deviceatlas(void)
|
2015-06-01 11:50:06 +00:00
|
|
|
{
|
2016-12-21 20:25:06 +00:00
|
|
|
if (global_deviceatlas.jsonpath != 0) {
|
|
|
|
free(global_deviceatlas.jsonpath);
|
2015-06-01 11:50:06 +00:00
|
|
|
}
|
|
|
|
|
2016-12-21 20:25:06 +00:00
|
|
|
if (global_deviceatlas.daset == 1) {
|
|
|
|
free(global_deviceatlas.cookiename);
|
|
|
|
da_atlas_close(&global_deviceatlas.atlas);
|
|
|
|
free(global_deviceatlas.atlasimgptr);
|
2015-06-01 11:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
da_fini();
|
|
|
|
}
|
|
|
|
|
2015-09-25 13:16:30 +00:00
|
|
|
static int da_haproxy(const struct arg *args, struct sample *smp, da_deviceinfo_t *devinfo)
|
2015-06-01 11:50:06 +00:00
|
|
|
{
|
2018-07-13 09:56:34 +00:00
|
|
|
struct buffer *tmp;
|
2015-06-01 11:50:06 +00:00
|
|
|
da_propid_t prop, *pprop;
|
|
|
|
da_status_t status;
|
2015-09-25 13:16:30 +00:00
|
|
|
da_type_t proptype;
|
|
|
|
const char *propname;
|
2015-06-01 11:50:06 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
tmp = get_trash_chunk();
|
|
|
|
chunk_reset(tmp);
|
|
|
|
|
2018-07-13 08:54:26 +00:00
|
|
|
propname = (const char *) args[0].data.str.area;
|
2015-06-01 11:50:06 +00:00
|
|
|
i = 0;
|
|
|
|
|
2018-07-13 08:54:26 +00:00
|
|
|
for (; propname != 0; i ++,
|
|
|
|
propname = (const char *) args[i].data.str.area) {
|
2016-12-21 20:25:06 +00:00
|
|
|
status = da_atlas_getpropid(&global_deviceatlas.atlas,
|
2015-06-01 11:50:06 +00:00
|
|
|
propname, &prop);
|
|
|
|
if (status != DA_OK) {
|
2016-12-21 20:25:06 +00:00
|
|
|
chunk_appendf(tmp, "%c", global_deviceatlas.separator);
|
2015-06-01 11:50:06 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
pprop = ∝
|
2016-12-21 20:25:06 +00:00
|
|
|
da_atlas_getproptype(&global_deviceatlas.atlas, *pprop, &proptype);
|
2015-06-01 11:50:06 +00:00
|
|
|
|
|
|
|
switch (proptype) {
|
|
|
|
case DA_TYPE_BOOLEAN: {
|
|
|
|
bool val;
|
2015-09-25 13:16:30 +00:00
|
|
|
status = da_getpropboolean(devinfo, *pprop, &val);
|
2015-06-01 11:50:06 +00:00
|
|
|
if (status == DA_OK) {
|
|
|
|
chunk_appendf(tmp, "%d", val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DA_TYPE_INTEGER:
|
|
|
|
case DA_TYPE_NUMBER: {
|
|
|
|
long val;
|
2015-09-25 13:16:30 +00:00
|
|
|
status = da_getpropinteger(devinfo, *pprop, &val);
|
2015-06-01 11:50:06 +00:00
|
|
|
if (status == DA_OK) {
|
|
|
|
chunk_appendf(tmp, "%ld", val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DA_TYPE_STRING: {
|
|
|
|
const char *val;
|
2015-09-25 13:16:30 +00:00
|
|
|
status = da_getpropstring(devinfo, *pprop, &val);
|
2015-06-01 11:50:06 +00:00
|
|
|
if (status == DA_OK) {
|
|
|
|
chunk_appendf(tmp, "%s", val);
|
|
|
|
}
|
|
|
|
break;
|
2015-09-25 13:16:30 +00:00
|
|
|
}
|
2015-06-01 11:50:06 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-12-21 20:25:06 +00:00
|
|
|
chunk_appendf(tmp, "%c", global_deviceatlas.separator);
|
2015-06-01 11:50:06 +00:00
|
|
|
}
|
|
|
|
|
2015-09-25 13:16:30 +00:00
|
|
|
da_close(devinfo);
|
2015-06-01 11:50:06 +00:00
|
|
|
|
2018-07-13 08:54:26 +00:00
|
|
|
if (tmp->data) {
|
|
|
|
--tmp->data;
|
|
|
|
tmp->area[tmp->data] = 0;
|
2015-06-01 11:50:06 +00:00
|
|
|
}
|
|
|
|
|
2018-07-13 08:54:26 +00:00
|
|
|
smp->data.u.str.area = tmp->area;
|
|
|
|
smp->data.u.str.data = tmp->data;
|
2019-07-10 20:19:24 +00:00
|
|
|
smp->data.type = SMP_T_STR;
|
2015-06-01 11:50:06 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-09-25 13:16:30 +00:00
|
|
|
static int da_haproxy_conv(const struct arg *args, struct sample *smp, void *private)
|
|
|
|
{
|
|
|
|
da_deviceinfo_t devinfo;
|
|
|
|
da_status_t status;
|
|
|
|
const char *useragent;
|
|
|
|
char useragentbuf[1024] = { 0 };
|
|
|
|
int i;
|
|
|
|
|
2018-07-13 08:54:26 +00:00
|
|
|
if (global_deviceatlas.daset == 0 || smp->data.u.str.data == 0) {
|
2015-09-25 13:16:30 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-07-13 08:54:26 +00:00
|
|
|
i = smp->data.u.str.data > sizeof(useragentbuf) ? sizeof(useragentbuf) : smp->data.u.str.data;
|
|
|
|
memcpy(useragentbuf, smp->data.u.str.area, i - 1);
|
2015-09-25 13:16:30 +00:00
|
|
|
useragentbuf[i - 1] = 0;
|
|
|
|
|
|
|
|
useragent = (const char *)useragentbuf;
|
|
|
|
|
2016-12-21 20:25:06 +00:00
|
|
|
status = da_search(&global_deviceatlas.atlas, &devinfo,
|
|
|
|
global_deviceatlas.useragentid, useragent, 0);
|
2015-09-25 13:16:30 +00:00
|
|
|
|
|
|
|
return status != DA_OK ? 0 : da_haproxy(args, smp, &devinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DA_MAX_HEADERS 24
|
|
|
|
|
|
|
|
static int da_haproxy_fetch(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
|
|
|
{
|
|
|
|
da_evidence_t ev[DA_MAX_HEADERS];
|
|
|
|
da_deviceinfo_t devinfo;
|
|
|
|
da_status_t status;
|
2019-04-24 19:41:53 +00:00
|
|
|
struct channel *chn;
|
2019-07-15 12:36:03 +00:00
|
|
|
struct htx *htx;
|
|
|
|
struct htx_blk *blk;
|
2015-09-25 13:16:30 +00:00
|
|
|
char vbuf[DA_MAX_HEADERS][1024] = {{ 0 }};
|
|
|
|
int i, nbh = 0;
|
|
|
|
|
2016-12-21 20:25:06 +00:00
|
|
|
if (global_deviceatlas.daset == 0) {
|
2019-04-24 19:41:53 +00:00
|
|
|
return 0;
|
2015-09-25 13:16:30 +00:00
|
|
|
}
|
|
|
|
|
2019-04-24 19:41:53 +00:00
|
|
|
chn = (smp->strm ? &smp->strm->req : NULL);
|
2019-07-15 12:36:03 +00:00
|
|
|
htx = smp_prefetch_htx(smp, chn, 1);
|
|
|
|
if (!htx)
|
|
|
|
return 0;
|
2015-09-25 13:16:30 +00:00
|
|
|
|
2019-07-15 12:36:03 +00:00
|
|
|
i = 0;
|
|
|
|
for (blk = htx_get_first_blk(htx); nbh < DA_MAX_HEADERS && blk; blk = htx_get_next_blk(htx, blk)) {
|
|
|
|
size_t vlen;
|
|
|
|
char *pval;
|
|
|
|
da_evidence_id_t evid;
|
|
|
|
enum htx_blk_type type;
|
|
|
|
struct ist n, v;
|
|
|
|
char hbuf[24] = { 0 };
|
|
|
|
char tval[1024] = { 0 };
|
|
|
|
|
|
|
|
type = htx_get_blk_type(blk);
|
|
|
|
|
|
|
|
if (type == HTX_BLK_HDR) {
|
|
|
|
n = htx_get_blk_name(htx, blk);
|
|
|
|
v = htx_get_blk_value(htx, blk);
|
|
|
|
} else if (type == HTX_BLK_EOH) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
2019-04-24 19:41:53 +00:00
|
|
|
|
2019-07-15 12:36:03 +00:00
|
|
|
/* The HTTP headers used by the DeviceAtlas API are not longer */
|
|
|
|
if (n.len >= sizeof(hbuf)) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-04-24 19:41:53 +00:00
|
|
|
|
2019-07-15 12:36:03 +00:00
|
|
|
memcpy(hbuf, n.ptr, n.len);
|
|
|
|
hbuf[n.len] = 0;
|
|
|
|
pval = v.ptr;
|
|
|
|
vlen = v.len;
|
|
|
|
evid = -1;
|
|
|
|
i = v.len > sizeof(tval) - 1 ? sizeof(tval) - 1 : v.len;
|
|
|
|
memcpy(tval, v.ptr, i);
|
|
|
|
tval[i] = 0;
|
|
|
|
pval = tval;
|
|
|
|
|
|
|
|
if (strcasecmp(hbuf, "Accept-Language") == 0) {
|
|
|
|
evid = da_atlas_accept_language_evidence_id(&global_deviceatlas.atlas);
|
|
|
|
} else if (strcasecmp(hbuf, "Cookie") == 0) {
|
|
|
|
char *p, *eval;
|
|
|
|
size_t pl;
|
|
|
|
|
|
|
|
eval = pval + vlen;
|
|
|
|
/**
|
|
|
|
* The cookie value, if it exists, is located between the current header's
|
|
|
|
* value position and the next one
|
|
|
|
*/
|
|
|
|
if (http_extract_cookie_value(pval, eval, global_deviceatlas.cookiename,
|
|
|
|
global_deviceatlas.cookienamelen, 1, &p, &pl) == NULL) {
|
2019-04-24 19:41:53 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-07-15 12:36:03 +00:00
|
|
|
vlen -= global_deviceatlas.cookienamelen - 1;
|
|
|
|
pval = p;
|
|
|
|
evid = da_atlas_clientprop_evidence_id(&global_deviceatlas.atlas);
|
|
|
|
} else {
|
|
|
|
evid = da_atlas_header_evidence_id(&global_deviceatlas.atlas, hbuf);
|
2015-09-25 13:16:30 +00:00
|
|
|
}
|
|
|
|
|
2019-07-15 12:36:03 +00:00
|
|
|
if (evid == -1) {
|
|
|
|
continue;
|
2019-04-24 19:41:53 +00:00
|
|
|
}
|
2019-07-15 12:36:03 +00:00
|
|
|
|
|
|
|
i = vlen > sizeof(vbuf[nbh]) - 1 ? sizeof(vbuf[nbh]) - 1 : vlen;
|
|
|
|
memcpy(vbuf[nbh], pval, i);
|
|
|
|
vbuf[nbh][i] = 0;
|
|
|
|
ev[nbh].key = evid;
|
|
|
|
ev[nbh].value = vbuf[nbh];
|
|
|
|
++ nbh;
|
2015-09-25 13:16:30 +00:00
|
|
|
}
|
|
|
|
|
2016-12-21 20:25:06 +00:00
|
|
|
status = da_searchv(&global_deviceatlas.atlas, &devinfo,
|
2015-09-25 13:16:30 +00:00
|
|
|
ev, nbh);
|
|
|
|
|
|
|
|
return status != DA_OK ? 0 : da_haproxy(args, smp, &devinfo);
|
|
|
|
}
|
|
|
|
|
2015-06-01 13:42:29 +00:00
|
|
|
static struct cfg_kw_list dacfg_kws = {{ }, {
|
|
|
|
{ CFG_GLOBAL, "deviceatlas-json-file", da_json_file },
|
2019-04-24 19:41:53 +00:00
|
|
|
{ CFG_GLOBAL, "deviceatlas-log-level", da_log_level },
|
|
|
|
{ CFG_GLOBAL, "deviceatlas-property-separator", da_property_separator },
|
|
|
|
{ CFG_GLOBAL, "deviceatlas-properties-cookie", da_properties_cookie },
|
|
|
|
{ 0, NULL, NULL },
|
2015-06-01 13:42:29 +00:00
|
|
|
}};
|
|
|
|
|
2018-11-25 18:14:37 +00:00
|
|
|
INITCALL1(STG_REGISTER, cfg_register_keywords, &dacfg_kws);
|
|
|
|
|
2015-09-25 13:16:30 +00:00
|
|
|
/* Note: must not be declared <const> as its list will be overwritten */
|
|
|
|
static struct sample_fetch_kw_list fetch_kws = {ILH, {
|
2016-03-16 10:09:55 +00:00
|
|
|
{ "da-csv-fetch", da_haproxy_fetch, ARG12(1,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR), NULL, SMP_T_STR, SMP_USE_HRQHV },
|
2019-04-24 19:41:53 +00:00
|
|
|
{ NULL, NULL, 0, 0, 0 },
|
2015-09-25 13:16:30 +00:00
|
|
|
}};
|
|
|
|
|
2018-11-25 18:14:37 +00:00
|
|
|
INITCALL1(STG_REGISTER, sample_register_fetches, &fetch_kws);
|
|
|
|
|
2015-06-01 13:39:50 +00:00
|
|
|
/* Note: must not be declared <const> as its list will be overwritten */
|
|
|
|
static struct sample_conv_kw_list conv_kws = {ILH, {
|
2016-03-16 10:09:55 +00:00
|
|
|
{ "da-csv-conv", da_haproxy_conv, ARG12(1,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR), NULL, SMP_T_STR, SMP_T_STR },
|
2019-04-24 19:41:53 +00:00
|
|
|
{ NULL, NULL, 0, 0, 0 },
|
2015-06-01 13:39:50 +00:00
|
|
|
}};
|
|
|
|
|
2019-04-26 12:02:28 +00:00
|
|
|
static void da_haproxy_register_build_options()
|
|
|
|
{
|
|
|
|
char *ptr = NULL;
|
|
|
|
|
|
|
|
#ifdef MOBI_DA_DUMMY_LIBRARY
|
|
|
|
memprintf(&ptr, "Built with DeviceAtlas support (dummy library only).");
|
|
|
|
#else
|
|
|
|
memprintf(&ptr, "Built with DeviceAtlas support (library version %u.%u).", MOBI_DA_MAJOR, MOBI_DA_MINOR);
|
|
|
|
#endif
|
|
|
|
hap_register_build_opts(ptr, 1);
|
|
|
|
}
|
|
|
|
|
2018-11-25 18:14:37 +00:00
|
|
|
INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws);
|
|
|
|
|
2018-11-26 10:21:50 +00:00
|
|
|
REGISTER_POST_CHECK(init_deviceatlas);
|
|
|
|
REGISTER_POST_DEINIT(deinit_deviceatlas);
|
2019-04-26 12:02:28 +00:00
|
|
|
INITCALL0(STG_REGISTER, da_haproxy_register_build_options);
|