gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: hello: add new gnunet-hello CLI; fix war


From: gnunet
Subject: [gnunet] branch master updated: hello: add new gnunet-hello CLI; fix warnings; update submodules
Date: Wed, 07 Aug 2024 10:42:23 +0200

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

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 6cdc6eabb hello: add new gnunet-hello CLI; fix warnings; update 
submodules
6cdc6eabb is described below

commit 6cdc6eabb454b3828bb3027e6ff90f80146cb5bb
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Wed Aug 7 10:42:14 2024 +0200

    hello: add new gnunet-hello CLI; fix warnings; update submodules
---
 configure.ac                                       |   1 +
 contrib/gana                                       |   2 +-
 contrib/handbook                                   |   2 +-
 doc/man/Makefile.am                                |   1 +
 doc/man/gnunet-hello.1                             |  89 +++++
 doc/man/meson.build                                |   1 +
 po/POTFILES.in                                     |   3 +-
 src/cli/Makefile.am                                |   1 +
 src/cli/core/Makefile.am                           |   2 -
 src/cli/core/gnunet-core.c                         | 176 +--------
 src/cli/core/meson.build                           |   3 +-
 src/cli/{core => hello}/Makefile.am                |  13 +-
 .../{core/gnunet-core.c => hello/gnunet-hello.c}   | 160 +-------
 src/cli/{core => hello}/meson.build                |   7 +-
 src/cli/meson.build                                |   1 +
 src/cli/namestore/gnunet-namestore.c               |   2 +-
 src/lib/hello/gnunet-hello.c                       | 426 ---------------------
 src/lib/hello/hello-uri.c                          |   2 +-
 src/lib/util/crypto_elligator.c                    |   2 +-
 src/service/dht/gnunet-service-dht_neighbours.c    |   2 +-
 20 files changed, 126 insertions(+), 770 deletions(-)

diff --git a/configure.ac b/configure.ac
index 467ffebc4..3d61fa27c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1322,6 +1322,7 @@ src/cli/datastore/Makefile
 src/cli/dht/Makefile
 src/cli/fs/Makefile
 src/cli/gns/Makefile
+src/cli/hello/Makefile
 src/cli/identity/Makefile
 src/cli/messenger/Makefile
 src/cli/namecache/Makefile
diff --git a/contrib/gana b/contrib/gana
index 3ae4bcc5c..a2057ac0e 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit 3ae4bcc5c40d63d91c5248311b93419e4faabf8f
+Subproject commit a2057ac0e3c43950dcfc5024cc0abe6f362e45ba
diff --git a/contrib/handbook b/contrib/handbook
index ae9976551..77a011d42 160000
--- a/contrib/handbook
+++ b/contrib/handbook
@@ -1 +1 @@
-Subproject commit ae9976551b142d02053ca07239975fa6155cdf77
+Subproject commit 77a011d421b3d0c89f1c7006c00280ba6c7c4199
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
index 6ab720826..d7e971df7 100644
--- a/doc/man/Makefile.am
+++ b/doc/man/Makefile.am
@@ -60,6 +60,7 @@ man_MANS = \
   gnunet-gns.1 \
   gnunet-gns-proxy.1 \
   gnunet-gns-proxy-setup-ca.1 \
+  gnunet-hello.1 \
   gnunet-identity.1 \
   gnunet-cadet.1 \
   gnunet-messenger.1 \
diff --git a/doc/man/gnunet-hello.1 b/doc/man/gnunet-hello.1
new file mode 100644
index 000000000..ea24bd274
--- /dev/null
+++ b/doc/man/gnunet-hello.1
@@ -0,0 +1,89 @@
+.\" This file is part of GNUnet.
+.\" Copyright (C) 2024 GNUnet e.V.
+.\"
+.\" Permission is granted to copy, distribute and/or modify this document
+.\" under the terms of the GNU Free Documentation License, Version 1.3 or
+.\" any later version published by the Free Software Foundation; with no
+.\" Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.  A
+.\" copy of the license is included in the file
+.\" FDL-1.3.
+.\"
+.\" A copy of the license is also available from the Free Software
+.\" Foundation Web site at http://www.gnu.org/licenses/fdl.html}.
+.\"
+.\" Alternately, this document is also available under the General
+.\" Public License, version 3 or later, as published by the Free Software
+.\" Foundation.  A copy of the license is included in the file
+.\" GPL3.
+.\"
+.\" A copy of the license is also available from the Free Software
+.\" Foundation Web site at http://www.gnu.org/licenses/gpl.html
+.\"
+.\" SPDX-License-Identifier: GPL3.0-or-later OR FDL1.3-or-later
+.\"
+.Dd August 07, 2024
+.Dt GNUNET-HELLO 1
+.Os
+.Sh NAME
+.Nm gnunet-hello
+.Nd import/export print HELLOs
+.Sh SYNOPSIS
+.Nm
+.Op Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME
+.Op Fl h | -help
+.Op Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL
+.Op Fl I Ar HELLOURI | Fl -import-hello= Ns Ar HELLOURI
+.Op Fl H | -export-hello
+.Op Fl D | -dump-hellos
+.Op Fl v | -version
+.Op Fl V | -verbose
+.Sh DESCRIPTION
+.Nm
+is a tool to import/export and print known HELLOs.
+.Bl -tag -width indent
+.It Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME
+Configuration file to use.
+.It Fl h | -help
+Print the help page.
+.It Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL
+Change the loglevel.
+Possible values for LOGLEVEL are ERROR, WARNING, INFO and DEBUG.
+.It Fl I Ar HELLOURI | Fl -import-hello= Ns Ar HELLOURI
+Import a HELLO URI (into the peerstore and make it available to core).
+.It Fl H | -export-hello
+Print a freshly signed HELLO URI for our peer.
+.It Fl D | -dump-hellos
+Print all known HELLOs (peer IDs and addresses).
+These are only all known, and not necessarily connected peers.
+.It Fl v | -version
+Print the version number.
+.It Fl V | -verbose
+Be verbose.
+.El
+.\".Sh EXAMPLES
+.Sh SEE ALSO
+.Xr gnunet-transport 1
+.Pp
+The full documentation for gnunet is maintained as a Texinfo manual.
+If the
+.Xr info 1
+and gnunet programs are properly installed at your site, the command
+.Pp
+.Dl info gnunet
+.Pp
+should give you access to the complete handbook,
+.Pp
+.Dl info gnunet-c-tutorial
+.Pp
+will give you access to a tutorial for developers.
+.sp
+Depending on your installation, this information is also available in
+.Xr gnunet 7 and
+.Xr gnunet-c-tutorial 7 .
+.\".Sh HISTORY
+.\".Sh AUTHORS
+.Sh BUGS
+Report bugs by using
+.Lk https://bugs.gnunet.org
+or by sending electronic mail to
+.Aq Mt gnunet-developers@gnu.org .
diff --git a/doc/man/meson.build b/doc/man/meson.build
index fbd8179ba..354dc8a8d 100644
--- a/doc/man/meson.build
+++ b/doc/man/meson.build
@@ -30,6 +30,7 @@ install_man(
   'gnunet-gns.1',
   'gnunet-gns-proxy.1',
   'gnunet-gns-proxy-setup-ca.1',
+  'gnunet-hello.1',
   'gnunet-identity.1',
   'gnunet-cadet.1',
   'gnunet-messenger.1',
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 60cf06f91..3169f263f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -14,6 +14,7 @@ src/cli/fs/gnunet-publish.c
 src/cli/fs/gnunet-search.c
 src/cli/fs/gnunet-unindex.c
 src/cli/gns/gnunet-gns.c
+src/cli/hello/gnunet-hello.c
 src/cli/identity/gnunet-identity.c
 src/cli/messenger/gnunet-messenger.c
 src/cli/namecache/gnunet-namecache.c
@@ -25,7 +26,6 @@ src/cli/nat-auto/gnunet-nat-auto.c
 src/cli/nat-auto/gnunet-nat-server.c
 src/cli/nat/gnunet-nat.c
 src/cli/nse/gnunet-nse.c
-src/cli/peerstore/gnunet-peerstore.c
 src/cli/reclaim/gnunet-did.c
 src/cli/reclaim/gnunet-reclaim.c
 src/cli/revocation/gnunet-revocation-tvg.c
@@ -110,7 +110,6 @@ src/lib/gnsrecord/gnsrecord_pow.c
 src/lib/gnsrecord/gnsrecord_serialization.c
 src/lib/gnsrecord/gnunet-gnsrecord-tvg.c
 src/lib/gnsrecord/json_gnsrecord.c
-src/lib/hello/gnunet-hello.c
 src/lib/hello/hello-ng.c
 src/lib/hello/hello-uri.c
 src/lib/json/json.c
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index d7584b2c4..db2367e33 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -3,6 +3,7 @@ SUBDIRS = \
        arm \
        statistics \
        core \
+       hello \
        nat \
        nat-auto \
        nse \
diff --git a/src/cli/core/Makefile.am b/src/cli/core/Makefile.am
index 2179a8824..97abf0db2 100644
--- a/src/cli/core/Makefile.am
+++ b/src/cli/core/Makefile.am
@@ -19,8 +19,6 @@ gnunet_core_SOURCES = \
  gnunet-core.c
 gnunet_core_LDADD = \
   $(top_builddir)/src/service/core/libgnunetcore.la \
-  $(top_builddir)/src/service/peerstore/libgnunetpeerstore.la \
-  $(top_builddir)/src/lib/hello/libgnunethello.la \
   $(top_builddir)/src/lib/util/libgnunetutil.la
 gnunet_core_LDFLAGS = \
   $(GN_LIBINTL)
diff --git a/src/cli/core/gnunet-core.c b/src/cli/core/gnunet-core.c
index bbbccc928..f40ab84e3 100644
--- a/src/cli/core/gnunet-core.c
+++ b/src/cli/core/gnunet-core.c
@@ -23,13 +23,11 @@
  * @brief Print information about other peers known to CORE.
  * @author Nathan Evans
  */
-#include "gnunet_time_lib.h"
 #include "platform.h"
+#include "gnunet_time_lib.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_core_service.h"
-#include "gnunet_hello_uri_lib.h"
 #include "gnunet_util_lib.h"
-#include "gnunet_peerstore_service.h"
 
 /**
  * Return code
@@ -56,21 +54,6 @@ static int show_conns;
  */
 static struct GNUNET_CORE_MonitorHandle *mh;
 
-/*
- * Handle to PEERSTORE service
- */
-static struct GNUNET_PEERSTORE_Handle *peerstore_handle;
-
-/**
- * PEERSTORE iteration context
- */
-static struct GNUNET_PEERSTORE_IterateContext *iter_ctx;
-
-/**
- * HELLO store context handle
- */
-static struct GNUNET_PEERSTORE_StoreHelloContext *shc;
-
 /**
  * Peer private key
  */
@@ -81,21 +64,6 @@ static struct GNUNET_CRYPTO_EddsaPrivateKey my_private_key;
  */
 static struct GNUNET_PeerIdentity my_full_id;
 
-/**
- * HELLO URI export option -H
- */
-static int export_own_hello_uri;
-
-/**
- * Hello list option -D
- */
-static int print_hellos;
-
-/**
- * HELLO URI import option -I
- */
-static char *import_uri;
-
 /**
  * Task run in monitor mode when the user presses CTRL-C to abort.
  * Stops monitoring activity.
@@ -111,20 +79,6 @@ shutdown_task (void *cls)
     GNUNET_CORE_monitor_stop (mh);
     mh = NULL;
   }
-  if (NULL != shc)
-  {
-    GNUNET_PEERSTORE_hello_add_cancel (shc);
-    shc = NULL;
-  }
-  if (NULL != iter_ctx)
-  {
-    GNUNET_PEERSTORE_iteration_stop (iter_ctx);
-  }
-  if (NULL != peerstore_handle)
-  {
-    GNUNET_PEERSTORE_disconnect (peerstore_handle);
-    peerstore_handle = NULL;
-  }
 }
 
 
@@ -207,91 +161,6 @@ monitor_cb (void *cls,
 }
 
 
-/**
- * Callback function used to extract URIs from a builder.
- * Called when we should consider connecting to a peer.
- *
- * @param cls closure pointing to a `struct GNUNET_PeerIdentity *`
- * @param uri one of the URIs
- */
-void
-print_hello_addrs (void *cls,
-                   const struct GNUNET_PeerIdentity *pid,
-                   const char *uri)
-{
-  (void) cls;
-
-
-  printf ("|- %s\n", uri);
-}
-
-
-void
-hello_iter (void *cls, const struct GNUNET_PEERSTORE_Record *record,
-            const char *emsg)
-{
-  struct GNUNET_HELLO_Builder *hb;
-  struct GNUNET_TIME_Absolute hello_exp;
-  const struct GNUNET_PeerIdentity *pid;
-  char *url;
-
-  if ((NULL == record) && (NULL == emsg))
-  {
-    /** If we ever get here, we are newer than the existing record
-     *  or the only/first record.
-     */
-    iter_ctx = NULL;
-    GNUNET_SCHEDULER_shutdown ();
-    return;
-  }
-  if (NULL != emsg)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
-    GNUNET_PEERSTORE_iteration_next (iter_ctx, 1);
-    return;
-  }
-  hb = GNUNET_HELLO_builder_from_msg (record->value);
-  hello_exp = GNUNET_HELLO_builder_get_expiration_time (record->value);
-  pid = GNUNET_HELLO_builder_get_id (hb);
-  if (export_own_hello_uri)
-  {
-    if (0 == GNUNET_memcmp (&my_full_id,
-                            pid))
-    {
-      url = GNUNET_HELLO_builder_to_url (hb, &my_private_key);
-      printf ("%s\n", url);
-      GNUNET_free (url);
-      GNUNET_PEERSTORE_iteration_stop (iter_ctx);
-      iter_ctx = NULL;
-      GNUNET_HELLO_builder_free (hb);
-      GNUNET_SCHEDULER_shutdown ();
-      return;
-    }
-  }
-  else if (print_hellos)
-  {
-    printf ("`%s' (expires: %s):\n", GNUNET_i2s (pid),
-            GNUNET_STRINGS_absolute_time_to_string (hello_exp));
-    GNUNET_HELLO_builder_iterate (hb, &print_hello_addrs, NULL);
-  }
-  GNUNET_HELLO_builder_free (hb);
-  GNUNET_PEERSTORE_iteration_next (iter_ctx, 1);
-}
-
-
-static void
-hello_store_success (void *cls, int success)
-{
-  shc = NULL;
-  if (GNUNET_OK != success)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Storing hello uri failed\n");
-  }
-  GNUNET_SCHEDULER_shutdown ();
-}
-
-
 /**
  * Main function that will be run by the scheduler.
  *
@@ -306,8 +175,6 @@ run (void *cls,
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-  struct GNUNET_HELLO_Builder *hb;
-  struct GNUNET_MQ_Envelope *env;
   char *keyfile;
   (void) cls;
   (void) cfgfile;
@@ -317,8 +184,7 @@ run (void *cls,
     fprintf (stderr, _ ("Invalid command line argument `%s'\n"), args[0]);
     return;
   }
-  if (! show_pid && ! show_conns && ! monitor_connections &&
-      ! print_hellos && ! export_own_hello_uri && (NULL == import_uri))
+  if (! show_pid && ! show_conns && ! monitor_connections)
   {
     fprintf (stderr, "%s", _ ("No argument given.\n"));
     ret = 1;
@@ -364,30 +230,10 @@ run (void *cls,
     {
       fprintf (stderr, "%s", _ ("Failed to connect to CORE service!\n"));
       ret = 1;
-      GNUNET_SCHEDULER_shutdown();
+      GNUNET_SCHEDULER_shutdown ();
     }
     return;
   }
-  peerstore_handle = GNUNET_PEERSTORE_connect (cfg);
-  GNUNET_assert (NULL != peerstore_handle);
-  if (NULL != import_uri)
-  {
-    hb = GNUNET_HELLO_builder_from_url (import_uri);
-    env = GNUNET_HELLO_builder_to_env (hb, NULL, GNUNET_TIME_UNIT_ZERO);
-    shc = GNUNET_PEERSTORE_hello_add (peerstore_handle,
-                                      GNUNET_MQ_env_get_msg (env),
-                                      &hello_store_success, NULL);
-    GNUNET_HELLO_builder_free (hb);
-    return;
-  }
-
-  iter_ctx = GNUNET_PEERSTORE_iteration_start (peerstore_handle,
-                                               "peerstore",
-                                               NULL,
-                                               GNUNET_PEERSTORE_HELLO_KEY,
-                                               &hello_iter,
-                                               NULL);
-
 }
 
 
@@ -423,21 +269,7 @@ main (int argc, char *const *argv)
         "Show current connections"
         ),
       &show_conns),
-    GNUNET_GETOPT_option_flag ('H',
-                               "export-hello-uri",
-                               gettext_noop (
-                                 "Print a HELLO URI for our peer identity"),
-                               &export_own_hello_uri),
-    GNUNET_GETOPT_option_string ('I',
-                                 "import-hello",
-                                 gettext_noop ("Import a HELLO URI"),
-                                 "URI",
-                                 &import_uri),
-    GNUNET_GETOPT_option_flag ('D',
-                               "dump-hellos",
-                               gettext_noop (
-                                 "List all known HELLOs in peerstore"),
-                               &print_hellos),    GNUNET_GETOPT_OPTION_END };
+    GNUNET_GETOPT_OPTION_END };
 
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
diff --git a/src/cli/core/meson.build b/src/cli/core/meson.build
index 144c911dc..624b59477 100644
--- a/src/cli/core/meson.build
+++ b/src/cli/core/meson.build
@@ -2,8 +2,7 @@ executable ('gnunet-core',
             ['gnunet-core.c'],
             dependencies: [libgnunetcore_dep,
                            libgnunetutil_dep,
-                           libgnunethello_dep,
-                           libgnunetpeerstore_dep],
+                          ],
             include_directories: [incdir, configuration_inc],
             install: true,
             install_dir: get_option('bindir'))
diff --git a/src/cli/core/Makefile.am b/src/cli/hello/Makefile.am
similarity index 74%
copy from src/cli/core/Makefile.am
copy to src/cli/hello/Makefile.am
index 2179a8824..c059e8458 100644
--- a/src/cli/core/Makefile.am
+++ b/src/cli/hello/Makefile.am
@@ -13,14 +13,13 @@ if USE_COVERAGE
 endif
 
 bin_PROGRAMS = \
- gnunet-core
+ gnunet-hello
 
-gnunet_core_SOURCES = \
- gnunet-core.c
-gnunet_core_LDADD = \
-  $(top_builddir)/src/service/core/libgnunetcore.la \
-  $(top_builddir)/src/service/peerstore/libgnunetpeerstore.la \
+gnunet_hello_SOURCES = \
+ gnunet-hello.c
+gnunet_hello_LDADD = \
   $(top_builddir)/src/lib/hello/libgnunethello.la \
+  $(top_builddir)/src/service/peerstore/libgnunetpeerstore.la \
   $(top_builddir)/src/lib/util/libgnunetutil.la
-gnunet_core_LDFLAGS = \
+gnunet_hello_LDFLAGS = \
   $(GN_LIBINTL)
diff --git a/src/cli/core/gnunet-core.c b/src/cli/hello/gnunet-hello.c
similarity index 69%
copy from src/cli/core/gnunet-core.c
copy to src/cli/hello/gnunet-hello.c
index bbbccc928..26df9f445 100644
--- a/src/cli/core/gnunet-core.c
+++ b/src/cli/hello/gnunet-hello.c
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2011, 2012, 2014 GNUnet e.V.
+     Copyright (C) 2024 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
@@ -19,14 +19,13 @@
  */
 
 /**
- * @file core/gnunet-core.c
- * @brief Print information about other peers known to CORE.
+ * @file cli/hello/gnunet-hello.c
+ * @brief Export/import/print HELLOs.
  * @author Nathan Evans
  */
-#include "gnunet_time_lib.h"
 #include "platform.h"
+#include "gnunet_time_lib.h"
 #include "gnunet_util_lib.h"
-#include "gnunet_core_service.h"
 #include "gnunet_hello_uri_lib.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_peerstore_service.h"
@@ -36,26 +35,6 @@
  */
 static int ret;
 
-/**
- * Option -m.
- */
-static int monitor_connections;
-
-/**
- * Option -i.
- */
-static int show_pid;
-
-/**
- * Option -s.
- */
-static int show_conns;
-
-/**
- * Handle to the CORE monitor.
- */
-static struct GNUNET_CORE_MonitorHandle *mh;
-
 /*
  * Handle to PEERSTORE service
  */
@@ -106,11 +85,6 @@ static void
 shutdown_task (void *cls)
 {
   (void) cls;
-  if (NULL != mh)
-  {
-    GNUNET_CORE_monitor_stop (mh);
-    mh = NULL;
-  }
   if (NULL != shc)
   {
     GNUNET_PEERSTORE_hello_add_cancel (shc);
@@ -128,85 +102,6 @@ shutdown_task (void *cls)
 }
 
 
-/**
- * Function called to notify core users that another
- * peer changed its state with us.
- *
- * @param cls closure
- * @param peer the peer that changed state
- * @param state new state of the peer
- * @param timeout timeout for the new state
- */
-static void
-monitor_cb (void *cls,
-            const struct GNUNET_PeerIdentity *peer,
-            enum GNUNET_CORE_KxState state,
-            struct GNUNET_TIME_Absolute timeout)
-{
-  struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
-  const char *now_str;
-  const char *state_str;
-
-  (void) cls;
-  if (((NULL == peer) || (GNUNET_CORE_KX_ITERATION_FINISHED == state)) &&
-      (GNUNET_NO == monitor_connections))
-  {
-    GNUNET_SCHEDULER_shutdown ();
-    return;
-  }
-
-  switch (state)
-  {
-  case GNUNET_CORE_KX_STATE_DOWN:
-    /* should never happen, as we immediately send the key */
-    state_str = _ ("fresh connection");
-    break;
-
-  case GNUNET_CORE_KX_STATE_KEY_SENT:
-    state_str = _ ("key sent");
-    break;
-
-  case GNUNET_CORE_KX_STATE_KEY_RECEIVED:
-    state_str = _ ("key received");
-    break;
-
-  case GNUNET_CORE_KX_STATE_UP:
-    state_str = _ ("connection established");
-    break;
-
-  case GNUNET_CORE_KX_STATE_REKEY_SENT:
-    state_str = _ ("rekeying");
-    break;
-
-  case GNUNET_CORE_KX_PEER_DISCONNECT:
-    state_str = _ ("disconnected");
-    break;
-
-  case GNUNET_CORE_KX_ITERATION_FINISHED:
-    return;
-
-  case GNUNET_CORE_KX_CORE_DISCONNECT:
-    fprintf (stderr,
-             "%s\n",
-             _ ("Connection to CORE service lost (reconnecting)"));
-    return;
-
-  default:
-    state_str = _ ("unknown state");
-    break;
-  }
-  now_str = GNUNET_STRINGS_absolute_time_to_string (now);
-  fprintf (stdout,
-           _ ("%24s: %-30s %4s (timeout in %6s)\n"),
-           now_str,
-           state_str,
-           GNUNET_i2s (peer),
-           GNUNET_STRINGS_relative_time_to_string (
-             GNUNET_TIME_absolute_get_remaining (timeout),
-             GNUNET_YES));
-}
-
-
 /**
  * Callback function used to extract URIs from a builder.
  * Called when we should consider connecting to a peer.
@@ -317,8 +212,9 @@ run (void *cls,
     fprintf (stderr, _ ("Invalid command line argument `%s'\n"), args[0]);
     return;
   }
-  if (! show_pid && ! show_conns && ! monitor_connections &&
-      ! print_hellos && ! export_own_hello_uri && (NULL == import_uri))
+  if (! print_hellos &&
+      ! export_own_hello_uri &&
+      (NULL == import_uri))
   {
     fprintf (stderr, "%s", _ ("No argument given.\n"));
     ret = 1;
@@ -353,21 +249,6 @@ run (void *cls,
   }
   GNUNET_free (keyfile);
   GNUNET_CRYPTO_eddsa_key_get_public (&my_private_key, &my_full_id.public_key);
-  if (show_pid)
-    fprintf (stdout,
-             _ ("Current local peer identity: %s\n"),
-             GNUNET_i2s_full (&my_full_id));
-  if (show_conns || monitor_connections)
-  {
-    mh = GNUNET_CORE_monitor_start (cfg, &monitor_cb, NULL);
-    if (NULL == mh)
-    {
-      fprintf (stderr, "%s", _ ("Failed to connect to CORE service!\n"));
-      ret = 1;
-      GNUNET_SCHEDULER_shutdown();
-    }
-    return;
-  }
   peerstore_handle = GNUNET_PEERSTORE_connect (cfg);
   GNUNET_assert (NULL != peerstore_handle);
   if (NULL != import_uri)
@@ -403,26 +284,7 @@ main (int argc, char *const *argv)
 {
   int res;
   struct GNUNET_GETOPT_CommandLineOption options[] =
-  { GNUNET_GETOPT_option_flag (
-      'm',
-      "monitor",
-      gettext_noop (
-        "provide information about all current connections (continuously)"),
-      &monitor_connections),
-    GNUNET_GETOPT_option_flag (
-      'i',
-      "show-identity",
-      gettext_noop (
-        "Show our current peer identity"
-        ),
-      &show_pid),
-    GNUNET_GETOPT_option_flag (
-      's',
-      "connection-status",
-      gettext_noop (
-        "Show current connections"
-        ),
-      &show_conns),
+  {
     GNUNET_GETOPT_option_flag ('H',
                                "export-hello-uri",
                                gettext_noop (
@@ -443,9 +305,9 @@ main (int argc, char *const *argv)
     return 2;
   res = GNUNET_PROGRAM_run (argc,
                             argv,
-                            "gnunet-core",
+                            "gnunet-hello",
                             gettext_noop (
-                              "Print information about connected peers."),
+                              "Import/export/print HELLOs."),
                             options,
                             &run,
                             NULL);
@@ -457,4 +319,4 @@ main (int argc, char *const *argv)
 }
 
 
-/* end of gnunet-core.c */
+/* end of gnunet-hello.c */
diff --git a/src/cli/core/meson.build b/src/cli/hello/meson.build
similarity index 61%
copy from src/cli/core/meson.build
copy to src/cli/hello/meson.build
index 144c911dc..adc8f423b 100644
--- a/src/cli/core/meson.build
+++ b/src/cli/hello/meson.build
@@ -1,7 +1,6 @@
-executable ('gnunet-core',
-            ['gnunet-core.c'],
-            dependencies: [libgnunetcore_dep,
-                           libgnunetutil_dep,
+executable ('gnunet-hello',
+            ['gnunet-hello.c'],
+            dependencies: [libgnunetutil_dep,
                            libgnunethello_dep,
                            libgnunetpeerstore_dep],
             include_directories: [incdir, configuration_inc],
diff --git a/src/cli/meson.build b/src/cli/meson.build
index 5c1fded1a..2af93f6e9 100644
--- a/src/cli/meson.build
+++ b/src/cli/meson.build
@@ -5,6 +5,7 @@ subdir('datastore')
 subdir('nat')
 subdir('nat-auto')
 subdir('core')
+subdir('hello')
 subdir('nse')
 subdir('dht')
 subdir('identity')
diff --git a/src/cli/namestore/gnunet-namestore.c 
b/src/cli/namestore/gnunet-namestore.c
index 901308147..8dd16fe2d 100644
--- a/src/cli/namestore/gnunet-namestore.c
+++ b/src/cli/namestore/gnunet-namestore.c
@@ -25,8 +25,8 @@
  * TODO:
  * - test
  */
-#include "gnunet_common.h"
 #include "platform.h"
+#include "gnunet_common.h"
 #include <gnunet_util_lib.h>
 #include <gnunet_identity_service.h>
 #include <gnunet_gnsrecord_lib.h>
diff --git a/src/lib/hello/gnunet-hello.c b/src/lib/hello/gnunet-hello.c
deleted file mode 100644
index aaa4b5005..000000000
--- a/src/lib/hello/gnunet-hello.c
+++ /dev/null
@@ -1,426 +0,0 @@
-/*
-     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_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/lib/hello/hello-uri.c b/src/lib/hello/hello-uri.c
index b7c177387..a6177eef0 100644
--- a/src/lib/hello/hello-uri.c
+++ b/src/lib/hello/hello-uri.c
@@ -34,8 +34,8 @@
  *   that does this to create bootstrap HELLOs shipped with
  *   the TGZ.
  */
-#include "gnunet_time_lib.h"
 #include "platform.h"
+#include "gnunet_time_lib.h"
 #include "gnunet_signatures.h"
 #include "gnunet_hello_uri_lib.h"
 #include "gnunet_protocols.h"
diff --git a/src/lib/util/crypto_elligator.c b/src/lib/util/crypto_elligator.c
index 554b77602..f17a65b2e 100644
--- a/src/lib/util/crypto_elligator.c
+++ b/src/lib/util/crypto_elligator.c
@@ -26,8 +26,8 @@
 
 */
 
-#include "gnunet_common.h"
 #include "platform.h"
+#include "gnunet_common.h"
 #include <gcrypt.h>
 #include <sodium.h>
 #include "gnunet_util_lib.h"
diff --git a/src/service/dht/gnunet-service-dht_neighbours.c 
b/src/service/dht/gnunet-service-dht_neighbours.c
index 230af5568..b54e6f20b 100644
--- a/src/service/dht/gnunet-service-dht_neighbours.c
+++ b/src/service/dht/gnunet-service-dht_neighbours.c
@@ -24,8 +24,8 @@
  * @author Christian Grothoff
  * @author Nathan Evans
  */
-#include "gnunet_common.h"
 #include "platform.h"
+#include "gnunet_common.h"
 #include "gnunet_constants.h"
 #include "gnunet_protocols.h"
 #include "gnunet_hello_uri_lib.h"

-- 
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]