]> git.meshlink.io Git - meshlink/blobdiff - src/graph.c
Use a status bit to track which nodes use SPTPS.
[meshlink] / src / graph.c
index b3a2c255c5945c4a1fe26a97f8de43f6ff01cfdb..9da552e743ccf36b4b8b2f834f4c0f6c2188e541 100644 (file)
@@ -226,6 +226,9 @@ static void check_reachability(void) {
                                           n->name, n->hostname);
                        }
 
+                       if(experimental && OPTION_VERSION(n->options) >= 2)
+                               n->status.sptps = true;
+
                        /* TODO: only clear status.validkey if node is unreachable? */
 
                        n->status.validkey = false;
@@ -263,10 +266,16 @@ static void check_reachability(void) {
 
                        subnet_update(n, NULL, n->status.reachable);
 
-                       if(!n->status.reachable)
+                       if(!n->status.reachable) {
                                update_node_udp(n, NULL);
-                       else if(n->connection)
-                               send_ans_key(n);
+                       } else if(n->connection) {
+                               if(n->status.sptps) {
+                                       if(n->connection->outgoing)
+                                               send_req_key(n);
+                               } else {
+                                       send_ans_key(n);
+                               }
+                       }
                }
        }
 }