From: Saverio Proto Date: Tue, 20 May 2014 21:15:45 +0000 (+0200) Subject: Trivial test for meshlink_blacklist X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=5cb0c2139905daffee975b20dc6cb2d2faf29078;p=meshlink Trivial test for meshlink_blacklist --- diff --git a/src/meshlink.c b/src/meshlink.c index bfadf61b..0efdb397 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -1248,6 +1248,11 @@ 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; + return; + } static void __attribute__((constructor)) meshlink_init(void) { diff --git a/src/net_packet.c b/src/net_packet.c index f3809e87..e5dbd964 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -654,6 +654,9 @@ void handle_incoming_vpn_data(event_loop_t *loop, void *data, int flags) { return; } + if (n->status.blacklisted) + return; + n->sock = ls - mesh->listen_socket; receive_udppacket(mesh, n, &pkt); diff --git a/src/node.h b/src/node.h index 3a779af9..f3930895 100644 --- a/src/node.h +++ b/src/node.h @@ -33,8 +33,9 @@ typedef struct node_status_t { 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 {