summaryrefslogtreecommitdiff
path: root/minecproxy
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-25 17:01:24 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-25 17:01:24 +0200
commit4d0fcab10e91ad5962837f7dd428f5bca1c8c980 (patch)
tree3529036819aec2a56d769f3f8626fb24c625d4b2 /minecproxy
parent7e980225821aaa3073fc46d2dc248e9571d3c298 (diff)
Flesh out minecctl some more
Diffstat (limited to 'minecproxy')
-rw-r--r--minecproxy/main.c10
-rw-r--r--minecproxy/server-config.c23
2 files changed, 3 insertions, 30 deletions
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 <config.h>
+#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);