Browse Source

* rename cmd: exists -> check

master
Alex 'AdUser' Z 9 years ago
parent
commit
d3b671ebd3
  1. 4
      src/backend-test.c
  2. 4
      src/backend.c
  3. 2
      src/backend.h
  4. 2
      src/backends/backend.h
  5. 15
      src/backends/exec.c

4
src/backend-test.c

@ -48,8 +48,8 @@ int main(int argc, char *argv[]) {
goto cleanup;
}
if (!backend->exists(backend->cfg, ip)) {
f2b_log_msg(log_error, "action 'exists' failed");
if (!backend->check(backend->cfg, ip)) {
f2b_log_msg(log_error, "action 'check' failed");
goto cleanup;
}

4
src/backend.c

@ -38,9 +38,9 @@ f2b_backend_create(f2b_config_section_t *config, const char *id) {
goto cleanup;
if ((*(void **) (&backend->ban) = dlsym(backend->h, "ban")) == NULL)
goto cleanup;
if ((*(void **) (&backend->unban) = dlsym(backend->h, "unban")) == NULL)
if ((*(void **) (&backend->check) = dlsym(backend->h, "check")) == NULL)
goto cleanup;
if ((*(void **) (&backend->exists) = dlsym(backend->h, "exists")) == NULL)
if ((*(void **) (&backend->unban) = dlsym(backend->h, "unban")) == NULL)
goto cleanup;
if ((*(void **) (&backend->destroy) = dlsym(backend->h, "destroy")) == NULL)
goto cleanup;

2
src/backend.h

@ -14,8 +14,8 @@ typedef struct f2b_backend_t {
bool (*stop) (void *cfg);
bool (*ping) (void *cfg);
bool (*ban) (void *cfg, const char *ip);
bool (*check) (void *cfg, const char *ip);
bool (*unban) (void *cfg, const char *ip);
bool (*exists) (void *cfg, const char *ip);
void (*destroy) (void *cfg);
} f2b_backend_t;

2
src/backends/backend.h

@ -11,6 +11,6 @@ extern bool start(cfg_t *c);
extern bool stop(cfg_t *c);
extern bool ping(cfg_t *c);
extern bool ban(cfg_t *c, const char *ip);
extern bool check(cfg_t *c, const char *ip);
extern bool unban(cfg_t *c, const char *ip);
extern bool exists(cfg_t *c, const char *ip);
extern void destroy(cfg_t *c);

15
src/backends/exec.c

@ -24,7 +24,7 @@ struct _config {
cmd_t *stop;
cmd_t *ban;
cmd_t *unban;
cmd_t *exists;
cmd_t *check;
};
static cmd_t *
@ -167,7 +167,7 @@ config(cfg_t *cfg, const char *key, const char *value) {
CREATE_CMD(stop)
CREATE_CMD(ban)
CREATE_CMD(unban)
CREATE_CMD(exists)
CREATE_CMD(check)
return false;
}
@ -217,16 +217,15 @@ unban(cfg_t *cfg, const char *ip) {
}
bool
exists(cfg_t *cfg, const char *ip) {
check(cfg_t *cfg, const char *ip) {
assert(cfg != NULL && ip != NULL);
if (!cfg->exists)
return true;
if (!cfg->check)
return false;
return cmd_list_exec(cfg->exists, ip, cfg->timeout);
return cmd_list_exec(cfg->check, ip, cfg->timeout);
}
bool
ping(cfg_t *cfg) {
return cfg != NULL;
@ -241,6 +240,6 @@ destroy(cfg_t *cfg) {
cmd_list_destroy(cfg->stop);
cmd_list_destroy(cfg->ban);
cmd_list_destroy(cfg->unban);
cmd_list_destroy(cfg->exists);
cmd_list_destroy(cfg->check);
free(cfg);
}

Loading…
Cancel
Save