]> git.meshlink.io Git - meshlink/commitdiff
Fix outgoing connection attempts after local discovery.
authorGuus Sliepen <guus@meshlink.io>
Mon, 13 Jul 2020 20:31:46 +0000 (22:31 +0200)
committerGuus Sliepen <guus@meshlink.io>
Tue, 26 Jan 2021 20:43:45 +0000 (21:43 +0100)
We were trying the wrong port due to a forgotten byteswap. Also, if no
address was known at all for a node, there might be an outgoing structure
for it that would never be retried.

src/discovery.c
src/net_socket.c

index 148656ac179b86b4b42c7b68d04fa112309d548a..6fec9a2466299592fb51b6f6cf47e145723416b5 100644 (file)
@@ -248,11 +248,11 @@ static void mdns_io_handler(event_loop_t *loop, void *data, int flags) {
 
                        switch(sa.sa.sa_family) {
                        case AF_INET:
-                               sa.in.sin_port = port;
+                               sa.in.sin_port = htons(port);
                                break;
 
                        case AF_INET6:
-                               sa.in6.sin6_port = port;
+                               sa.in6.sin6_port = htons(port);
                                break;
 
                        default:
@@ -263,20 +263,25 @@ static void mdns_io_handler(event_loop_t *loop, void *data, int flags) {
 
                        if(sa.sa.sa_family != AF_UNKNOWN) {
                                n->catta_address = sa;
+                               n->last_connect_try = 0;
                                node_add_recent_address(mesh, n, &sa);
 
-                               connection_t *c = n->connection;
+                               if(n->connection) {
+                                       n->connection->last_ping_time = -3600;
+                               }
+
+                               for list_each(outgoing_t, outgoing, mesh->outgoings) {
+                                       if(outgoing->node != n) {
+                                               continue;
+                                       }
 
-                               if(c && c->outgoing && !c->status.active) {
-                                       c->outgoing->timeout = 0;
+                                       outgoing->timeout = 0;
 
-                                       if(c->outgoing->ev.cb) {
-                                               timeout_set(&mesh->loop, &c->outgoing->ev, &(struct timespec) {
+                                       if(outgoing->ev.cb) {
+                                               timeout_set(&mesh->loop, &outgoing->ev, &(struct timespec) {
                                                        0, 0
                                                });
                                        }
-
-                                       c->last_ping_time = -3600;
                                }
                        }
                }
index abf6a7cf0e0eb7fa878f347efa45a6910c646927..9bd00bcc4fab5620ea3572e429eebbac77cd4d91 100644 (file)
@@ -378,6 +378,7 @@ begin:
                        /* We are waiting for a callback from the ADNS thread */
                } else if(outgoing->state == OUTGOING_NO_KNOWN_ADDRESSES) {
                        logger(mesh, MESHLINK_ERROR, "No known addresses for %s", outgoing->node->name);
+                       list_delete(mesh->outgoings, outgoing);
                } else {
                        logger(mesh, MESHLINK_ERROR, "Could not set up a meta connection to %s", outgoing->node->name);
                        retry_outgoing(mesh, outgoing);