]> git.meshlink.io Git - meshlink/commitdiff
Drop messages from blacklisted nodes that I receive over a n-hops path
authorSaverio Proto <zioproto@gmail.com>
Tue, 20 May 2014 21:53:08 +0000 (23:53 +0200)
committerSaverio Proto <zioproto@gmail.com>
Fri, 23 May 2014 07:13:40 +0000 (09:13 +0200)
src/meshlink.c
src/net_packet.c

index 0efdb39780c372d3182d7eab89a0c1f1d2128e93..01d3c6c38f1e7f587a3d6fd3dcb27b7cd116eaa9 100644 (file)
@@ -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;
 
 }
index e5dbd964577d7a0df2ef5c40ff6e190f3addae98..8367a9c5157d78c978d65ce9e1267daa1e6fc862 100644 (file)
@@ -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);