-options to play with
[oweals/gnunet.git] / src / fs / gnunet-service-fs.c
index 125a14118d62c87214ee82b0cd5fc8963129bc20..0f4d513ff2511143400f61a50b032f6fefa7d596 100644 (file)
@@ -22,9 +22,6 @@
  * @file fs/gnunet-service-fs.c
  * @brief gnunet anonymity protocol implementation
  * @author Christian Grothoff
- *
- * To use:
- * - consider re-issue GSF_dht_lookup_ after non-DHT reply received
  */
 #include "platform.h"
 #include <float.h>
@@ -397,7 +394,30 @@ start_p2p_processing (void *cls, struct GSF_PendingRequest *pr,
     GSF_pending_request_cancel_ (pr, GNUNET_YES);
     return;
   }
-  GSF_dht_lookup_ (pr);
+  if (0 == prd->anonymity_level)
+  {
+    switch (prd->type)
+    {
+    case GNUNET_BLOCK_TYPE_FS_DBLOCK:
+    case GNUNET_BLOCK_TYPE_FS_IBLOCK:
+      /* the above block types MAY be available via 'stream' */
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Considering stream-based download for block\n");
+      GSF_stream_lookup_ (pr);
+      break; 
+    case GNUNET_BLOCK_TYPE_FS_KBLOCK:
+    case GNUNET_BLOCK_TYPE_FS_SBLOCK:
+    case GNUNET_BLOCK_TYPE_FS_NBLOCK:
+      /* the above block types are in the DHT */
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Considering DHT-based search for block\n");
+      GSF_dht_lookup_ (pr);
+      break;
+    default:
+      GNUNET_break (0);
+      break;
+    }
+  }
   consider_forwarding (NULL, pr, result);
 }
 
@@ -562,6 +582,9 @@ static int
 main_init (struct GNUNET_SERVER_Handle *server,
            const struct GNUNET_CONFIGURATION_Handle *c)
 {
+  static const struct GNUNET_CORE_MessageHandler no_p2p_handlers[] = {
+    {NULL, 0, 0}
+  };
   static const struct GNUNET_CORE_MessageHandler p2p_handlers[] = {
     {&handle_p2p_get,
      GNUNET_MESSAGE_TYPE_FS_GET, 0},
@@ -584,11 +607,21 @@ main_init (struct GNUNET_SERVER_Handle *server,
      0},
     {NULL, NULL, 0, 0}
   };
-
+  int anon_p2p_off;
+
+  /* this option is really only for testcases that need to disable
+     _anonymous_ file-sharing for some reason */
+  anon_p2p_off = (GNUNET_YES ==
+                 GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg,
+                                                       "fs",
+                                                       "DISABLE_ANON_TRANSFER"));  
   GSF_core =
       GNUNET_CORE_connect (GSF_cfg, NULL, &peer_init_handler,
                            &peer_connect_handler, &GSF_peer_disconnect_handler_,
-                           NULL, GNUNET_NO, NULL, GNUNET_NO, p2p_handlers);
+                           NULL, GNUNET_NO, NULL, GNUNET_NO,
+                          (GNUNET_YES == anon_p2p_off)
+                          ? no_p2p_handlers
+                          : p2p_handlers);
   if (NULL == GSF_core)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,