]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.c
Speed up reconnections on network interface changes.
[meshlink] / src / meshlink.c
index 302624fc5d0944cdd53934bd272a11d942ee8d65..b1f5c918fa68dd9d1d29e09a710c60d73b3bd51e 100644 (file)
@@ -3090,6 +3090,21 @@ end:
 #endif
 }
 
+void handle_network_change(meshlink_handle_t *mesh, bool online) {
+       if(!mesh->connections) {
+               return;
+       }
+
+       if(online) {
+               retry(mesh);
+       } else {
+               // We are off-line. Terminate all active connections.
+               for list_each(connection_t, c, mesh->connections) {
+                       terminate_connection(mesh, c, false);
+               }
+       }
+}
+
 static void __attribute__((constructor)) meshlink_init(void) {
        crypto_init();
        unsigned int seed;