}
// Write host config files
- while(count--) {
+ for(uint32_t i = 0; i < count; i++) {
const void *data;
uint32_t len = packmsg_get_bin_raw(&in, &data);
return false;
}
- node_add(mesh, n);
+ if(i == 0) {
+ /* The first host config file is of the inviter itself;
+ * remember the address we are currently using for the invitation connection.
+ */
+ sockaddr_t sa;
+ socklen_t salen = sizeof(sa);
- if(!config_write(mesh, "current", n->name, &config, mesh->config_key)) {
+ if(getpeername(mesh->sock, &sa.sa, &salen) == 0) {
+ node_add_recent_address(mesh, n, &sa);
+ }
+ }
+
+ if(!node_write_config(mesh, n)) {
+ free_node(n);
return false;
}
+
+ node_add(mesh, n);
}
/* Ensure the configuration directory metadata is on disk */