]> git.meshlink.io Git - meshlink/commitdiff
Try addresses found by Catta for UDP probes.
authorGuus Sliepen <guus@meshlink.io>
Sun, 29 Mar 2020 22:42:32 +0000 (00:42 +0200)
committerGuus Sliepen <guus@meshlink.io>
Sun, 29 Mar 2020 22:42:32 +0000 (00:42 +0200)
src/discovery.c
src/net_packet.c
src/node.h

index 2a74cc35bd22a5ef321bc68ce80ff0f50b521143..db71a5d15a47034d100745eda2a395c8b8310721 100644 (file)
@@ -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) {
index 8aca6aa59adda1ef8f78d9eecec914625a9a367a..8bc363d229a8f45350a09e3d18a53ad5ca264681 100644 (file)
@@ -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++) {
index ff8b3335ba70740830a08d70f8e51245f315a32c..733abb0017425dbb7b0c4e1c1e372d0f7f0f2454 100644 (file)
@@ -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;