From 778a69962205829ed728b77d9747515db8c24132 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Mon, 2 Jun 2025 16:54:16 -0600 Subject: [PATCH] lua: simplify streaming output setup Setup the init function to simply return: {streaming = "tcp"} or {streaming = "http"} The returned table can have a lot of parameters that don't make sense together, this should simplify this one case. --- doc/userguide/lua/lua-functions.rst | 10 ++-------- src/output-lua.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/doc/userguide/lua/lua-functions.rst b/doc/userguide/lua/lua-functions.rst index de38f03aed..708ee96b9a 100644 --- a/doc/userguide/lua/lua-functions.rst +++ b/doc/userguide/lua/lua-functions.rst @@ -219,10 +219,7 @@ according to the host OS settings. :: function init (args) - local needs = {} - needs["type"] = "streaming" - needs["filter"] = "tcp" - return needs + return {streaming = "tcp"} end In case of HTTP body data, the bodies are unzipped and dechunked if applicable. @@ -230,10 +227,7 @@ In case of HTTP body data, the bodies are unzipped and dechunked if applicable. :: function init (args) - local needs = {} - needs["type"] = "streaming" - needs["protocol"] = "http" - return needs + return {streaming = "http"} end The streaming data will be provided in the ``args`` to the log diff --git a/src/output-lua.c b/src/output-lua.c index 77597220ab..15b1d440ca 100644 --- a/src/output-lua.c +++ b/src/output-lua.c @@ -505,7 +505,17 @@ static int LuaScriptInit(const char *filename, LogLuaScriptOptions *options, Log SCLogDebug("k='%s', v='%s'", k, v); - if (strcmp(k,"protocol") == 0 && strcmp(v, "http") == 0) + if (strcmp(k, "streaming") == 0) { + options->streaming = 1; + if (strcmp(v, "http") == 0) { + options->alproto = ALPROTO_HTTP1; + } else if (strcmp(v, "tcp") == 0) { + options->tcp_data = 1; + } else { + SCLogError("unsupported streaming argument: %s", v); + goto error; + } + } else if (strcmp(k, "protocol") == 0 && strcmp(v, "http") == 0) options->alproto = ALPROTO_HTTP1; else if (strcmp(k,"protocol") == 0 && strcmp(v, "dns") == 0) options->alproto = ALPROTO_DNS; -- 2.47.2