]> git.meshlink.io Git - meshlink/blobdiff - src/protocol_auth.c
Modify meshlink configuration base file structre
[meshlink] / src / protocol_auth.c
index 9fec1ffad737451a94d17f7b5d5132196a0ff7bc..e2fe28b40d972d68a5a8023d5c4cef71045599f0 100644 (file)
@@ -164,9 +164,8 @@ static bool finalize_invitation(meshlink_handle_t *mesh, connection_t *c, const
        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);
 
@@ -206,7 +205,7 @@ static bool receive_invitation_sptps(void *handle, uint8_t type, const void *dat
 
        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;
        }
@@ -239,6 +238,9 @@ static bool receive_invitation_sptps(void *handle, uint8_t type, const void *dat
        // 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);