From 8930e401fcfcfd2a0b631ec2d915840bae8df06c Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Fri, 23 Oct 2015 17:03:19 +0200 Subject: [PATCH] new recorder option --norec --- README.md | 5 +++++ recorder.c | 9 +++++++++ udata.h | 1 + 3 files changed, 15 insertions(+) diff --git a/README.md b/README.md index 0e8f2ff..624c754 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,11 @@ Note in particular the `--hosted` option: you specify neither a host name or a p When the recorder has received a publish or two, visit it with your favorite Web browser by pointing your browser at `http://127.0.0.1:8083`. +### Recorder options + +`--norec` disables writing of REC files, so no location history or other similar publishes are stored, and the Lua `otr_putrec()` function is not invoked even if it exists. What is stored are CARDS and PHOTOS, as well as the LAST location of a device. As such, the API's `/locations` endpoint becomes useless. + + ## Design decisions We took a number of decisions for the design of the recorder and its utilities: diff --git a/recorder.c b/recorder.c index 6274592..a21b428 100644 --- a/recorder.c +++ b/recorder.c @@ -306,6 +306,9 @@ static void putrec(struct udata *ud, time_t now, UT_string *reltopic, UT_string FILE *fp; int rc = 0; + if (ud->norec) + return; + #ifdef WITH_LUA rc = hooks_norec(ud, UB(username), UB(device), string); #endif @@ -1002,6 +1005,7 @@ void usage(char *prog) #endif printf(" --precision ghash precision (dflt: %d)\n", GHASHPREC); printf(" --hosted use OwnTracks Hosted\n"); + printf(" --norec don't maintain REC files\n"); printf("\n"); printf("Options override these environment variables:\n"); printf(" $OTR_HOST MQTT hostname\n"); @@ -1045,6 +1049,7 @@ int main(int argc, char **argv) udata.skipdemo = TRUE; udata.revgeo = TRUE; udata.verbose = TRUE; + udata.norec = FALSE; #ifdef WITH_LMDB udata.gc = NULL; udata.t2t = NULL; /* Topic to TID */ @@ -1100,6 +1105,7 @@ int main(int argc, char **argv) { "quiet", no_argument, 0, 8}, { "initialize", no_argument, 0, 9}, { "label", required_argument, 0, 10}, + { "norec", no_argument, 0, 11}, #ifdef WITH_LUA { "lua-script", required_argument, 0, 7}, #endif @@ -1117,6 +1123,9 @@ int main(int argc, char **argv) break; switch (ch) { + case 11: + udata.norec = TRUE; + break; case 10: free(udata.label); udata.label = strdup(optarg); diff --git a/udata.h b/udata.h index 2eaed02..00cd7c8 100644 --- a/udata.h +++ b/udata.h @@ -19,6 +19,7 @@ struct udata { int revgeo; /* True (default) if we should do reverse Geo lookups */ int qos; /* Subscribe QoS */ int verbose; /* TRUE if print verbose messages to stdout */ + int norec; /* If TRUE, no .REC files are written to */ #ifdef WITH_LMDB struct gcache *gc; struct gcache *t2t; /* topic to tid */