return false;
}
+ node_t *n = (node_t *)destination;
+
+ if(n->status.blacklisted) {
+ logger(mesh, MESHLINK_ERROR, "Node %s blacklisted, dropping packet\n", n->name);
+ return false;
+ }
+
// Prepare the packet
vpn_packet_t *packet = malloc(sizeof(*packet));
node_t *n;
n = (node_t *)node;
+
+ if(n == mesh->self) {
+ logger(mesh, MESHLINK_ERROR, "%s blacklisting itself?\n", node->name);
+ meshlink_errno = MESHLINK_EINVAL;
+ pthread_mutex_unlock(&(mesh->mesh_mutex));
+ return;
+ }
+
+ if(n->status.blacklisted) {
+ logger(mesh, MESHLINK_DEBUG, "Node %s already blacklisted\n", node->name);
+ pthread_mutex_unlock(&(mesh->mesh_mutex));
+ return;
+ }
+
n->status.blacklisted = true;
logger(mesh, MESHLINK_DEBUG, "Blacklisted %s.\n", node->name);
}
}
+ utcp_abort_all_connections(n->utcp);
+
+ n->mtu = 0;
+ n->minmtu = 0;
+ n->maxmtu = MTU;
+ n->mtuprobes = 0;
+ n->status.udp_confirmed = false;
+
+ if(n->status.reachable) {
+ update_node_status(mesh, n);
+ }
+
pthread_mutex_unlock(&(mesh->mesh_mutex));
}
pthread_mutex_lock(&(mesh->mesh_mutex));
node_t *n = (node_t *)node;
+
+ if(!n->status.blacklisted) {
+ logger(mesh, MESHLINK_DEBUG, "Node %s was already whitelisted\n", node->name);
+ meshlink_errno = MESHLINK_EINVAL;
+ pthread_mutex_unlock(&(mesh->mesh_mutex));
+ return;
+ }
+
n->status.blacklisted = false;
- //TODO: remove blacklisted = yes from the config file
+ if(n->status.reachable) {
+ update_node_status(mesh, n);
+ }
+
+ //Remove blacklisting from the config file
+ append_config_file(mesh, n->name, "blacklisted", NULL);
pthread_mutex_unlock(&(mesh->mesh_mutex));
return;
}
}
+ if(n->status.blacklisted) {
+ logger(mesh, MESHLINK_ERROR, "Cannot open a channel with blacklisted node\n");
+ return NULL;
+ }
+
meshlink_channel_t *channel = xzalloc(sizeof(*channel));
channel->node = n;
channel->receive_cb = cb;
}
if(mesh->node_status_cb) {
- mesh->node_status_cb(mesh, (meshlink_node_t *)n, n->status.reachable);
+ mesh->node_status_cb(mesh, (meshlink_node_t *)n, n->status.reachable && !n->status.blacklisted);
}
}