From: Saverio Proto Date: Tue, 20 May 2014 21:53:08 +0000 (+0200) Subject: Drop messages from blacklisted nodes that I receive over a n-hops path X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=48708830253681860692c909c65d1a0989909c09;p=meshlink Drop messages from blacklisted nodes that I receive over a n-hops path --- diff --git a/src/meshlink.c b/src/meshlink.c index 0efdb397..01d3c6c3 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -1251,6 +1251,7 @@ 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); return; } diff --git a/src/net_packet.c b/src/net_packet.c index e5dbd964..8367a9c5 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -276,10 +276,14 @@ static void receive_packet(meshlink_handle_t *mesh, node_t *n, vpn_packet_t *pac 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) { @@ -654,9 +658,10 @@ void handle_incoming_vpn_data(event_loop_t *loop, void *data, int flags) { return; } - if (n->status.blacklisted) - 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);