From 61ab7adcdb4ac160e57ef7b22f56df9676b6381d Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Fri, 24 Jul 2020 00:04:38 +0200 Subject: [PATCH] Always let the initiator send a REQ_KEY once a connection is activated. 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 | 4 ---- src/protocol_auth.c | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/graph.c b/src/graph.c index 754626ed..1efdb26c 100644 --- a/src/graph.c +++ b/src/graph.c @@ -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) { diff --git a/src/protocol_auth.c b/src/protocol_auth.c index 3720e14a..4165bb1b 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -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; } -- 2.39.5