From 4d0fcab10e91ad5962837f7dd428f5bca1c8c980 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Thu, 25 Jun 2020 17:01:24 +0200 Subject: Flesh out minecctl some more --- minecproxy/main.c | 10 +--------- minecproxy/server-config.c | 23 ++--------------------- 2 files changed, 3 insertions(+), 30 deletions(-) (limited to 'minecproxy') diff --git a/minecproxy/main.c b/minecproxy/main.c index 790bbfe..99513ee 100644 --- a/minecproxy/main.c +++ b/minecproxy/main.c @@ -27,7 +27,7 @@ #include "igmp.h" #include "idle.h" #include "ptimer.h" -#include +#include "config.h" /* Global */ struct cfg *cfg = NULL; @@ -38,14 +38,6 @@ static bool daemonize = false; static FILE *log_file = NULL; static const char *log_file_path = NULL; -#define ANSI_RED "\x1B[0;31m" -#define ANSI_GREEN "\x1B[0;32m" -#define ANSI_YELLOW "\x1B[0;33m" -#define ANSI_BLUE "\x1B[0;34m" -#define ANSI_MAGENTA "\x1B[0;35m" -#define ANSI_GREY "\x1B[0;38;5;245m" -#define ANSI_NORMAL "\x1B[0m" - static void msg(enum debug_lvl lvl, const char *fmt, va_list ap) { diff --git a/minecproxy/server-config.c b/minecproxy/server-config.c index 8786f88..92990d3 100644 --- a/minecproxy/server-config.c +++ b/minecproxy/server-config.c @@ -306,23 +306,6 @@ scfg_open_cb(struct uring_task *task, int res) uring_tbuf_read_until_eof(&server->task, scfg_read_cb); } -static bool -scfg_valid_filename(const char *name) -{ - const char *suffix; - - if (empty_str(name)) - return false; - if (name[0] == '.') - return false; - if ((suffix = strrchr(name, '.')) == NULL) - return false; - if (!streq(suffix, ".server")) - return false; - - return true; -} - struct server_cfg_monitor { struct uring_task task; char buf[4096] _alignas_(struct inotify_event); @@ -417,7 +400,7 @@ inotify_cb(struct uring_task *task, int res) continue; } - if (!scfg_valid_filename(event->name)) + if (!is_valid_server_config_filename(NULL, event->name)) continue; if (event->mask & (IN_MOVED_FROM | IN_DELETE)) @@ -490,9 +473,7 @@ server_cfg_monitor_init() die("opendir(%s): %m", cfg->cfg_dir); while ((dent = readdir(dir)) != NULL) { - if (dent->d_type != DT_REG && dent->d_type != DT_UNKNOWN) - continue; - if (!scfg_valid_filename(dent->d_name)) + if (!is_valid_server_config_filename(dent, NULL)) continue; server = server_new(dent->d_name); -- cgit v1.2.3