gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated (65dbd214b -> 67362c231)


From: gnunet
Subject: [gnunet] branch master updated (65dbd214b -> 67362c231)
Date: Wed, 18 Oct 2023 15:49:29 +0200

This is an automated email from the git hooks/post-receive script.

t3sserakt pushed a change to branch master
in repository gnunet.

    from 65dbd214b BUILD: Move identity/rest components to service/rest-plugin
     new 7761b424d Hostlist: Task added to start reading the hostlist entries 
only after a certain period of time has elapsed.
     new 3c761cdd0 Hostlist: Added test config to have a peer running the 
hostlist server.
     new 3e7b01620 Hello: Fix bug in cli tool to generate contrib hello file.
     new 59ea70ba2 Hello: Changed signature of method 
GNUNET_HELLO_builder_get_id
     new 3b62cab22 Hostlist: Fixed bug in hostlist client.
     new e4b146efc Hostlist: Changed hostlist server to use a hello cache.
     new 051653827 Bootstrap: Fixed bug to not replace hellos for a peer.
     new c5cce2b62 TNG: Fixed bug in shared secret handling of udo communicator.
     new e0d28ef92 Hello: Fix another bug in cli tool to generate contrib hello 
file.
     new 3d595570d Merge branch 'master' of ssh://git.gnunet.org/gnunet. 
Undeleted src/hello/gnunet-hello.c, because it is still needed.
     new 67362c231 Merge branch 'master' of ssh://git.gnunet.org/gnunet

The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/hello/gnunet-hello.c                         | 427 +++++++++++++++++++++++
 src/hostlist/gnunet-daemon-hostlist_client.c     |   3 +-
 src/hostlist/gnunet-daemon-hostlist_server.c     | 142 ++++----
 src/include/gnunet_hello_uri_lib.h               |   4 +-
 src/lib/hello/hello-uri.c                        |   4 +-
 src/peerstore/gnunet-service-peerstore.c         |  10 +-
 src/service/core/test_core_plugin_cmd_just_run.c |  14 +-
 src/transport/gnunet-communicator-udp.c          |   2 +-
 8 files changed, 528 insertions(+), 78 deletions(-)
 create mode 100644 src/hello/gnunet-hello.c

diff --git a/src/hello/gnunet-hello.c b/src/hello/gnunet-hello.c
new file mode 100644
index 000000000..7f43e77b9
--- /dev/null
+++ b/src/hello/gnunet-hello.c
@@ -0,0 +1,427 @@
+/*
+     This file is part of GNUnet
+     Copyright (C) 2012 GNUnet e.V.
+
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     Affero General Public License for more details.
+
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
+ */
+/**
+ * @file hello/gnunet-hello.c
+ * @brief change HELLO files to never expire
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_protocols.h"
+#include "gnunet_hello_lib.h"
+#include "gnunet_hello_uri_lib.h"
+#include "gnunet_transport_plugin.h"
+
+/**
+ * Closure for #add_to_buf().
+ */
+struct AddContext
+{
+  /**
+   * Where to add.
+   */
+  char *buf;
+
+  /**
+   * Maximum number of bytes left
+   */
+  size_t max;
+
+  /**
+   * Number of bytes added so far.
+   */
+  size_t ret;
+
+  struct GNUNET_HELLO_Builder *builder;
+};
+
+/**
+ * Entry in doubly-linked list of all of our plugins.
+ */
+struct TransportPlugin
+{
+  /**
+   * This is a doubly-linked list.
+   */
+  struct TransportPlugin *next;
+
+  /**
+   * This is a doubly-linked list.
+   */
+  struct TransportPlugin *prev;
+
+  /**
+   * API of the transport as returned by the plugin's
+   * initialization function.
+   */
+  struct GNUNET_TRANSPORT_PluginFunctions *api;
+
+  /**
+   * Short name for the plugin (e.g. "tcp").
+   */
+  char *short_name;
+
+  /**
+   * Name of the library (e.g. "gnunet_plugin_transport_tcp").
+   */
+  char *lib_name;
+
+  /**
+   * Environment this transport service is using
+   * for this plugin.
+   */
+  struct GNUNET_TRANSPORT_PluginEnvironment env;
+};
+
+static int address_count;
+
+/**
+ * Our private key.
+ */
+static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key;
+
+/**
+ * Local peer own ID.
+ */
+struct GNUNET_PeerIdentity my_full_id;
+
+/**
+ * The file with hello in old style which we like to replace with the new one.
+ */
+static char *hello_file;
+
+/**
+ * Head of DLL of all loaded plugins.
+ */
+static struct TransportPlugin *plugins_head;
+
+/**
+ * Head of DLL of all loaded plugins.
+ */
+static struct TransportPlugin *plugins_tail;
+
+static void
+plugins_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  struct TransportPlugin *plug;
+  struct TransportPlugin *next;
+  char *libname;
+  char *plugs;
+  char *pos;
+
+  if (NULL != plugins_head)
+    return; /* already loaded */
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_string (cfg, "TRANSPORT", "PLUGINS",
+                                             &plugs))
+    return;
+  fprintf (stdout,"Starting transport plugins `%s'\n",
+              plugs);
+  for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " "))
+  {
+    fprintf (stdout,"Loading `%s' transport plugin\n",
+                pos);
+    GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", pos);
+    plug = GNUNET_new (struct TransportPlugin);
+    plug->short_name = GNUNET_strdup (pos);
+    plug->lib_name = libname;
+    plug->env.cfg = cfg;
+    plug->env.cls = plug->short_name;
+    GNUNET_CONTAINER_DLL_insert (plugins_head, plugins_tail, plug);
+  }
+  GNUNET_free (plugs);
+  next = plugins_head;
+  while (next != NULL)
+  {
+    plug = next;
+    next = plug->next;
+    plug->api = GNUNET_PLUGIN_load (plug->lib_name, &plug->env);
+    if (plug->api == NULL)
+    {
+      fprintf (stdout,"Failed to load transport plugin for `%s'\n",
+                  plug->lib_name);
+      GNUNET_CONTAINER_DLL_remove (plugins_head, plugins_tail, plug);
+      GNUNET_free (plug->short_name);
+      GNUNET_free (plug->lib_name);
+      GNUNET_free (plug);
+    }
+  }
+}
+
+
+static int
+add_to_builder (void *cls,
+            const struct GNUNET_HELLO_Address *address,
+            struct GNUNET_TIME_Absolute expiration)
+{
+  struct GNUNET_HELLO_Builder *builder= cls;
+  struct TransportPlugin *pos = plugins_head;
+  const char *addr;
+  char *uri;
+
+  while (NULL != pos)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "short_name: %s transport_name: %s\n",
+                pos->short_name,
+              address->transport_name);
+    if (0 == strcmp (address->transport_name, pos->short_name))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "short_name: %s transport_name: %s are the same\n",
+                  pos->short_name,
+              address->transport_name);
+      addr = strchr (strchr (pos->api->address_to_string (pos, address, 
address->address_length), '.')+1, '.') + 1;
+    }
+    pos = pos->next;
+  }
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Hello address string: %s\n",
+              addr);
+  GNUNET_asprintf (&uri, "%s://%s", address->transport_name, addr);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Hello address uri string: %s\n",
+              uri);
+  GNUNET_HELLO_builder_add_address (builder,
+                                    uri);
+}
+
+
+/**
+ * Add the given address with infinite expiration to the buffer.
+ *
+ * @param cls closure
+ * @param address address to add
+ * @param expiration old expiration
+ * @return #GNUNET_OK keep iterating
+ */
+static int
+add_to_buf (void *cls,
+            const struct GNUNET_HELLO_Address *address,
+            struct GNUNET_TIME_Absolute expiration)
+{
+  struct AddContext *ac = cls;
+  size_t ret;
+
+  ret = GNUNET_HELLO_add_address (address,
+                                  GNUNET_TIME_UNIT_FOREVER_ABS,
+                                  ac->buf,
+                                  ac->max);
+
+  ac->buf += ret;
+  ac->max -= ret;
+  ac->ret += ret;
+  address_count++;
+  return GNUNET_OK;
+}
+
+
+/**
+ * Add addresses from the address list to the HELLO.
+ *
+ * @param cls the HELLO with the addresses to add
+ * @param max maximum space available
+ * @param buf where to add the addresses
+ * @return number of bytes added, 0 to terminate
+ */
+static ssize_t
+add_from_hello (void *cls, size_t max, void *buf)
+{
+  struct GNUNET_HELLO_Message **orig = cls;
+  struct AddContext ac;
+
+  if (NULL == *orig)
+    return GNUNET_SYSERR; /* already done */
+  ac.buf = buf;
+  ac.max = max;
+  ac.ret = 0;
+  GNUNET_assert (
+    NULL ==
+    GNUNET_HELLO_iterate_addresses (*orig, GNUNET_NO, &add_to_buf, &ac));
+  *orig = NULL;
+  return ac.ret;
+}
+
+
+/**
+ * Main function that will be run without the scheduler.
+ *
+ * @param cls closure
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be 
NULL!)
+ * @param c configuration
+ */
+static void
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *c)
+{
+  struct GNUNET_DISK_FileHandle *fh;
+  struct GNUNET_HELLO_Message *orig;
+  struct GNUNET_HELLO_Message *result;
+  struct GNUNET_PeerIdentity pid;
+  uint64_t fsize;
+  ssize_t size_written;
+  struct GNUNET_HELLO_Builder *builder;
+  char *url;
+  const struct GNUNET_MessageHeader *msg;
+  struct GNUNET_MQ_Envelope *env;
+
+  plugins_load (c);
+  address_count = 0;
+
+  my_private_key =
+    GNUNET_CRYPTO_eddsa_key_create_from_configuration (c);
+  GNUNET_CRYPTO_eddsa_key_get_public (my_private_key,
+                                      &my_full_id.public_key);
+  fprintf (stdout,"We are peer %s\n", GNUNET_i2s (&my_full_id));
+
+  GNUNET_log_setup ("gnunet-hello", "DEBUG", NULL);
+
+  if (GNUNET_OK !=
+      GNUNET_DISK_file_size (hello_file, &fsize, GNUNET_YES, GNUNET_YES))
+  {
+    fprintf (stderr,
+             _ ("Error accessing file `%s': %s\n"),
+             hello_file,
+             strerror (errno));
+    return;
+  }
+  if (fsize > 65536)
+  {
+    fprintf (stderr, _ ("File `%s' is too big to be a HELLO\n"), hello_file);
+    return;
+  }
+  if (fsize < sizeof(struct GNUNET_MessageHeader))
+  {
+    fprintf (stderr, _ ("File `%s' is too small to be a HELLO\n"), hello_file);
+    return;
+  }
+  fh = GNUNET_DISK_file_open (hello_file,
+                              GNUNET_DISK_OPEN_READ,
+                              GNUNET_DISK_PERM_USER_READ);
+  if (NULL == fh)
+  {
+    fprintf (stderr,
+             _ ("Error opening file `%s': %s\n"),
+             hello_file,
+             strerror (errno));
+    return;
+  }
+  {
+    char buf[fsize] GNUNET_ALIGN;
+
+    GNUNET_assert (fsize == GNUNET_DISK_file_read (fh, buf, fsize));
+    GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
+    orig = (struct GNUNET_HELLO_Message *) buf;
+    if ((fsize < GNUNET_HELLO_size (orig)) ||
+        (GNUNET_OK != GNUNET_HELLO_get_id (orig, &pid)))
+    {
+      fprintf (stderr,
+               _ ("Did not find well-formed HELLO in file `%s'\n"),
+               hello_file);
+      return;
+    }
+    {
+      char *pids;
+
+      pids = GNUNET_CRYPTO_eddsa_public_key_to_string (&my_full_id.public_key);
+      fprintf (stdout, "Processing HELLO for peer `%s'\n", pids);
+      GNUNET_free (pids);
+    }
+    /* result = GNUNET_HELLO_create (&pid.public_key, */
+    /*                               &add_from_hello, */
+    /*                               &orig, */
+    /*                               GNUNET_HELLO_is_friend_only (orig)); */
+
+    builder = GNUNET_HELLO_builder_new (&my_full_id);
+    GNUNET_assert (
+    NULL ==
+    GNUNET_HELLO_iterate_addresses ((const struct GNUNET_HELLO_Message *) 
orig, GNUNET_NO, &add_to_builder, builder));
+    url = GNUNET_HELLO_builder_to_url (builder, my_private_key);
+    fprintf (stdout,"url: %s\n", url);
+    env = GNUNET_HELLO_builder_to_env (builder,
+                                 my_private_key,
+                                 GNUNET_TIME_UNIT_FOREVER_REL);
+    msg = GNUNET_MQ_env_get_msg (env);
+    //GNUNET_assert (NULL != result);
+    GNUNET_assert (NULL != msg);
+    fh =
+      GNUNET_DISK_file_open (hello_file,
+                             GNUNET_DISK_OPEN_WRITE | 
GNUNET_DISK_OPEN_TRUNCATE,
+                             GNUNET_DISK_PERM_USER_READ
+                             | GNUNET_DISK_PERM_USER_WRITE);
+    if (NULL == fh)
+    {
+      fprintf (stderr,
+               _ ("Error opening file `%s': %s\n"),
+               hello_file,
+               strerror (errno));
+      GNUNET_free (result);
+      return;
+    }
+    //fsize = GNUNET_HELLO_size (result);
+    size_written = GNUNET_DISK_file_write (fh, msg, ntohs (msg->size));
+    if (ntohs (msg->size) != size_written)
+    {
+      fprintf (stderr,
+               _ ("Error writing HELLO to file `%s': %s expected size %u size 
written %u\n"),
+               hello_file,
+               strerror (errno));
+      (void) GNUNET_DISK_file_close (fh);
+      return;
+    }
+    GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
+  }
+  fprintf (stderr,
+           _ ("Modified %u addresses, wrote %u bytes\n"),
+           address_count,
+           (unsigned int) ntohs (msg->size));
+  GNUNET_HELLO_builder_free (builder);
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+  { GNUNET_GETOPT_option_string ('h',
+                               "hello-file",
+                               "HELLO_FILE",
+                               gettext_noop ("Hello file to read"),
+                               &hello_file),
+    GNUNET_GETOPT_OPTION_END };
+  int ret;
+
+  ret = (GNUNET_OK ==
+         GNUNET_PROGRAM_run2 (argc,
+                             argv,
+                             "gnunet-peerinfo",
+                             gettext_noop ("Print information about peers."),
+                             options,
+                             &run,
+                             NULL,
+                             GNUNET_YES));
+  return ret;
+}
+
+
+/* end of gnunet-hello.c */
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c 
b/src/hostlist/gnunet-daemon-hostlist_client.c
index 0fd16370f..aceea0aaf 100644
--- a/src/hostlist/gnunet-daemon-hostlist_client.c
+++ b/src/hostlist/gnunet-daemon-hostlist_client.c
@@ -313,7 +313,8 @@ static struct GNUNET_PEERSTORE_Handle *peerstore;
 static void
 shc_cont (void *cls, int success)
 {
-  GNUNET_free (cls);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Hostlist entry stored successfully!\n");
 }
 
 
diff --git a/src/hostlist/gnunet-daemon-hostlist_server.c 
b/src/hostlist/gnunet-daemon-hostlist_server.c
index 54db95009..c4a7aab03 100644
--- a/src/hostlist/gnunet-daemon-hostlist_server.c
+++ b/src/hostlist/gnunet-daemon-hostlist_server.c
@@ -42,6 +42,10 @@
 #define GNUNET_ADV_TIMEOUT \
   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
 
+/**
+ * Map with hellos we build the hostlist with.
+ */
+struct GNUNET_CONTAINER_MultiPeerMap *hellos;
 
 /**
  * Handle to the HTTP server as provided by libmicrohttpd for IPv6.
@@ -68,6 +72,12 @@ static struct GNUNET_STATISTICS_Handle *stats;
  */
 static struct GNUNET_CORE_Handle *core;
 
+/**
+ * The task to delayed start the notification process intially.
+ * We like to give transport some time to give us our hello to distribute it.
+ */
+struct GNUNET_SCHEDULER_Task *peerstore_notify_task;
+
 /**
  * Our peerstore notification context.  We use notification
  * to instantly learn about new peers as they are discovered.
@@ -110,11 +120,6 @@ static char *hostlist_uri;
  */
 struct HostSet
 {
-  /**
-   * Iterator used to build @e data (NULL when done).
-   */
-  struct GNUNET_PEERSTORE_IterateContext *pitr;
-
   /**
    * Place where we accumulate all of the HELLO messages.
    */
@@ -188,64 +193,27 @@ finish_response ()
  * @param hello hello message for the peer (can be NULL)
  * @param err_msg message
  */
-static void
+static enum GNUNET_GenericReturnValue
 host_processor (void *cls,
-                const struct GNUNET_PEERSTORE_Record *record,
-                const char *emsg)
+                const struct GNUNET_PeerIdentity *peer,
+                void *value)
 {
+  (void *) cls;
   size_t old;
   size_t s;
-  struct GNUNET_MessageHeader *hello;
+  struct GNUNET_MessageHeader *hello = value;
   struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
   struct GNUNET_TIME_Absolute hello_exp;
 
-  if (NULL != emsg)
-  {
-    GNUNET_assert (NULL == &record->peer);
-    builder->pitr = NULL;
-    GNUNET_free (builder->data);
-    GNUNET_free (builder);
-    builder = NULL;
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                _ ("Error in communication with PEERSTORE service: %s\n"),
-                emsg);
-    return;
-  }
-  if (NULL == record)
-  {
-    builder->pitr = NULL;
-    finish_response ();
-    return;
-  }
-  else
-  {
-    hello = record->value;
-    if ((0 == record->value_size))
-    {
-      GNUNET_break (0);
-      return;
-    }
-    hello_exp = GNUNET_HELLO_builder_get_expiration_time (hello);
-    if (GNUNET_TIME_absolute_cmp (hello_exp, <, now))
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "HELLO for peer `%4s' has expired address, not suitable for 
hostlist!\n",
-                  GNUNET_i2s (&record->peer));
-      GNUNET_STATISTICS_update (stats,
-                                gettext_noop (
-                                  "Expired HELLO encountered (ignored)"),
-                                1,
-                                GNUNET_NO);
-      return;
-    }
-  }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "host_processor\n");
   old = builder->size;
   s = ntohs (hello->size);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received %u bytes of `%s' from peer `%s' for hostlist.\n",
               (unsigned int) s,
               "HELLO",
-              GNUNET_i2s (&record->peer));
+              GNUNET_i2s (peer));
   if ((old + s >= GNUNET_MAX_MALLOC_CHECKED) ||
       (old + s >= MAX_BYTES_PER_HOSTLISTS))
   {
@@ -255,14 +223,16 @@ host_processor (void *cls,
                                 "bytes not included in hostlist (size limit)"),
                               s,
                               GNUNET_NO);
-    return;
+    return GNUNET_YES;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Adding peer `%s' to hostlist (%u bytes)\n",
-              GNUNET_i2s (&record->peer),
+              GNUNET_i2s (peer),
               (unsigned int) s);
   GNUNET_array_grow (builder->data, builder->size, old + s);
   GNUNET_memcpy (&builder->data[old], hello, s);
+
+  return GNUNET_YES;
 }
 
 
@@ -500,20 +470,23 @@ process_notify (void *cls,
                 const struct GNUNET_MessageHeader *hello,
                 const char *err_msg)
 {
+  unsigned int map_size;
+  struct GNUNET_MessageHeader *hello_cpy;
+  struct GNUNET_PeerIdentity *peer_cpy;
+
+  map_size = GNUNET_CONTAINER_multipeermap_size (hellos);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peerstore is notifying us to rebuild our hostlist\n");
+              "Peerstore is notifying us to rebuild our hostlist map size 
%u\n",
+              map_size);
   if (NULL != err_msg)
+  {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 _ ("Error in communication with PEERSTORE service: %s\n"),
                 err_msg);
+    return;
+  }
   if (NULL != builder)
   {
-    /* restart re-build already in progress ... */
-    if (NULL != builder->pitr)
-    {
-      GNUNET_PEERSTORE_iterate_cancel (builder->pitr);
-      builder->pitr = NULL;
-    }
     GNUNET_free (builder->data);
     builder->size = 0;
     builder->data = NULL;
@@ -522,9 +495,27 @@ process_notify (void *cls,
   {
     builder = GNUNET_new (struct HostSet);
   }
-  GNUNET_assert (NULL != peerstore);
-  builder->pitr =
-    GNUNET_PEERSTORE_iterate (peerstore, "hostlist", NULL, 
GNUNET_PEERSTORE_HELLO_KEY, &host_processor, NULL);
+
+  peer_cpy = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
+  GNUNET_memcpy (peer_cpy, peer, sizeof (struct GNUNET_PeerIdentity));
+  hello_cpy = GNUNET_malloc (ntohs (hello->size));
+  GNUNET_memcpy (hello_cpy, hello, ntohs (hello->size));
+  GNUNET_assert (GNUNET_YES ==
+                 GNUNET_CONTAINER_multipeermap_put (hellos,
+                                                    peer_cpy,
+                                                    (struct
+                                                     GNUNET_MessageHeader *)
+                                                    hello_cpy,
+                                                    
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
+  if (0 != GNUNET_CONTAINER_multipeermap_iterate (hellos,
+                                                  &host_processor,
+                                                  NULL))
+    finish_response ();
+  map_size = GNUNET_CONTAINER_multipeermap_size (hellos);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "1 Peerstore is notifying us to rebuild our hostlist map size %u 
peer %s\n",
+              map_size,
+              GNUNET_i2s (peer));
 }
 
 
@@ -605,6 +596,19 @@ prepare_daemon (struct MHD_Daemon *daemon_handle)
 }
 
 
+static void
+start_notify (void *cls)
+{
+  (void) cls;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Starting to process new hellos to add to hostlist.\n");
+  peerstore_notify =
+    GNUNET_PEERSTORE_hello_changed_notify (peerstore, GNUNET_NO,
+                                           &process_notify, NULL);
+}
+
+
 /**
  * Start server offering our hostlist.
  *
@@ -634,6 +638,7 @@ GNUNET_HOSTLIST_server_start (const struct 
GNUNET_CONFIGURATION_Handle *c,
   const struct sockaddr *sa4;
   const struct sockaddr *sa6;
 
+  hellos = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES);
   advertising = advertise;
   if (! advertising)
   {
@@ -817,7 +822,9 @@ GNUNET_HOSTLIST_server_start (const struct 
GNUNET_CONFIGURATION_Handle *c,
     hostlist_task_v4 = prepare_daemon (daemon_handle_v4);
   if (NULL != daemon_handle_v6)
     hostlist_task_v6 = prepare_daemon (daemon_handle_v6);
-  peerstore_notify = GNUNET_PEERSTORE_hello_changed_notify (peerstore, 
GNUNET_NO, &process_notify, NULL);
+  peerstore_notify_task = GNUNET_SCHEDULER_add_delayed 
(GNUNET_TIME_UNIT_MINUTES,
+                                                        start_notify,
+                                                        NULL);
   return GNUNET_OK;
 }
 
@@ -859,13 +866,12 @@ GNUNET_HOSTLIST_server_stop ()
     GNUNET_PEERSTORE_hello_changed_notify_cancel (peerstore_notify);
     peerstore_notify = NULL;
   }
+  else if (NULL != peerstore_notify_task)
+  {
+    GNUNET_SCHEDULER_cancel (peerstore_notify_task);
+  }
   if (NULL != builder)
   {
-    if (NULL != builder->pitr)
-    {
-      GNUNET_PEERSTORE_iterate_cancel (builder->pitr);
-      builder->pitr = NULL;
-    }
     GNUNET_free (builder->data);
     GNUNET_free (builder);
     builder = NULL;
diff --git a/src/include/gnunet_hello_uri_lib.h 
b/src/include/gnunet_hello_uri_lib.h
index 858b60793..1c804f590 100644
--- a/src/include/gnunet_hello_uri_lib.h
+++ b/src/include/gnunet_hello_uri_lib.h
@@ -72,8 +72,8 @@ GNUNET_HELLO_builder_new (const struct GNUNET_PeerIdentity 
*pid);
 /**
  * Get the PeerIdentity for this builder.
  */
-struct GNUNET_PeerIdentity *
-GNUNET_HELLO_builder_get_id (struct GNUNET_HELLO_Builder *builder);
+const struct GNUNET_PeerIdentity *
+GNUNET_HELLO_builder_get_id (const struct GNUNET_HELLO_Builder *builder);
 
 
 /**
diff --git a/src/lib/hello/hello-uri.c b/src/lib/hello/hello-uri.c
index 83d43fa2b..25f8948fe 100644
--- a/src/lib/hello/hello-uri.c
+++ b/src/lib/hello/hello-uri.c
@@ -341,8 +341,8 @@ GNUNET_HELLO_builder_new (const struct GNUNET_PeerIdentity 
*pid)
 }
 
 
-struct GNUNET_PeerIdentity *
-GNUNET_HELLO_builder_get_id (struct GNUNET_HELLO_Builder *builder)
+const struct GNUNET_PeerIdentity *
+GNUNET_HELLO_builder_get_id (const struct GNUNET_HELLO_Builder *builder)
 {
   return &builder->pid;
 }
diff --git a/src/peerstore/gnunet-service-peerstore.c 
b/src/peerstore/gnunet-service-peerstore.c
index 514b173bb..2a8ecdfa2 100644
--- a/src/peerstore/gnunet-service-peerstore.c
+++ b/src/peerstore/gnunet-service-peerstore.c
@@ -555,7 +555,7 @@ hosts_directory_scan_callback (void *cls, const char 
*fullname)
   char buffer[GNUNET_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN;
   const struct GNUNET_MessageHeader *hello;
   struct GNUNET_HELLO_Builder *builder;
-  struct GNUNET_PeerIdentity *pid;
+  const struct GNUNET_PeerIdentity *pid;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "1 hosts_directory_scan_callback filename %s\n",
@@ -598,14 +598,18 @@ hosts_directory_scan_callback (void *cls, const char 
*fullname)
   builder = GNUNET_HELLO_builder_from_msg (hello);
   pid = GNUNET_HELLO_builder_get_id (builder);
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "store contrib hello for peer %s\n",
+              GNUNET_i2s (pid));
+  
   if (GNUNET_OK != db->store_record (db->cls,
                                      "peerstore",
                                      pid,
-                                     "",
+                                     GNUNET_PEERSTORE_HELLO_KEY,
                                      hello,
                                      size_total,
                                      GNUNET_TIME_UNIT_FOREVER_ABS,
-                                     GNUNET_PEERSTORE_STOREOPTION_REPLACE,
+                                     GNUNET_PEERSTORE_STOREOPTION_MULTIPLE,
                                      &store_hello_continuation,
                                      NULL))
   {
diff --git a/src/service/core/test_core_plugin_cmd_just_run.c 
b/src/service/core/test_core_plugin_cmd_just_run.c
index 176d055c8..04b65607d 100644
--- a/src/service/core/test_core_plugin_cmd_just_run.c
+++ b/src/service/core/test_core_plugin_cmd_just_run.c
@@ -391,8 +391,20 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb 
write_message,
     write_message);
 
 
-  GNUNET_asprintf (&ts->cfgname,
+  if (1 == m_int)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "m_int %u should be 1\n");
+    GNUNET_asprintf (&ts->cfgname,
+                     "test_core_just_run_host.conf");
+  }
+  else
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "m_int %u should not be 1\n");
+    GNUNET_asprintf (&ts->cfgname,
                    "test_core_just_run.conf");
+  }
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "plugin cfgname: %s\n",
diff --git a/src/transport/gnunet-communicator-udp.c 
b/src/transport/gnunet-communicator-udp.c
index f9bbe91f6..e977cffa4 100644
--- a/src/transport/gnunet-communicator-udp.c
+++ b/src/transport/gnunet-communicator-udp.c
@@ -1012,7 +1012,7 @@ secret_destroy (struct SharedSecret *ss)
     sender->num_secrets--;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "%u sender->num_secrets\n",
-                receiver->num_secrets);
+                sender->num_secrets);
     if (NULL != ss->sender->kce_task)
     {
       GNUNET_SCHEDULER_cancel (ss->sender->kce_task);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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