- // Create a new host config file
- char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s" SLASH "hosts" SLASH "%s", mesh->confbase, c->name);
- if(!access(filename, F_OK)) {
- logger(mesh, MESHLINK_ERROR, "Host config file for %s (%s) already exists!\n", c->name, c->hostname);
- return false;
- }
-
- FILE *f = fopen(filename, "w");
- if(!f) {
- logger(mesh, MESHLINK_ERROR, "Error trying to create %s: %s\n", filename, strerror(errno));
- return false;
- }
-
- fprintf(f, "ECDSAPublicKey = %s\n", (const char *)data);
- fclose(f);
+ // Create a new node
+ node_t *n = new_node();
+ n->name = xstrdup(c->name);
+ n->devclass = DEV_CLASS_UNKNOWN;
+ n->ecdsa = ecdsa_set_public_key(data);
+ n->submesh = c->submesh;
+ node_add(mesh, n);
+ node_write_config(mesh, n);