/// Helper function to start parsing a host config file
static bool node_get_config(meshlink_handle_t *mesh, node_t *n, config_t *config, packmsg_input_t *in) {
- if(!config_read(mesh, "current", n->name, config, mesh->config_key)) {
+ if(!config_load(mesh, n->name, config)) {
return false;
}
config_t config = {buf, packmsg_output_size(&out, buf)};
- if(!config_write(mesh, "current", n->name, &config, mesh->config_key)) {
+ if(!config_store(mesh, n->name, &config)) {
call_error_cb(mesh, MESHLINK_ESTORAGE);
return false;
}
return true;
}
-static bool load_node(meshlink_handle_t *mesh, const char *name, void *priv) {
- (void)priv;
+static bool load_node(meshlink_handle_t *mesh, const char *name, size_t len) {
+ (void)len;
if(!check_id(name)) {
- // Check if this is a temporary file, if so remove it
- const char *suffix = strstr(name, ".tmp");
-
- if(suffix && !suffix[4]) {
- char filename[PATH_MAX];
- snprintf(filename, sizeof(filename), "%s" SLASH "current" SLASH "hosts", mesh->confbase);
- unlink(filename);
- }
-
+ // TODO: detect partial key rotation
return true;
}
node_add(mesh, mesh->self);
- if(!config_scan_all(mesh, "current", "hosts", load_node, NULL)) {
+ if(!config_ls(mesh, load_node)) {
logger(mesh, MESHLINK_WARNING, "Could not scan all host config files");
}