diff --git a/src/csocket.c b/src/csocket.c index 8851d19..50ceb17 100644 --- a/src/csocket.c +++ b/src/csocket.c @@ -99,7 +99,7 @@ f2b_conn_process(f2b_conn_t *conn, bool in, void (*cb)(const f2b_cmd_t *cmd, f2b cb(cmd, &conn->send); /* handle command */ f2b_cmd_destroy(cmd); } else { - f2b_buf_append(&conn->send, "can't parse input\n", 0); + f2b_buf_append(&conn->send, "can't parse input, try 'help'\n", 0); } free(line); } diff --git a/src/filter.c b/src/filter.c index b226436..9b79e84 100644 --- a/src/filter.c +++ b/src/filter.c @@ -16,11 +16,12 @@ #define HOST_TOKEN "" #define FILTER_LIBRARY_PARAM "load" -static bool +static size_t f2b_filter_load_file(f2b_filter_t *filter, const char *path) { f2b_config_param_t *param; FILE *f = NULL; size_t linenum = 0; + size_t loaded = 0; char line[REGEX_LINE_MAX] = ""; char *p, *q; @@ -29,7 +30,7 @@ f2b_filter_load_file(f2b_filter_t *filter, const char *path) { if ((f = fopen(path, "r")) == NULL) { f2b_log_msg(log_error, "can't open regex list '%s': %s", path, strerror(errno)); - return false; + return 0; } filter->flush(filter->cfg); @@ -73,12 +74,13 @@ f2b_filter_load_file(f2b_filter_t *filter, const char *path) { f2b_log_msg(log_warn, "can't create regex from pattern at %s:%zu: %s", path, linenum, p); continue; } + loaded++; break; } } fclose(f); - return true; + return loaded; } f2b_filter_t * @@ -232,11 +234,14 @@ f2b_filter_cmd_stats(char *buf, size_t bufsize, f2b_filter_t *filter) { void f2b_filter_cmd_reload(char *buf, size_t bufsize, f2b_filter_t *filter) { + size_t c = 0; assert(buf != NULL); assert(filter != NULL); filter->flush(filter->cfg); - if (f2b_filter_load_file(filter, filter->init)) { - snprintf(buf, bufsize, "can't reload filter"); + if ((c = f2b_filter_load_file(filter, filter->init)) > 0) { + snprintf(buf, bufsize, "loaded %zu regexps\n", c); + } else { + snprintf(buf, bufsize, "can't reload filter\n"); } }