X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fdiscovery.c;fp=src%2Fdiscovery.c;h=6fec9a2466299592fb51b6f6cf47e145723416b5;hb=29dbceb7c011b3114cf97bb7712e56b4ed0c5e27;hp=148656ac179b86b4b42c7b68d04fa112309d548a;hpb=f6a9eb00bab9659f28c479dc34c16dc5c28a354d;p=meshlink diff --git a/src/discovery.c b/src/discovery.c index 148656ac..6fec9a24 100644 --- a/src/discovery.c +++ b/src/discovery.c @@ -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; } } }