summaryrefslogtreecommitdiff
path: root/minecproxy/server-config.c
diff options
context:
space:
mode:
Diffstat (limited to 'minecproxy/server-config.c')
-rw-r--r--minecproxy/server-config.c23
1 files changed, 2 insertions, 21 deletions
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);