From bab00223b01190f844e5af5348efe508c2753833 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 18 Aug 2019 16:51:31 +0200 Subject: [PATCH] Send REQ_KEY after a successful meta-connection only from the initiator. --- src/connection.h | 1 + src/graph.c | 2 +- src/net_socket.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/connection.h b/src/connection.h index fd633b3f..ef688549 100644 --- a/src/connection.h +++ b/src/connection.h @@ -40,6 +40,7 @@ typedef struct connection_status_t { uint16_t log: 1; /* 1 if this is a control connection requesting log dump */ uint16_t invitation: 1; /* 1 if this is an invitation */ uint16_t invitation_used: 1; /* 1 if the invitation has been consumed */ + uint16_t initiator: 1; /* 1 if we initiated this connection */ } connection_status_t; #include "ecdsa.h" diff --git a/src/graph.c b/src/graph.c index 1a1e2375..60ac3adf 100644 --- a/src/graph.c +++ b/src/graph.c @@ -228,7 +228,7 @@ static void check_reachability(meshlink_handle_t *mesh) { update_node_udp(mesh, n, NULL); n->status.broadcast = false; } else if(n->connection) { - if(n->connection->outgoing) { + if(n->connection->status.initiator) { send_req_key(mesh, n); } } diff --git a/src/net_socket.c b/src/net_socket.c index 374ba205..29f14c0e 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -577,6 +577,7 @@ 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; -- 2.39.2