]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.c
Implemented meshlink_blacklist feature
[meshlink] / src / meshlink.c
index 2aa79def7d47c6762e01f30715cb14e277933991..816f77abe630540d7f3f2724be887d505c0cd4e0 100644 (file)
@@ -828,7 +828,12 @@ bool meshlink_start(meshlink_handle_t *mesh) {
 }
 
 void meshlink_stop(meshlink_handle_t *mesh) {
-       // TODO: close the listening sockets to signal the main thread to shut down
+       // Shut down the listening sockets to signal the main thread to shut down
+
+       for(int i = 0; i < mesh->listen_sockets; i++) {
+               shutdown(mesh->listen_socket[i].tcp.fd, SHUT_RDWR);
+               shutdown(mesh->listen_socket[i].udp.fd, SHUT_RDWR);
+       }
 
        // Wait for the main thread to finish
 
@@ -1243,6 +1248,15 @@ bool meshlink_import(meshlink_handle_t *mesh, const char *data) {
 }
 
 void meshlink_blacklist(meshlink_handle_t *mesh, meshlink_node_t *node) {
+    node_t *n;
+    n = (node_t*)node;
+    n->status.blacklisted=true;
+       fprintf(stderr, "Blacklisted %s.\n",node->name);
+
+       //Make blacklisting persistent in the config file
+       append_config_file(mesh, n->name, "blacklisted", "yes");
+    return;
+
 }
 
 static void __attribute__((constructor)) meshlink_init(void) {