refuse connections from self
authorChristian Grothoff <christian@grothoff.org>
Fri, 10 Jun 2011 15:10:57 +0000 (15:10 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 10 Jun 2011 15:10:57 +0000 (15:10 +0000)
src/transport/gnunet-service-transport.c
src/transport/plugin_transport_tcp.c

index eb3e8f9dc48608477957f170313b3888b4346a30..875e56938dc725bd5311d24d5f8a0dcaa5a0d9e9 100644 (file)
@@ -5332,14 +5332,11 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
 }
 
 
-
-
-
 /**
- * Function called by the plugin for each received message.
- * Update data volumes, possibly notify plugins about
- * reducing the rate at which they read from the socket
- * and generally forward to our receive callback.
+ * Function called by the plugin for each received message.  Update
+ * data volumes, possibly notify plugins about reducing the rate at
+ * which they read from the socket and generally forward to our
+ * receive callback.
  *
  * @param cls the "struct TransportPlugin *" we gave to the plugin
  * @param peer (claimed) identity of the other peer
@@ -5371,6 +5368,14 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
   uint32_t distance;
   int c;
 
+  if (0 == memcmp (peer,
+                  &my_identity,
+                  sizeof (struct GNUNET_PeerIdentity)))
+    {
+      /* refuse to receive from myself */
+      GNUNET_break (0); 
+      return GNUNET_TIME_UNIT_FOREVER_REL;
+    }
   if (is_blacklisted (peer, plugin))
     return GNUNET_TIME_UNIT_FOREVER_REL;
   n = find_neighbour (peer);
index e93985f40d5448a9cd32be5f1dd31b748384d96d..689cb37842c714fcc8dc3be868df6f713fa0fe0f 100644 (file)
@@ -1810,6 +1810,15 @@ handle_tcp_nat_probe (void *cls,
   if (ntohs(message->size) != sizeof(struct TCP_NAT_ProbeMessage))
     {
       GNUNET_break_op(0);
+      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+      return;
+    }
+  if (0 == memcmp (&tcp_nat_probe->clientIdentity,
+                  plugin->env->my_identity,
+                  sizeof (struct GNUNET_PeerIdentity)))
+    {
+      /* refuse connections from ourselves */
+      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
       return;
     }
   tcp_nat_probe = (const struct TCP_NAT_ProbeMessage *)message;
@@ -1921,7 +1930,15 @@ handle_tcp_welcome (void *cls,
   struct IPv6TcpAddress *t6;
   const struct sockaddr_in *s4;
   const struct sockaddr_in6 *s6;
-
+  
+  if (0 == memcmp (&wm->clientIdentity,
+                  plugin->env->my_identity,
+                  sizeof (struct GNUNET_PeerIdentity)))
+    {
+      /* refuse connections from ourselves */
+      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+      return;
+    }
 #if DEBUG_TCP
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                   "tcp",