gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r10890 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r10890 - gnunet/src/transport
Date: Mon, 12 Apr 2010 22:36:38 +0200

Author: grothoff
Date: 2010-04-12 22:36:38 +0200 (Mon, 12 Apr 2010)
New Revision: 10890

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/transport_api.c
Log:
proper PONG validation

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2010-04-12 20:09:55 UTC 
(rev 10889)
+++ gnunet/src/transport/gnunet-service-transport.c     2010-04-12 20:36:38 UTC 
(rev 10890)
@@ -23,6 +23,15 @@
  * @brief low-level P2P messaging
  * @author Christian Grothoff
  *
+ * TODO:
+ * - Need to validate *inbound* bi-directional transports (i.e., TCP)
+ *   using PING-PONG and then SIGNAL 'connected' to core/etc.!
+ *   (currently we neither validate those nor do we signal the
+ *    connection); only after those, we should transmit data
+ *   (we currently send and receive arbitrary data on inbound TCP 
+ *    connections even if they have not been validated and hand it
+ *    to our clients!)
+ *
  * NOTE:
  * - This code uses 'GNUNET_a2s' for debug printing in many places,
  *   which is technically wrong since it assumes we have IP+Port 
@@ -2341,6 +2350,15 @@
 
   if (ve->challenge != challenge)
     return GNUNET_YES;
+  if (GNUNET_OK !=
+      GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PING,
+                               &pong->purpose, 
+                               &pong->signature,
+                               &ve->publicKey))
+    {
+      GNUNET_break_op (0);
+      return GNUNET_YES;
+    }
 
 #if DEBUG_TRANSPORT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2392,8 +2410,8 @@
       n->distance = fal->distance;
       if (GNUNET_NO == n->received_pong)
        {
+         n->received_pong = GNUNET_YES;
          notify_clients_connect (&target, n->latency, n->distance);
-         n->received_pong = GNUNET_YES;
        }
       if (n->retry_task != GNUNET_SCHEDULER_NO_TASK)
        {
@@ -2989,7 +3007,7 @@
     htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
            sizeof (uint32_t) +
            sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + 
sender_address_len);
-  pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_TCP_PING);
+  pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PING);
   pong->challenge = ping->challenge;
   pong->addrlen = htons(sender_address_len);
   memcpy(&pong->signer, 
@@ -3163,10 +3181,10 @@
          process_hello (plugin, message);
          break;
        case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
-         handle_ping(plugin, message, peer, sender_address, 
sender_address_len);
+         handle_ping (plugin, message, peer, sender_address, 
sender_address_len);
          break;
        case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG:
-         handle_pong(plugin, message, peer, sender_address, 
sender_address_len);
+         handle_pong (plugin, message, peer, sender_address, 
sender_address_len);
          break;
        default:
 #if DEBUG_TRANSPORT

Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c        2010-04-12 20:09:55 UTC (rev 
10889)
+++ gnunet/src/transport/transport_api.c        2010-04-12 20:36:38 UTC (rev 
10890)
@@ -1577,9 +1577,15 @@
 #endif      
       n = neighbour_find (h, &im->peer);
       if (n == NULL)
-       n = neighbour_add (h, &im->peer);
-      if (n == NULL) 
-       break;
+       {
+         GNUNET_break (0);
+         break;
+       }
+      if (n->is_connected != GNUNET_YES)
+       {
+         GNUNET_break (0);
+         break;
+       }
       if (h->rec != NULL)
        h->rec (h->cls, &im->peer, imm,
                GNUNET_TIME_relative_ntoh (im->latency), ntohs(im->distance));





reply via email to

[Prev in Thread] Current Thread [Next in Thread]