Browse Source

* update csocket responces

master
Alex 'AdUser' Z 4 years ago
parent
commit
f92c18b415
  1. 2
      src/csocket.c
  2. 10
      src/daemon.c
  3. 4
      src/filter.c
  4. 6
      src/jail.c

2
src/csocket.c

@ -111,7 +111,7 @@ f2b_conn_process(f2b_conn_t *conn, bool in, void (*cb)(const f2b_cmd_t *cmd, f2b
cb(cmd, &conn->send); /* handle command */ cb(cmd, &conn->send); /* handle command */
f2b_cmd_destroy(cmd); f2b_cmd_destroy(cmd);
} else { } else {
f2b_buf_append(&conn->send, "can't parse input, try 'help'\n", 0); f2b_buf_append(&conn->send, "-can't parse input, try 'help'\n", 0);
} }
free(line); free(line);
} }

10
src/daemon.c

@ -103,7 +103,7 @@ f2b_csocket_cmd_process(const f2b_cmd_t *cmd, f2b_buf_t *res) {
if (cmd->type >= CMD_JAIL_STATUS && cmd->type <= CMD_JAIL_FILTER_RELOAD) { if (cmd->type >= CMD_JAIL_STATUS && cmd->type <= CMD_JAIL_FILTER_RELOAD) {
if ((jail = f2b_jail_find(jails, cmd->args[1])) == NULL) { if ((jail = f2b_jail_find(jails, cmd->args[1])) == NULL) {
len = snprintf(buf, sizeof(buf), "can't find jail '%s'\n", cmd->args[1]); len = snprintf(buf, sizeof(buf), "-can't find jail '%s'\n", cmd->args[1]);
f2b_buf_append(res, buf, len); f2b_buf_append(res, buf, len);
return; return;
} }
@ -154,21 +154,21 @@ f2b_csocket_cmd_process(const f2b_cmd_t *cmd, f2b_buf_t *res) {
f2b_filter_cmd_stats(buf, sizeof(buf), jail->filter); f2b_filter_cmd_stats(buf, sizeof(buf), jail->filter);
f2b_buf_append(res, buf, 0); f2b_buf_append(res, buf, 0);
} else { } else {
f2b_buf_append(res, "this jail has no filter\n", 0); f2b_buf_append(res, "-this jail has no filter\n", 0);
} }
} else if (cmd->type == CMD_JAIL_FILTER_RELOAD) { } else if (cmd->type == CMD_JAIL_FILTER_RELOAD) {
if (jail->flags & JAIL_HAS_FILTER) { if (jail->flags & JAIL_HAS_FILTER) {
f2b_filter_cmd_reload(buf, sizeof(buf), jail->filter); f2b_filter_cmd_reload(buf, sizeof(buf), jail->filter);
f2b_buf_append(res, buf, 0); f2b_buf_append(res, buf, 0);
} else { } else {
f2b_buf_append(res, "this jail has no filter\n", 0); f2b_buf_append(res, "-this jail has no filter\n", 0);
} }
} else { } else {
f2b_buf_append(res, "error: unknown command\n", 0); f2b_buf_append(res, "-error: unknown command\n", 0);
} }
if (res->used == 0) if (res->used == 0)
f2b_buf_append(res, "ok\n", 3); /* default reply if not set above */ f2b_buf_append(res, "+ok\n", 3); /* default reply if not set above */
return; return;
} }

4
src/filter.c

@ -240,8 +240,8 @@ f2b_filter_cmd_reload(char *buf, size_t bufsize, f2b_filter_t *filter) {
filter->flush(filter->cfg); filter->flush(filter->cfg);
if ((c = f2b_filter_load_file(filter, filter->init)) > 0) { if ((c = f2b_filter_load_file(filter, filter->init)) > 0) {
snprintf(buf, bufsize, "loaded %zu regexps\n", c); snprintf(buf, bufsize, "+loaded %zu regexps\n", c);
} else { } else {
snprintf(buf, bufsize, "can't reload filter\n"); snprintf(buf, bufsize, "-can't reload filter\n");
} }
} }

6
src/jail.c

@ -586,7 +586,7 @@ f2b_jail_cmd_set(char *res, size_t ressize, f2b_jail_t *jail, const char *param,
if (f2b_jail_set_param(jail, param, value)) if (f2b_jail_set_param(jail, param, value))
return; return;
snprintf(res, ressize, "parameter not found: %s", param); snprintf(res, ressize, "-parameter not found: %s", param);
} }
/** /**
@ -612,7 +612,7 @@ f2b_jail_cmd_ip_xxx(char *res, size_t ressize, f2b_jail_t *jail, int op, const c
/* ban */ /* ban */
time_t now = time(NULL); time_t now = time(NULL);
if ((addr = f2b_ipaddr_create(ip)) == NULL) { if ((addr = f2b_ipaddr_create(ip)) == NULL) {
snprintf(res, ressize, "can't parse ip address: %s", ip); snprintf(res, ressize, "-can't parse ip address: %s", ip);
return; return;
} }
addr->lastseen = now; addr->lastseen = now;
@ -625,7 +625,7 @@ f2b_jail_cmd_ip_xxx(char *res, size_t ressize, f2b_jail_t *jail, int op, const c
jail->sfile->need_save = true; jail->sfile->need_save = true;
} else { } else {
/* unban & status */ /* unban & status */
snprintf(res, ressize, "can't find ip '%s' in jail '%s'\n", ip, jail->name); snprintf(res, ressize, "-can't find ip '%s' in jail '%s'\n", ip, jail->name);
return; return;
} }
} }

Loading…
Cancel
Save