work on namespace stuff
authorChristian Grothoff <christian@grothoff.org>
Tue, 30 Mar 2010 11:17:50 +0000 (11:17 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 30 Mar 2010 11:17:50 +0000 (11:17 +0000)
16 files changed:
TODO
contrib/defaults.conf
doc/man/Makefile.am
src/core/core.h
src/fs/fs_publish.c
src/fs/fs_search.c
src/fs/fs_test_lib_data.conf
src/fs/gnunet-pseudonym.c
src/fs/gnunet-service-fs.c
src/fs/test_fs_download.c
src/fs/test_fs_namespace.c
src/fs/test_fs_namespace_data.conf
src/fs/test_fs_search.c
src/fs/test_fs_search_data.conf
src/fs/test_fs_test_lib.c
src/fs/test_gnunet_service_fs_p2p.c

diff --git a/TODO b/TODO
index 37621af31000c46a9faf2b70a35821751c1362f3..1ba71ab18a35ce06b1c3198ffc4738470a0c3c65 100644 (file)
--- a/TODO
+++ b/TODO
@@ -15,8 +15,6 @@ away), in order in which they will likely be done:
 
 0.9.0pre0:
 * CORE:
-  - SET_KEY is triggered every 2.5 minutes (after session is up); should
-    just do PING (not SET_KEY + PING)
   - "Forcing disconnect of XXX due to inactivity" -- can happen every few MS!?
     (disconnect does not really succeed, or what?)
     Also, core does not seem to actually decrement the number of active
@@ -34,15 +32,15 @@ away), in order in which they will likely be done:
   - 2-peer download is still too slow (why?)
   - advanced FS API parts
     + search: SBlocks, NBlocks, probes, notify FS-service of known results
-    + indexing: index-failure-cleanup
     + gnunet-publish (URI args)
     + gnunet-download (directory)
     + gnunet-search (options, incl. namespace search)
     + gnunet-download (many options)
     + gnunet-directory (man page, options)
-    + gnunet-pseudonym (all of it)
+    + gnunet-pseudonym (listing of namespaces, advertisement uris, testing)
     + gnunet-service-fs (remove failing on-demand blocks, hot-path routing, 
       load-based routing, nitpicks)
+    + indexing: index-failure-cleanup
   - implement adv. FS testcases 
   - [./fs/gnunet-service-fs.c:208]: (style) struct or union member 'LocalGetContext::results_bf_size' is never used
   - [./fs/gnunet-service-fs.c:501]: (style) struct or union member 'PendingRequest::used_pids_size' is never used
@@ -154,6 +152,7 @@ away), in order in which they will likely be done:
 * FS:
   - location URIs (publish, search, download)
   - collection API & tests
+    + gnunet-pseudonym (collection support)
   - implement FS performance tests
     + insert
     + download
index b3a77d7e3b2b29ed7cf37f41261afbf2c611bfcb..d4374a54bff15e7e4f113ac19b3e2738fa77c7b3 100644 (file)
@@ -197,4 +197,4 @@ BINARY = gnunet-service-fs
 ACCEPT_FROM = 127.0.0.1;
 ACCEPT_FROM6 = ::1;
 ALLOW_SHUTDOWN = YES
-DEBUG = YES
\ No newline at end of file
+# DEBUG = YES
index 11b687bbee3466dddf9b0497ed91211f42501492..9b59b858919ae54a7d1ddb382242441c94953d21 100644 (file)
@@ -3,6 +3,7 @@ man_MANS = \
   gnunet-directory.1 \
   gnunet-download.1 \
   gnunet-peerinfo.1 \
+  gnunet-pseudonym.1 \
   gnunet-publish.1 \
   gnunet-search.1 \
   gnunet-statistics.1 \
index 45d138140ffe7dd538e99ba049d9499e7f781fcb..ea2925797346cf206be11efcb5fd7fc93badeb5d 100644 (file)
@@ -29,7 +29,7 @@
 /**
  * General core debugging.
  */
-#define DEBUG_CORE GNUNET_YES
+#define DEBUG_CORE GNUNET_NO
 
 /**
  * Debugging interaction core-clients.
index dbecdfab706224faa1b9890a0a75f849aac5648e..18b0646986db387d1eec54418c927fd4b7ccd510 100644 (file)
@@ -40,7 +40,7 @@
 #include "fs.h"
 #include "fs_tree.h"
 
-#define DEBUG_PUBLISH GNUNET_YES
+#define DEBUG_PUBLISH GNUNET_NO
 
 /**
  * Main function that performs the upload.
index 98168c3f4c755b0f6a3c5c6282d5ab4bfeb91429..596ea0c63fdaf948112d713fa5bfe7e33aa1593a 100644 (file)
@@ -38,7 +38,7 @@
 #include "gnunet_protocols.h"
 #include "fs.h"
 
-#define DEBUG_SEARCH GNUNET_YES
+#define DEBUG_SEARCH GNUNET_NO
 
 
 
index 5d2f60527c3dd7224a6373abc7db12049d530fcd..b2fbd5ee0508c908aaa9e96e3332c1f6750749ca 100644 (file)
@@ -42,14 +42,14 @@ PORT = 43470
 HOSTNAME = localhost
 #TOTAL_QUOTA_IN = 3932160
 #TOTAL_QUOTA_OUT = 3932160
-DEBUG = YES
+#DEBUG = YES
 #PREFIX = valgrind --tool=memcheck --leak-check=yes
 #BINARY = /home/grothoff/bin/gnunet-service-core
 
 [fs]
 PORT = 43471
 HOSTNAME = localhost
-DEBUG = YES
+#DEBUG = YES
 #PREFIX = valgrind --tool=memcheck --leak-check=yes
 #BINARY = /home/grothoff/bin/gnunet-service-fs
 #PREFIX = xterm -e gdb -x cmd --args 
index e443d1e32a21f7602f912c877a19f88293ac320f..2d35e8e8c6a94dfbe5fef035058505b5dab13ebb 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
+     (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009, 2010 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
 #include "platform.h"
 #include "gnunet_fs_service.h"
 
+/**
+ * -a optiton.
+ */
+static unsigned int anonymity;
+
+/**
+ * -A option.
+ */
+static int start_automate;
+
+/**
+ * -e option
+ */
+static int stop_automate;
+
+/**
+ * -C option
+ */
+static char *create_ns;
+
+/**
+ * -D option
+ */
+static char *delete_ns;
+
+/**
+ * -k option
+ */
+static struct GNUNET_FS_Uri *ksk_uri;
+
+/**
+ * -l option.
+ */
+static int print_local_only;
+
+/**
+ * -m option.
+ */
+static struct GNUNET_CONTAINER_MetaData *adv_metadata;
+
+/**
+ * -n option.
+ */
+static int no_advertising;
+
+/**
+ * -p option.
+ */
+static unsigned int priority = 365;
+
+/**
+ * -q option given.
+ */
+static int no_remote_printing; 
+
+/**
+ * -r option.
+ */
+static char *root_identifier;
+
+/**
+ * -s option.
+ */
+static char *rating_change;
+
+/**
+ * Handle to fs service.
+ */
+static struct GNUNET_FS_Handle *h;
+
+/**
+ * Namespace we are looking at.
+ */
+static struct GNUNET_FS_Namespace *ns;
+
+
 static int ret;
 
+static void* 
+progress_cb (void *cls,
+            const struct GNUNET_FS_ProgressInfo *info)
+{
+  return NULL;
+}
+
+
+static void
+ns_printer (void *cls,
+           const char *name,
+           const GNUNET_HashCode *id)
+{
+  struct GNUNET_CRYPTO_HashAsciiEncoded enc;
+
+  GNUNET_CRYPTO_hash_to_enc (id, &enc);
+  fprintf (stdout, 
+          "%s (%s)\n",
+          name,
+          (const char*) &enc);
+}
+
+
+static void
+post_advertising (void *cls,
+                 const struct GNUNET_FS_Uri *uri,
+                 const char *emsg)
+{
+  if (emsg != NULL)
+    {
+      fprintf (stderr, "%s", emsg);
+      ret = 1;
+    }
+  if (ns != NULL)
+    {
+      if (GNUNET_OK !=
+         GNUNET_FS_namespace_delete (ns,
+                                     GNUNET_NO))
+       ret = 1;
+    }
+  if (0 != stop_automate)
+    {
+      GNUNET_break (0); // FIXME: not implemented
+    }
+  if (0 != start_automate)
+    {
+      GNUNET_break (0); // FIXME: not implemented
+    }
+  if (NULL != rating_change)
+    {
+      GNUNET_break (0); // FIXME: not implemented
+    }
+  if (0 != print_local_only)
+    {
+      GNUNET_FS_namespace_list (h,
+                               &ns_printer, 
+                               NULL);
+    }  
+  else if (0 == no_remote_printing)
+    {
+      GNUNET_break (0); // FIXME: not implemented
+    }
+  /* FIXME: is this OK here, or do we need
+     for completion of previous requests? */
+  GNUNET_FS_stop (h);
+}
+
+
 /**
  * Main function that will be run by the scheduler.
  *
@@ -43,15 +187,111 @@ run (void *cls,
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-  // FIXME
-}
+  struct GNUNET_FS_Uri *ns_uri;
+  struct GNUNET_TIME_Absolute expiration;
 
+  h = GNUNET_FS_start (sched,
+                      cfg,
+                      "gnunet-pseudonym",
+                      &progress_cb,
+                      NULL,
+                      GNUNET_FS_FLAGS_NONE);
+  if (NULL != delete_ns)
+    {
+      ns = GNUNET_FS_namespace_create (h, delete_ns);
+      if (ns == NULL)
+       {
+         ret = 1;
+       }
+      else
+       {
+         if (GNUNET_OK !=
+             GNUNET_FS_namespace_delete (ns,
+                                         GNUNET_YES))
+           ret = 1;
+         ns = NULL;
+       }
+    }
+  if (NULL != create_ns)
+    {
+      ns = GNUNET_FS_namespace_create (h, create_ns);
+      if (ns == NULL)
+       {
+         ret = 1;
+       }
+      else
+       {
+         if (0 == no_advertising)
+           {
+             GNUNET_break (0); // FIXME: not implemented
+             ns_uri = NULL; // FIXME!!
+             expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS);
+             GNUNET_FS_publish_ksk (h,
+                                    ksk_uri,
+                                    adv_metadata,
+                                    ns_uri,
+                                    expiration,
+                                    anonymity,
+                                    priority,
+                                    GNUNET_FS_PUBLISH_OPTION_NONE,
+                                    &post_advertising,
+                                    NULL);
+             return;
+           }
+       }
+    }
+  post_advertising (NULL, NULL, NULL);
+}
 
 /**
  * gnunet-pseudonym command line options
  */
 static struct GNUNET_GETOPT_CommandLineOption options[] = {
-  // FIXME: options!
+  {'a', "anonymity", "LEVEL",
+   gettext_noop ("set the desired LEVEL of sender-anonymity"),
+   1, &GNUNET_GETOPT_set_uint, &anonymity},
+  {'A', "automate", NULL,
+   gettext_noop ("start a collection"),
+   0, &GNUNET_GETOPT_set_one, &start_automate},
+  {'C', "create", "NAME",
+   gettext_noop
+   ("create or advertise namespace NAME"),
+   1, &GNUNET_GETOPT_set_string, &create_ns},
+  {'D', "delete", "NAME",
+   gettext_noop
+   ("delete namespace NAME "),
+   1, &GNUNET_GETOPT_set_string, &delete_ns},
+  {'e', "end", NULL,
+   gettext_noop ("end current collection"),
+   0, &GNUNET_GETOPT_set_one, &stop_automate},
+  {'k', "keyword", "VALUE",
+  gettext_noop
+   ("add an additional keyword for the advertisment"
+    " (this option can be specified multiple times)"),
+   1, &GNUNET_FS_getopt_set_keywords, &ksk_uri},
+  {'l', "local-only", NULL,
+   gettext_noop ("print names of local namespaces"),
+   0, &GNUNET_GETOPT_set_one, &print_local_only},
+  {'m', "meta", "TYPE:VALUE",
+   gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
+   1, &GNUNET_FS_getopt_set_metadata, &adv_metadata},
+  {'n', "no-advertisement", NULL,
+   gettext_noop ("do not create an advertisement"),
+   0, &GNUNET_GETOPT_set_one, &no_advertising},
+  {'p', "priority", "PRIORITY",
+   gettext_noop ("use the given PRIORITY for the advertisments"),
+   1, &GNUNET_GETOPT_set_uint, &priority},
+  {'q', "quiet", NULL,
+   gettext_noop ("do not print names of remote namespaces"),
+   0, &GNUNET_GETOPT_set_one, &no_remote_printing},
+  {'r', "root", "ID",
+   gettext_noop
+   ("specify ID of the root of the namespace"),
+   1, &GNUNET_GETOPT_set_string, &root_identifier},
+  {'s', "set-rating", "ID:VALUE",
+   gettext_noop
+   ("change rating of namespace ID by VALUE"),
+   1, &GNUNET_GETOPT_set_string, &rating_change},
   GNUNET_GETOPT_OPTION_END
 };
 
index 7f22307472826c4eb5d1210ba64276b6f095f023..9b8a14052719701a2998d8d1765d40cebb3ede32 100644 (file)
@@ -47,7 +47,7 @@
 #include "gnunet-service-fs_indexing.h"
 #include "fs.h"
 
-#define DEBUG_FS 2
+#define DEBUG_FS GNUNET_NO
 
 /**
  * Maximum number of outgoing messages we queue per peer.
@@ -1188,8 +1188,10 @@ transmit_query_continuation (void *cls,
 
   if (tpid == 0)   
     {
+#if DEBUG_FS
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Transmission of request failed, will try again later.\n");
+#endif
       if (pr->task == GNUNET_SCHEDULER_NO_TASK)
        pr->task = GNUNET_SCHEDULER_add_delayed (sched,
                                                 get_processing_delay (),
@@ -1863,14 +1865,18 @@ process_reply (void *cls,
                                        gettext_noop ("# duplicate replies discarded (bloomfilter)"),
                                        1,
                                        GNUNET_NO);
+#if DEBUG_FS
              GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                          "Duplicate response `%s', discarding.\n",
                          GNUNET_h2s (&mhash));
+#endif
              return GNUNET_YES; /* duplicate */
            }
+#if DEBUG_FS
          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                      "New response `%s', adding to filter.\n",
                      GNUNET_h2s (&mhash));
+#endif
          GNUNET_CONTAINER_bloomfilter_add (pr->bf,
                                            &mhash);
        }
@@ -1970,9 +1976,11 @@ process_reply (void *cls,
     }
   if (GNUNET_YES == do_remove)
     {
+#if DEBUG_FS
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Removing request `%s' from request map (has been satisfied)\n",
                  GNUNET_h2s (key));
+#endif
       GNUNET_break (GNUNET_YES ==
                    GNUNET_CONTAINER_multihashmap_remove (query_request_map,
                                                          key,
@@ -2210,10 +2218,12 @@ process_local_reply (void *cls,
                                             pr);      
       return;
     }
+#if DEBUG_FS
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "New local response to `%s' of type %u.\n",
              GNUNET_h2s (key),
              type);
+#endif
   if (type == GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND)
     {
 #if DEBUG_FS
@@ -2274,10 +2284,14 @@ process_local_reply (void *cls,
                                                      pr->bf_size, 
                                                      BLOOMFILTER_K);
        }
+#if DEBUG_FS
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "New local response `%s', adding to filter.\n",
                  GNUNET_h2s (&mhash));
+#endif
 #if 0
+      /* this would break stuff since we will check the bf later
+        again (and would then discard the reply!) */
       GNUNET_CONTAINER_bloomfilter_add (pr->bf, 
                                        &mhash);
 #endif
index afb95bc7189aa71ae4f14367a21bf19f853dd016..af1fbfa50f594a9fd46824c08bd8caa0c757393c 100644 (file)
@@ -29,7 +29,7 @@
 #include "gnunet_arm_service.h"
 #include "gnunet_fs_service.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 #define START_ARM GNUNET_YES
 
index a7ccbeccf50955341c8e70f6f3f35cc330cc2e5e..9e02521a82d6ad42375b279a2e29258fa2dc2215 100644 (file)
@@ -31,7 +31,7 @@
 #include "gnunet_arm_service.h"
 #include "gnunet_fs_service.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 #define START_ARM GNUNET_YES
 
index 3316da3daae7f61f7cf58054001b407094fed819..3b4ba5c7069e485fcdd5d0c8f6ae11828303416e 100644 (file)
@@ -19,7 +19,7 @@ HOSTNAME = localhost
 DEFAULTSERVICES = resolver datastore transport core fs
 
 [datastore]
-DEBUG = YES
+DEBUG = YES
 
 [statistics]
 PORT = 42467
@@ -37,7 +37,7 @@ HOSTNAME = localhost
 PORT = 42471
 HOSTNAME = localhost
 IDENTITY_DIR = $SERVICEHOME/pseudos/
-DEBUG = YES
+DEBUG = YES
 
 [testing]
 WEAKRANDOM = YES
index d4d000c4052353a7a8165f7acff6c3c97b371bc8..4320f965f8edca72eb8fd2fc190fffd9afb29639 100644 (file)
@@ -29,7 +29,7 @@
 #include "gnunet_arm_service.h"
 #include "gnunet_fs_service.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 #define START_ARM GNUNET_YES
 
index 40b440b2e6e700ebff5f2aa3ceca0a1477e7e680..ce89cd8df2bd0e2a4e5e9ec5c725c9d76c753745 100644 (file)
@@ -19,7 +19,7 @@ HOSTNAME = localhost
 DEFAULTSERVICES = resolver datastore transport core fs
 
 [datastore]
-DEBUG = YES
+DEBUG = YES
 
 [statistics]
 PORT = 42467
@@ -36,7 +36,7 @@ HOSTNAME = localhost
 [fs]
 PORT = 42471
 HOSTNAME = localhost
-DEBUG = YES
+DEBUG = YES
 
 [testing]
 WEAKRANDOM = YES
index 0abb539d6af621d88a3656184c8c9ecf598eed40..a62200100fd7953ab822b5c0366fbac1e4fd298f 100644 (file)
@@ -26,7 +26,7 @@
 #include "platform.h"
 #include "fs_test_lib.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 /**
  * File-size we use for testing.
index 024e08155a6afb3fa4c3034c341d47d03d113824..4153c65848b7192d966e2ec06cda1be4ead34fbf 100644 (file)
@@ -26,7 +26,7 @@
 #include "platform.h"
 #include "fs_test_lib.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 /**
  * File-size we use for testing.