using the meshlink_blacklist function the application is able to blacklist a node
data from with node will be discarded. No more data will be sent to this node.
the blacklisting is persistent in the host configuration file
}
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) {
}
if(!found) {
+ //TODO: if the node is blacklisted the connection will not happen, but
+ //the user will read this debug message "Autoconnecting to %s" that is misleading
logger(DEBUG_CONNECTIONS, LOG_INFO, "Autoconnecting to %s", n->name);
outgoing_t *outgoing = xzalloc(sizeof *outgoing);
outgoing->name = xstrdup(n->name);
logger(DEBUG_TRAFFIC, LOG_DEBUG, "Received packet of %d bytes from %s (%s)",
packet->len, n->name, n->hostname);
+ if (n->status.blacklisted) {
+ logger(DEBUG_PROTOCOL, LOG_WARNING, "Dropping packet from blacklisted node %s", n->name);
+ } else {
n->in_packets++;
n->in_bytes += packet->len;
route(mesh, n, packet);
+ }
}
static bool try_mac(meshlink_handle_t *mesh, node_t *n, const vpn_packet_t *inpkt) {
return;
}
+ if (n->status.blacklisted) {
+ logger(DEBUG_PROTOCOL, LOG_WARNING, "Dropping packet from blacklisted node %s", n->name);
+ return;
+ }
n->sock = ls - mesh->listen_socket;
receive_udppacket(mesh, n, &pkt);
}
void setup_outgoing_connection(meshlink_handle_t *mesh, outgoing_t *outgoing) {
+ bool blacklisted = false;
timeout_del(&mesh->loop, &outgoing->ev);
node_t *n = lookup_node(mesh, outgoing->name);
read_host_config(mesh, outgoing->config_tree, outgoing->name);
outgoing->cfg = lookup_config(outgoing->config_tree, "Address");
+ get_config_bool(lookup_config(outgoing->config_tree, "blacklisted"), &blacklisted);
+ if (blacklisted) return;
+
if(!outgoing->cfg) {
if(n)
outgoing->aip = outgoing->ai = get_known_addresses(n);
unsigned int indirect:1; /* 1 if this node is not directly reachable by us */
unsigned int unused_sptps:1; /* 1 if this node supports SPTPS */
unsigned int udp_confirmed:1; /* 1 if the address is one that we received UDP traffic on */
- unsigned int broadcast:1; /* 1 if the next UDP packet should be broadcast to the local network */
- unsigned int unused:23;
+ unsigned int broadcast:1; /* 1 if the next UDP packet should be broadcast to the local network */
+ unsigned int blacklisted:1; /* 1 if the node is blacklist so we never want to speak with him anymore*/
+ unsigned int unused:22;
} node_status_t;
typedef struct node_t {