n->devclass = DEV_CLASS_UNKNOWN;
n->ecdsa = ecdsa_set_public_key(data);
n->submesh = c->submesh;
- n->status.dirty = true;
node_add(mesh, n);
- // TODO: immediately write the config file?
+ node_write_config(mesh, n);
logger(mesh, MESHLINK_INFO, "Key successfully received from %s", c->name);
config_t config;
- if(!invitation_read(mesh, cookie, &config)) {
+ if(!invitation_read(mesh, "current", cookie, &config, mesh->config_key)) {
logger(mesh, MESHLINK_ERROR, "Error while trying to read invitation file\n");
return false;
}
// Send the node the contents of the invitation file
sptps_send_record(&c->sptps, 0, config.buf, config.len);
+ config_free(&config);
+ free(submesh_name);
+
c->status.invitation_used = true;
logger(mesh, MESHLINK_INFO, "Invitation %s successfully sent to %s", cookie, c->name);