]> git.meshlink.io Git - meshlink/commitdiff
Always let the initiator send a REQ_KEY once a connection is activated.
authorGuus Sliepen <guus@meshlink.io>
Thu, 23 Jul 2020 22:04:38 +0000 (00:04 +0200)
committerGuus Sliepen <guus@meshlink.io>
Thu, 23 Jul 2020 22:04:38 +0000 (00:04 +0200)
Before, the logic was to do this when the graph reported a bidirectional
edge. However, there was a possibility that if two nodes connect to each
other simultaneously, causing a second connection to be activated while the
first was also still active, which caused the REQ_KEY to not be sent.

src/graph.c
src/protocol_auth.c

index 754626edd8a117fa15ddcdf9845a18c1aa43ae16..1efdb26c9b21ad73a809a9fa95ec16076528c8c7 100644 (file)
@@ -212,10 +212,6 @@ static void check_reachability(meshlink_handle_t *mesh) {
                        if(!n->status.reachable) {
                                update_node_udp(mesh, n, NULL);
                                n->status.broadcast = false;
-                       } else if(n->connection) {
-                               if(n->connection->status.initiator) {
-                                       send_req_key(mesh, n);
-                               }
                        }
 
                        if(n->utcp) {
index 3720e14abc64c0bf9eeb7cf71fcb927feb55f691..4165bb1b987cfbfa4dae0d5362a8137ef7eeaece 100644 (file)
@@ -360,6 +360,7 @@ bool ack_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
        n->last_successfull_connection = mesh->loop.now.tv_sec;
 
        n->connection = c;
+       n->nexthop = n;
        c->node = n;
 
        /* Activate this connection */
@@ -400,5 +401,11 @@ bool ack_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
 
        graph(mesh);
 
+       /* Request a session key to jump start UDP traffic */
+
+       if(c->status.initiator) {
+               send_req_key(mesh, n);
+       }
+
        return true;
 }