diff --git a/configs/conf-available/10-backend-redis.conf b/configs/conf-available/10-backend-redis.conf new file mode 100644 index 0000000..b0dc542 --- /dev/null +++ b/configs/conf-available/10-backend-redis.conf @@ -0,0 +1,7 @@ +[backend:redis] +load = libf2b_backend_redis.so +shared = no +timeout = 2 +server = 127.0.0.1 +port = 6379 +database = 0 diff --git a/src/backends/redis.c b/src/backends/redis.c new file mode 100644 index 0000000..85d3095 --- /dev/null +++ b/src/backends/redis.c @@ -0,0 +1,79 @@ +/* Copyright 2016 Alex 'AdUser' Z (ad_user@runbox.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "backend.h" + +struct _config { + char name[ID_MAX + 1]; + char error[256]; + bool shared; + struct timeval timeout; + uint8_t database; + char server[32]; + uint16_t port; + redisContext *conn; +}; + +/* handlers */ +cfg_t * +create(const char *id) { +} + +bool +ready(cfg_t *cfg) { +} + +char * +error(cfg_t *cfg) { +} + +bool +start(cfg_t *cfg) { +} + +bool +stop(cfg_t *cfg) { +} + +bool +ban(cfg_t *cfg, const char *ip) { +} + +bool +unban(cfg_t *cfg, const char *ip) { +} + +bool +check(cfg_t *cfg, const char *ip) { +} + +bool +ping(cfg_t *cfg) { + assert(cfg != NULL); + redisReply *reply = redisCommand(cfg->conn, "PING"); + if (reply) { + freeReplyObject(reply); + return true; + } + return false; +} + +void +destroy(cfg_t *cfg) { +}