+
+ goto begin;
+ }
+
+ /* Now that there is a working socket, fill in the rest and register this connection. */
+
+ c->status.connecting = true;
+ c->status.initiator = true;
+ c->name = xstrdup(outgoing->node->name);
+ c->last_ping_time = mesh->loop.now.tv_sec;
+
+ connection_add(mesh, c);
+
+ io_add(&mesh->loop, &c->io, handle_meta_io, c, c->socket, IO_READ | IO_WRITE);
+
+ return true;
+}
+
+void setup_outgoing_connection(meshlink_handle_t *mesh, outgoing_t *outgoing) {
+ timeout_del(&mesh->loop, &outgoing->ev);
+
+ if(outgoing->node->connection) {
+ logger(mesh, MESHLINK_INFO, "Already connected to %s", outgoing->node->name);
+
+ outgoing->node->connection->outgoing = outgoing;