Browse Source

* add skeleton of redis backend

master
Alex 'AdUser' Z 8 years ago
parent
commit
df2afced2c
  1. 7
      configs/conf-available/10-backend-redis.conf
  2. 79
      src/backends/redis.c

7
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

79
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 <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <hiredis.h>
#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) {
}
Loading…
Cancel
Save