From: Guus Sliepen Date: Sun, 29 Mar 2020 22:42:32 +0000 (+0200) Subject: Try addresses found by Catta for UDP probes. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=72fe3cdc361b933d8a471902b073378cbed6273d;p=meshlink Try addresses found by Catta for UDP probes. --- diff --git a/src/discovery.c b/src/discovery.c index 2a74cc35..db71a5d1 100644 --- a/src/discovery.c +++ b/src/discovery.c @@ -251,6 +251,7 @@ static void discovery_resolve_callback(CattaSServiceResolver *resolver, CattaIfI node_t *n = (node_t *)node; connection_t *c = n->connection; + n->catta_address = naddress; node_add_recent_address(mesh, n, &naddress); if(c && c->outgoing && !c->status.active) { diff --git a/src/net_packet.c b/src/net_packet.c index 8aca6aa5..8bc363d2 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -308,6 +308,12 @@ static void choose_udp_address(meshlink_handle_t *mesh, const node_t *n, const s return; } + /* If we have learned an address via Catta, try this once every batch */ + if(mesh->udp_choice == 1 && n->catta_address.sa.sa_family != AF_UNSPEC) { + *sa = &n->catta_address; + goto check_socket; + } + /* Otherwise, address are found in edges to this node. So we pick a random edge and a random socket. */ @@ -327,6 +333,7 @@ static void choose_udp_address(meshlink_handle_t *mesh, const node_t *n, const s *sock = prng(mesh, mesh->listen_sockets); } +check_socket: /* Make sure we have a suitable socket for the chosen address */ if(mesh->listen_socket[*sock].sa.sa.sa_family != (*sa)->sa.sa_family) { for(int i = 0; i < mesh->listen_sockets; i++) { diff --git a/src/node.h b/src/node.h index ff8b3335..733abb00 100644 --- a/src/node.h +++ b/src/node.h @@ -85,7 +85,8 @@ typedef struct node_t { time_t last_successfull_connection; char *canonical_address; /* The canonical address of this node, if known */ - sockaddr_t recent[MAX_RECENT]; /* Recently seen addresses */ + sockaddr_t recent[MAX_RECENT]; /* Recently seen addresses */ + sockaddr_t catta_address; /* Latest address seen by Catta */ // Graph-related member variables time_t last_reachable;