Example #1
0
int rediscsvmodule_init(struct state_conf *conf, UNUSED char **fields, UNUSED int fieldlens)
{
	buffer = xcalloc(BUFFER_SIZE, sizeof(char*));
	buffer_fill = 0;
	if (conf->output_args) {
		redisconf_t *rconf = redis_parse_connstr(conf->output_args);
		if (rconf->type == T_TCP) {
			log_info("redis-module", "{type: TCP, server: %s, "
					"port: %u, list: %s}", rconf->server,
					rconf->port, rconf->list_name);
		} else {
			log_info("redis-module", "{type: LOCAL, path: %s, "
					"list: %s}", rconf->path, rconf->list_name);
		}
		queue_name = rconf->list_name;
	} else {
		queue_name = strdup("zmap");
	}
	// generate field names CSV list to be logged.
	char *fieldstring = xcalloc(1000, fieldlens);
	memset(fieldstring, 0, sizeof(fields));
        for (int i=0; i < fieldlens; i++) {
                if (i) {
                        strcat(fieldstring, ", ");
                }
		strcat(fieldstring, fields[i]);
        }
	log_info("redis-csv", "the following fields will be output to redis: %s.",
			fieldstring);
	free(fields);
	return redis_init(conf->output_args);
}
Example #2
0
File: redis.c Project: Fale/zmap
redisContext* redis_connect(char *connstr)
{
	assert(connstr);
	redisconf_t rconf;
	redisconf_t *c = &rconf;
	// handle old behavior where we only connected to a specific
	// socket that we #defined.
	if (!connstr) {
		c->type = T_LOCAL;
		c->path = strdup("/tmp/redis.sock");
	} else {
		int retv = redis_parse_connstr(connstr, c);
		log_error("redis", "Could not connect: %s", c->error);
		if (retv != ZMAP_REDIS_ERROR) {
			return NULL;
		}
	}
	return redis_connect_from_conf(c);
}
Example #3
0
static int redismodule_init(struct state_conf *conf, char **fields, int fieldlens)
{
	assert(fieldlens == 1);
	buffer = calloc(BUFFER_SIZE, sizeof(uint32_t));
	assert(buffer);
	buffer_fill = 0;

	if (conf->output_args) { 
		redisconf_t *rconf = redis_parse_connstr(conf->output_args);
		if (rconf->type == T_TCP) {
			log_info("redis-module", "{type: TCP, server: %s, "
					"port: %u, list: %s}", rconf->server, 
					rconf->port, rconf->list_name);
		} else {
			log_info("redis-module", "{type: LOCAL, path: %s, "
					"list: %s}", rconf->path, rconf->list_name);
		}
		queue_name = rconf->list_name;
	} else {
		queue_name = "zmap_output";
	}
	return redis_init(conf->output_args);
}