This adds a new redis mode rpush. Also more consistent config keywords orientated at the redis command: lpush and publish.
Keeping list and channel config keywords for backwards compatibility. Removed unnecessary checks.
#redis:
# server: 127.0.0.1
# port: 6379
- # mode: list ## possible values: list (default), channel
+ # mode: list ## possible values: list|lpush (default), rpush, channel|publish
+ # ## lpush and rpush are using a Redis list. "list" is an alias for lpush
+ # ## publish is using a Redis channel. "channel" is an alias for publish
# key: suricata ## key or channel to use (default to suricata)
# Redis pipelining set up. This will enable to only do a query every
# 'batch-size' events. This should lower the latency induced by network
#redis:
# server: 127.0.0.1
# port: 6379
- # mode: list ## possible values: list (default), channel
+ # mode: list ## possible values: list|lpush (default), rpush, channel|publish
+ # ## lpush and rpush are using a Redis list. "list" is an alias for lpush
+ # ## publish is using a Redis channel. "channel" is an alias for publish
# key: suricata ## key or channel to use (default to suricata)
# Redis pipelining set up. This will enable to only do a query every
# 'batch-size' events. This should lower the latency induced by network
#redis:
# server: 127.0.0.1
# port: 6379
- # mode: list ## possible values: list (default), channel
+ # mode: list ## possible values: list|lpush (default), rpush, channel|publish
+ # ## lpush and rpush are using a Redis list. "list" is an alias for lpush
+ # ## publish is using a Redis channel. "channel" is an alias for publish
# key: suricata ## key or channel to use (default to suricata)
# Redis pipelining set up. This will enable to only do a query every
# 'batch-size' events. This should lower the latency induced by network
CASE_CODE(SC_WARN_REMOVE_FILE);
CASE_CODE (SC_ERR_NO_MAGIC_SUPPORT);
CASE_CODE (SC_ERR_REDIS);
+ CASE_CODE (SC_ERR_REDIS_CONFIG);
}
return "UNKNOWN_ERROR";
SC_WARN_REMOVE_FILE,
SC_ERR_NO_MAGIC_SUPPORT,
SC_ERR_REDIS,
+ SC_ERR_REDIS_CONFIG,
} SCError;
const char *SCErrorToString(SCError);
#include "util-logopenfile.h"
#include "util-logopenfile-tile.h"
-const char * redis_push_cmd = "LPUSH";
+const char * redis_lpush_cmd = "LPUSH";
+const char * redis_rpush_cmd = "RPUSH";
const char * redis_publish_cmd = "PUBLISH";
/** \brief connect to the indicated local stream socket, logging any errors
}
}
- if (!strcmp(redis_mode, "list")) {
- log_ctx->redis_setup.command = redis_push_cmd;
- if (!log_ctx->redis_setup.command) {
- SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate redis key command");
- exit(EXIT_FAILURE);
- }
- } else {
+ if (!strcmp(redis_mode, "list") || !strcmp(redis_mode,"lpush")) {
+ log_ctx->redis_setup.command = redis_lpush_cmd;
+ } else if(!strcmp(redis_mode, "rpush")){
+ log_ctx->redis_setup.command = redis_rpush_cmd;
+ } else if(!strcmp(redis_mode,"channel") || !strcmp(redis_mode,"publish")) {
log_ctx->redis_setup.command = redis_publish_cmd;
- if (!log_ctx->redis_setup.command) {
- SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate redis key command");
- exit(EXIT_FAILURE);
- }
+ } else {
+ SCLogError(SC_ERR_REDIS_CONFIG,"Invalid redis mode");
+ exit(EXIT_FAILURE);
}
+
redisContext *c = redisConnect(redis_server, atoi(redis_port));
if (c != NULL && c->err) {
SCLogError(SC_ERR_SOCKET, "Error connecting to redis server: %s", c->errstr);
#redis:
# server: 127.0.0.1
# port: 6379
- # mode: list ## possible values: list (default), channel
+ # mode: list ## possible values: list|lpush (default), rpush, channel|publish
+ # ## lpush and rpush are using a Redis list. "list" is an alias for lpush
+ # ## publish is using a Redis channel. "channel" is an alias for publish
# key: suricata ## key or channel to use (default to suricata)
# Redis pipelining set up. This will enable to only do a query every
# 'batch-size' events. This should lower the latency induced by network