]> git.meshlink.io Git - meshlink/commitdiff
Send REQ_KEY after a successful meta-connection only from the initiator.
authorGuus Sliepen <guus@meshlink.io>
Sun, 18 Aug 2019 14:51:31 +0000 (16:51 +0200)
committerGuus Sliepen <guus@meshlink.io>
Sun, 18 Aug 2019 14:51:31 +0000 (16:51 +0200)
src/connection.h
src/graph.c
src/net_socket.c

index fd633b3ffcb9e7535ba8c0263ff16dd938b07e62..ef688549062689e6b66cac2006ee4e9b03147188 100644 (file)
@@ -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"
index 1a1e237595076fd9bad0fe55e0ab3c6c60ffe699..60ac3adfc362a50806ac93b3b5e44850813f2ef7 100644 (file)
@@ -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);
                                }
                        }
index 374ba205b68ec6ebb42acc80151a2df1a35951fb..29f14c0eaa244e5122ef2679f4079486f3b89d16 100644 (file)
@@ -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;