[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 18/40: NEWS: The old hello design replaced by the new hello des
From: |
gnunet |
Subject: |
[gnunet] 18/40: NEWS: The old hello design replaced by the new hello design. |
Date: |
Thu, 05 Oct 2023 08:57:21 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit a362cd5a23ebb5c9650e577beb4f24edc55797cb
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Thu Aug 24 13:35:13 2023 +0200
NEWS: The old hello design replaced by the new hello design.
---
src/abd/abd_api.c | 1 -
src/cadet/Makefile.am | 2 +-
src/cadet/gnunet-service-cadet_hello.c | 52 +++++-----
src/cadet/gnunet-service-cadet_hello.h | 4 +-
src/cadet/gnunet-service-cadet_peer.c | 42 ++++++--
src/cadet/gnunet-service-cadet_peer.h | 4 +-
src/dht/dht_api.c | 1 -
src/dht/gnunet-service-dht.c | 1 -
src/dht/gnunet-service-dht_neighbours.c | 1 -
src/dht/plugin_block_dht.c | 99 ------------------
src/dhtu/Makefile.am | 2 +-
src/dhtu/plugin_dhtu_gnunet.c | 51 +++++++---
src/gns/gns_api.c | 1 -
src/gns/gns_tld_api.c | 1 -
src/hello/hello-uri.c | 88 +---------------
src/hostlist/Makefile.am | 2 +-
src/hostlist/gnunet-daemon-hostlist_client.c | 35 ++++---
src/hostlist/gnunet-daemon-hostlist_server.c | 147 ++++++++++++---------------
src/include/gnunet_hello_uri_lib.h | 14 +--
src/include/gnunet_peerstore_service.h | 4 +-
src/nse/nse_api.c | 1 -
src/peerstore/Makefile.am | 1 +
src/peerstore/peerstore_api.c | 47 +++++----
src/rps/Makefile.am | 3 +-
src/rps/gnunet-service-rps.c | 33 +++---
src/topology/gnunet-daemon-topology.c | 56 +++++++---
src/transport/gnunet-service-tng.c | 42 +++++++-
src/transport/plugin_transport_tcp.c | 2 +-
28 files changed, 330 insertions(+), 407 deletions(-)
diff --git a/src/abd/abd_api.c b/src/abd/abd_api.c
index 57f831e85..0b3b4f61f 100644
--- a/src/abd/abd_api.c
+++ b/src/abd/abd_api.c
@@ -26,7 +26,6 @@
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_arm_service.h"
-#include "gnunet_hello_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_signatures.h"
#include "abd.h"
diff --git a/src/cadet/Makefile.am b/src/cadet/Makefile.am
index 6cd4b812d..dec43b516 100644
--- a/src/cadet/Makefile.am
+++ b/src/cadet/Makefile.am
@@ -69,7 +69,7 @@ gnunet_service_cadet_LDADD = \
$(top_builddir)/src/dht/libgnunetdht.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/transport/libgnunettransportapplication.la \
- $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
+ $(top_builddir)/src/peerstore/libgnunetpeerstore.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/block/libgnunetblock.la
if LINUX
diff --git a/src/cadet/gnunet-service-cadet_hello.c
b/src/cadet/gnunet-service-cadet_hello.c
index e1850d60a..7a33b0e05 100644
--- a/src/cadet/gnunet-service-cadet_hello.c
+++ b/src/cadet/gnunet-service-cadet_hello.c
@@ -26,9 +26,8 @@
*/
#include "platform.h"
#include "gnunet_util_lib.h"
-
#include "gnunet_statistics_service.h"
-#include "gnunet_peerinfo_service.h"
+#include "gnunet_peerstore_service.h"
#include "cadet_protocol.h"
#include "gnunet-service-cadet.h"
#include "gnunet-service-cadet_dht.h"
@@ -40,17 +39,18 @@
/**
* Hello message of local peer.
*/
-static struct GNUNET_HELLO_Message *mine;
+static struct GNUNET_MessageHeader *mine;
/**
- * Handle to peerinfo service.
+ * Handle to the PEERSTORE service.
*/
-static struct GNUNET_PEERINFO_Handle *peerinfo;
+static struct GNUNET_PEERSTORE_Handle *peerstore;
/**
- * Iterator context.
+ * Our peerstore notification context. We use notification
+ * to instantly learn about new peers as they are discovered.
*/
-static struct GNUNET_PEERINFO_NotifyContext *nc;
+static struct GNUNET_PEERSTORE_NotifyContext *peerstore_notify;
/**
@@ -64,10 +64,11 @@ static struct GNUNET_PEERINFO_NotifyContext *nc;
static void
got_hello (void *cls,
const struct GNUNET_PeerIdentity *id,
- const struct GNUNET_HELLO_Message *hello,
+ const struct GNUNET_MessageHeader *hello,
const char *err_msg)
{
struct CadetPeer *peer;
+ struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (hello);
if ((NULL == id) ||
(NULL == hello))
@@ -76,21 +77,23 @@ got_hello (void *cls,
&my_full_id))
{
GNUNET_free (mine);
- mine = (struct GNUNET_HELLO_Message *) GNUNET_copy_message
(&hello->header);
+ mine = GNUNET_copy_message (hello);
GCD_hello_update ();
return;
}
-
+
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Hello for %s (%d bytes), expires on %s\n",
GNUNET_i2s (id),
- GNUNET_HELLO_size (hello),
+ sizeof (hello),
GNUNET_STRINGS_absolute_time_to_string (
- GNUNET_HELLO_get_last_expiration (hello)));
+
GNUNET_HELLO_builder_get_expiration_time (builder,
+
hello)));
peer = GCP_get (id,
GNUNET_YES);
GCP_set_hello (peer,
hello);
+ GNUNET_HELLO_builder_free (builder);
}
@@ -102,12 +105,11 @@ got_hello (void *cls,
void
GCH_init (const struct GNUNET_CONFIGURATION_Handle *c)
{
- GNUNET_assert (NULL == nc);
- peerinfo = GNUNET_PEERINFO_connect (c);
- nc = GNUNET_PEERINFO_notify (c,
- GNUNET_NO,
- &got_hello,
- NULL);
+ GNUNET_assert (NULL == peerstore_notify);
+ peerstore = GNUNET_PEERSTORE_connect (c);
+ peerstore_notify =
+ GNUNET_PEERSTORE_hello_changed_notify (peerstore, GNUNET_NO, &got_hello,
+ NULL);
}
@@ -117,15 +119,15 @@ GCH_init (const struct GNUNET_CONFIGURATION_Handle *c)
void
GCH_shutdown ()
{
- if (NULL != nc)
+ if (NULL != peerstore_notify)
{
- GNUNET_PEERINFO_notify_cancel (nc);
- nc = NULL;
+ GNUNET_PEERSTORE_hello_changed_notify_cancel (peerstore_notify);
+ peerstore_notify = NULL;
}
- if (NULL != peerinfo)
+ if (NULL != peerstore)
{
- GNUNET_PEERINFO_disconnect (peerinfo);
- peerinfo = NULL;
+ GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES);
+ peerstore = NULL;
}
if (NULL != mine)
{
@@ -140,7 +142,7 @@ GCH_shutdown ()
*
* @return Own hello message.
*/
-const struct GNUNET_HELLO_Message *
+const struct GNUNET_MessageHeader *
GCH_get_mine (void)
{
return mine;
diff --git a/src/cadet/gnunet-service-cadet_hello.h
b/src/cadet/gnunet-service-cadet_hello.h
index 2cb444b4a..88c955bb9 100644
--- a/src/cadet/gnunet-service-cadet_hello.h
+++ b/src/cadet/gnunet-service-cadet_hello.h
@@ -40,7 +40,7 @@ extern "C"
#include "platform.h"
#include "gnunet_util_lib.h"
-#include "gnunet_hello_lib.h"
+#include "gnunet_hello_uri_lib.h"
/**
@@ -64,7 +64,7 @@ GCH_shutdown (void);
*
* @return Own hello message.
*/
-const struct GNUNET_HELLO_Message *
+const struct GNUNET_MessageHeader *
GCH_get_mine (void);
diff --git a/src/cadet/gnunet-service-cadet_peer.c
b/src/cadet/gnunet-service-cadet_peer.c
index 6d6288e8d..c46e968dc 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -33,7 +33,7 @@
#include "platform.h"
#include "gnunet_time_lib.h"
#include "gnunet_util_lib.h"
-#include "gnunet_hello_lib.h"
+#include "gnunet_hello_uri_lib.h"
#include "gnunet_signatures.h"
#include "gnunet_transport_application_service.h"
#include "gnunet_ats_service.h"
@@ -186,7 +186,7 @@ struct CadetPeer
/**
* Hello message of the peer.
*/
- struct GNUNET_HELLO_Message *hello;
+ struct GNUNET_MessageHeader *hello;
/**
* Handle to us offering the HELLO to the transport.
@@ -491,12 +491,15 @@ consider_peer_destroy (struct CadetPeer *cp)
return; /* still relevant! */
if (NULL != cp->hello)
{
+ struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg
(cp->hello);
+
/* relevant only until HELLO expires */
- exp = GNUNET_TIME_absolute_get_remaining (GNUNET_HELLO_get_last_expiration
(
- cp->hello));
+ exp = GNUNET_TIME_absolute_get_remaining
(GNUNET_HELLO_builder_get_expiration_time (builder,
+
cp->hello));
cp->destroy_task = GNUNET_SCHEDULER_add_delayed (exp,
&destroy_peer,
cp);
+ GNUNET_HELLO_builder_free (builder);
return;
}
cp->destroy_task = GNUNET_SCHEDULER_add_delayed (IDLE_PEER_TIMEOUT,
@@ -1307,26 +1310,43 @@ GCP_get_tunnel (struct CadetPeer *cp,
void
GCP_set_hello (struct CadetPeer *cp,
- const struct GNUNET_HELLO_Message *hello)
+ const struct GNUNET_MessageHeader *hello)
{
struct GNUNET_HELLO_Message *mrg;
struct GNUNET_BANDWIDTH_Value32NBO bw;
+ uint16_t size = sizeof (hello);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Got %u byte HELLO for peer %s\n",
- (unsigned int) GNUNET_HELLO_size (hello),
+ (unsigned int) size,
GCP_2s (cp));
if (NULL != cp->hello)
{
- mrg = GNUNET_HELLO_merge (hello,
- cp->hello);
- GNUNET_free (cp->hello);
- cp->hello = mrg;
+ struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+ struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg
(hello);
+ struct GNUNET_HELLO_Builder *cp_builder = GNUNET_HELLO_builder_from_msg
(cp->hello);
+ struct GNUNET_TIME_Absolute new_hello_exp =
GNUNET_HELLO_builder_get_expiration_time (builder,
+
hello);
+ struct GNUNET_TIME_Absolute old_hello_exp =
GNUNET_HELLO_builder_get_expiration_time (cp_builder,
+
cp->hello);
+
+ if (GNUNET_TIME_absolute_cmp (new_hello_exp, > , now) &&
GNUNET_TIME_absolute_cmp (new_hello_exp, > , old_hello_exp))
+ {
+ GNUNET_free (cp->hello);
+ cp->hello = GNUNET_malloc (size);
+ GNUNET_memcpy (cp->hello, hello, size);
+ }
+ else
+ {
+ return;
+ }
+ GNUNET_HELLO_builder_free (builder);
+ GNUNET_HELLO_builder_free (cp_builder);
}
else
{
cp->hello = GNUNET_memdup (hello,
- GNUNET_HELLO_size (hello));
+ size);
}
if (NULL != cp->ash)
GNUNET_TRANSPORT_application_suggest_cancel (cp->ash);
diff --git a/src/cadet/gnunet-service-cadet_peer.h
b/src/cadet/gnunet-service-cadet_peer.h
index 69436d766..4c5ad4252 100644
--- a/src/cadet/gnunet-service-cadet_peer.h
+++ b/src/cadet/gnunet-service-cadet_peer.h
@@ -28,7 +28,7 @@
#define GNUNET_SERVICE_CADET_PEER_H
#include "gnunet-service-cadet.h"
-#include "gnunet_hello_lib.h"
+#include "gnunet_util_lib.h"
/**
@@ -292,7 +292,7 @@ GCP_remove_connection (struct CadetPeer *cp,
*/
void
GCP_set_hello (struct CadetPeer *cp,
- const struct GNUNET_HELLO_Message *hello);
+ const struct GNUNET_MessageHeader *hello);
/**
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c
index e31ac596c..62a8dd0fd 100644
--- a/src/dht/dht_api.c
+++ b/src/dht/dht_api.c
@@ -26,7 +26,6 @@
*/
#include "platform.h"
-#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_signatures.h"
#include "gnunet_arm_service.h"
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 0766bea62..c3ce2f284 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -27,7 +27,6 @@
#include "platform.h"
#include "gnunet_block_lib.h"
#include "gnunet_util_lib.h"
-#include "gnunet_hello_lib.h"
#include "gnunet_hello_uri_lib.h"
#include "gnunet_dht_service.h"
#include "gnunet_statistics_service.h"
diff --git a/src/dht/gnunet-service-dht_neighbours.c
b/src/dht/gnunet-service-dht_neighbours.c
index b0a71de95..e3a9bd3a1 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -28,7 +28,6 @@
#include "gnunet_constants.h"
#include "gnunet_protocols.h"
#include "gnunet_signatures.h"
-#include "gnunet_hello_lib.h"
#include "gnunet_hello_uri_lib.h"
#include "gnunet-service-dht.h"
#include "gnunet-service-dht_neighbours.h"
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c
index 6375fa272..aa5ffc719 100644
--- a/src/dht/plugin_block_dht.c
+++ b/src/dht/plugin_block_dht.c
@@ -27,7 +27,6 @@
*/
#include "platform.h"
#include "gnunet_constants.h"
-#include "gnunet_hello_lib.h"
#include "gnunet_hello_uri_lib.h"
#include "gnunet_block_plugin.h"
#include "gnunet_block_group_lib.h"
@@ -105,13 +104,6 @@ block_plugin_dht_check_query (void *cls,
{
switch (type)
{
- case GNUNET_BLOCK_TYPE_LEGACY_HELLO:
- if (0 != xquery_size)
- {
- GNUNET_break_op (0);
- return GNUNET_NO;
- }
- return GNUNET_OK;
case GNUNET_BLOCK_TYPE_DHT_HELLO:
if (0 != xquery_size)
{
@@ -143,33 +135,6 @@ block_plugin_dht_check_block (void *cls,
{
switch (type)
{
- case GNUNET_BLOCK_TYPE_LEGACY_HELLO:
- {
- const struct GNUNET_HELLO_Message *hello;
- struct GNUNET_PeerIdentity pid;
- const struct GNUNET_MessageHeader *msg;
-
- if (block_size < sizeof(struct GNUNET_MessageHeader))
- {
- GNUNET_break_op (0);
- return GNUNET_NO;
- }
- msg = block;
- if (block_size != ntohs (msg->size))
- {
- GNUNET_break_op (0);
- return GNUNET_NO;
- }
- hello = block;
- if (GNUNET_OK !=
- GNUNET_HELLO_get_id (hello,
- &pid))
- {
- GNUNET_break_op (0);
- return GNUNET_NO;
- }
- return GNUNET_OK;
- }
case GNUNET_BLOCK_TYPE_DHT_HELLO:
{
struct GNUNET_HELLO_Builder *b;
@@ -228,28 +193,6 @@ block_plugin_dht_check_reply (
{
switch (type)
{
- case GNUNET_BLOCK_TYPE_LEGACY_HELLO:
- {
- /* LEGACY */
- const struct GNUNET_MessageHeader *msg = reply_block;
- const struct GNUNET_HELLO_Message *hello = reply_block;
- struct GNUNET_PeerIdentity pid;
- struct GNUNET_HashCode phash;
-
- GNUNET_assert (reply_block_size >= sizeof(struct GNUNET_MessageHeader));
- GNUNET_assert (reply_block_size == ntohs (msg->size));
- GNUNET_assert (GNUNET_OK ==
- GNUNET_HELLO_get_id (hello,
- &pid));
- GNUNET_CRYPTO_hash (&pid,
- sizeof(pid),
- &phash);
- if (GNUNET_YES ==
- GNUNET_BLOCK_GROUP_bf_test_and_set (group,
- &phash))
- return GNUNET_BLOCK_REPLY_OK_DUPLICATE;
- return GNUNET_BLOCK_REPLY_OK_MORE;
- }
case GNUNET_BLOCK_TYPE_DHT_HELLO:
{
struct GNUNET_HELLO_Builder *b;
@@ -298,47 +241,6 @@ block_plugin_dht_get_key (void *cls,
{
switch (type)
{
- case GNUNET_BLOCK_TYPE_LEGACY_HELLO:
- {
- /* LEGACY */
- const struct GNUNET_MessageHeader *msg;
- const struct GNUNET_HELLO_Message *hello;
- struct GNUNET_PeerIdentity *pid;
-
- if (block_size < sizeof(struct GNUNET_MessageHeader))
- {
- GNUNET_break_op (0);
- memset (key,
- 0,
- sizeof (*key));
- return GNUNET_OK;
- }
- msg = block;
- if (block_size != ntohs (msg->size))
- {
- GNUNET_break_op (0);
- memset (key,
- 0,
- sizeof (*key));
- return GNUNET_OK;
- }
- hello = block;
- memset (key,
- 0,
- sizeof(*key));
- pid = (struct GNUNET_PeerIdentity *) key;
- if (GNUNET_OK !=
- GNUNET_HELLO_get_id (hello,
- pid))
- {
- GNUNET_break_op (0);
- memset (key,
- 0,
- sizeof (*key));
- return GNUNET_OK;
- }
- return GNUNET_OK;
- }
case GNUNET_BLOCK_TYPE_DHT_HELLO:
{
struct GNUNET_HELLO_Builder *b;
@@ -377,7 +279,6 @@ void *
libgnunet_plugin_block_dht_init (void *cls)
{
static enum GNUNET_BLOCK_Type types[] = {
- GNUNET_BLOCK_TYPE_LEGACY_HELLO,
GNUNET_BLOCK_TYPE_DHT_HELLO,
GNUNET_BLOCK_TYPE_ANY /* end of list */
};
diff --git a/src/dhtu/Makefile.am b/src/dhtu/Makefile.am
index f014b1505..2b0712dcf 100644
--- a/src/dhtu/Makefile.am
+++ b/src/dhtu/Makefile.am
@@ -35,7 +35,7 @@ libgnunet_plugin_dhtu_gnunet_la_SOURCES = \
libgnunet_plugin_dhtu_gnunet_la_LIBADD = \
$(top_builddir)/src/ats/libgnunetats.la \
$(top_builddir)/src/core/libgnunetcore.la \
- $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
+ $(top_builddir)/src/peerstore/libgnunetpeerstore.la \
$(top_builddir)/src/transport/libgnunettransportapplication.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/nse/libgnunetnse.la \
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c
index 6a79e70f3..665db4545 100644
--- a/src/dhtu/plugin_dhtu_gnunet.c
+++ b/src/dhtu/plugin_dhtu_gnunet.c
@@ -28,11 +28,10 @@
#include "gnunet_dhtu_plugin.h"
#include "gnunet_core_service.h"
#include "gnunet_transport_application_service.h"
-#include "gnunet_hello_lib.h"
-#include "gnunet_peerinfo_service.h"
+#include "gnunet_hello_uri_lib.h"
+#include "gnunet_peerstore_service.h"
#include "gnunet_nse_service.h"
-
/**
* Opaque handle that the underlay offers for our address to be used when
* sending messages to another peer.
@@ -138,6 +137,11 @@ struct Plugin
*/
struct GNUNET_DHTU_PluginEnvironment *env;
+ /**
+ * Handle to the PEERSTORE service.
+ */
+ struct GNUNET_PEERSTORE_Handle *peerstore;
+
/**
* Handle to the CORE service.
*/
@@ -154,15 +158,21 @@ struct Plugin
struct GNUNET_NSE_Handle *nse;
/**
- * Watching for our address to change.
+ * Our peerstore notification context. We use notification
+ * to instantly learn about new peers as they are discovered.
*/
- struct GNUNET_PEERINFO_NotifyContext *nc;
+ struct GNUNET_PEERSTORE_NotifyContext *peerstore_notify;
/**
* Identity of this peer.
*/
struct GNUNET_PeerIdentity my_identity;
+ /**
+ * Our private key.
+ */
+ struct GNUNET_CRYPTO_EddsaPrivateKey *my_priv;
+
};
@@ -361,10 +371,11 @@ core_disconnect_cb (void *cls,
static void
peerinfo_cb (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello,
- const char *err_msg)
+ const struct GNUNET_MessageHeader *hello,
+ const char *emsg)
{
struct Plugin *plugin = cls;
+ struct GNUNET_HELLO_Builder *builder;
char *addr;
if (NULL == hello)
@@ -375,8 +386,9 @@ peerinfo_cb (void *cls,
GNUNET_memcmp (peer,
&plugin->my_identity))
return;
- addr = GNUNET_HELLO_compose_uri (hello,
- &GPI_plugins_find);
+ builder = GNUNET_HELLO_builder_from_msg (hello);
+ addr = GNUNET_HELLO_builder_to_url (builder,
+ plugin->my_priv);
if (NULL == addr)
return;
plugin->env->address_add_cb (plugin->env->cls,
@@ -384,6 +396,7 @@ peerinfo_cb (void *cls,
&plugin->src,
&plugin->src.app_ctx);
GNUNET_free (addr);
+ GNUNET_HELLO_Builder_free (builder);
}
@@ -400,16 +413,17 @@ peerinfo_cb (void *cls,
* @param my_identity ID of this peer, NULL if we failed
*/
static void
-core_init_cb (void *cls,
+ core_init_cb (void *cls,
const struct GNUNET_PeerIdentity *my_identity)
{
struct Plugin *plugin = cls;
plugin->my_identity = *my_identity;
- plugin->nc = GNUNET_PEERINFO_notify (plugin->env->cfg,
- GNUNET_NO,
- &peerinfo_cb,
- plugin);
+ plugin->peerstore_notify =
+ GNUNET_PEERSTORE_hello_changed_notify (plugin->peerstore,
+ GNUNET_NO,
+ &peerinfo_cb,
+ plugin);
}
@@ -498,9 +512,12 @@ libgnunet_plugin_dhtu_gnunet_done (void *cls)
GNUNET_CORE_disconnect (plugin->core);
if (NULL != plugin->transport)
GNUNET_TRANSPORT_application_done (plugin->transport);
- if (NULL != plugin->nc)
- GNUNET_PEERINFO_notify_cancel (plugin->nc);
+ if (NULL != plugin->peerstore_notify)
+ GNUNET_PEERSTORE_hello_changed_notify_cancel (plugin->peerstore_notify);
+ if (NULL != plugin->peerstore)
+ GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES);
GPI_plugins_unload ();
+ GNUNET_free (plugin->my_priv);
GNUNET_free (plugin);
GNUNET_free (api);
return NULL;
@@ -527,6 +544,7 @@ libgnunet_plugin_dhtu_gnunet_init (void *cls)
GNUNET_MQ_handler_end ()
};
+ plugin->my_priv = GNUNET_CRYPTO_eddsa_key_create_from_configuration
(env->cfg);
plugin = GNUNET_new (struct Plugin);
plugin->env = env;
api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions);
@@ -535,6 +553,7 @@ libgnunet_plugin_dhtu_gnunet_init (void *cls)
api->hold = &gnunet_hold;
api->drop = &gnunet_drop;
api->send = &gnunet_send;
+ plugin->peerstore = GNUNET_PEERSTORE_connect (env->cfg);
plugin->transport = GNUNET_TRANSPORT_application_init (env->cfg);
plugin->core = GNUNET_CORE_connect (env->cfg,
plugin,
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c
index 9e25154ef..2e5ddc2b7 100644
--- a/src/gns/gns_api.c
+++ b/src/gns/gns_api.c
@@ -27,7 +27,6 @@
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_arm_service.h"
-#include "gnunet_hello_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_dht_service.h"
#include "gns.h"
diff --git a/src/gns/gns_tld_api.c b/src/gns/gns_tld_api.c
index c88ce776e..78a70f14e 100644
--- a/src/gns/gns_tld_api.c
+++ b/src/gns/gns_tld_api.c
@@ -28,7 +28,6 @@
#include "gnunet_constants.h"
#include "gnunet_arm_service.h"
#include "gnunet_identity_service.h"
-#include "gnunet_hello_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_dht_service.h"
#include "gns.h"
diff --git a/src/hello/hello-uri.c b/src/hello/hello-uri.c
index 9e8d6909d..fb35ee353 100644
--- a/src/hello/hello-uri.c
+++ b/src/hello/hello-uri.c
@@ -445,91 +445,13 @@ GNUNET_HELLO_builder_from_block (const void *block,
}
-static void
-merge_hellos2 (void *cls, const char *address_uri2)
-{
- struct AddressUriMergeResult *aumr = cls;
- const char *address_uri1 = aumr->address_uri;
-
- if (GNUNET_NO == aumr->found && 0 != GNUNET_memcmp (address_uri1,
- address_uri2))
- {
- aumr->found = GNUNET_YES;
- }
-}
-
-
-static void
-merge_hellos1 (void *cls, const char *address_uri1)
-{
- struct AddressUriMergeResult *aumr = cls;
- struct GNUNET_HELLO_Builder *builder2 = aumr->builder;
- struct GNUNET_PeerIdentity *peer2 = GNUNET_HELLO_builder_get_id (builder2);
-
- aumr->address_uri = address_uri1;
- GNUNET_HELLO_builder_iterate (builder2, peer2, &merge_hellos2, aumr);
- if (GNUNET_YES == aumr->found)
- {
- GNUNET_HELLO_builder_add_address (builder2, address_uri1);
- aumr->merged = GNUNET_YES;
- }
- aumr->found = GNUNET_NO;
-}
-
-
-struct GNUNET_MQ_Envelope *
-GNUNET_HELLO_builder_merge_hellos (const struct GNUNET_MessageHeader *msg1,
- const struct GNUNET_MessageHeader *msg2,
- const struct
- GNUNET_CRYPTO_EddsaPrivateKey *priv)
+struct GNUNET_TIME_Absolute
+GNUNET_HELLO_builder_get_expiration_time (struct GNUNET_HELLO_Builder *builder,
+ const struct GNUNET_MessageHeader
*msg)
{
- struct HelloUriMessage *hum1 = (struct HelloUriMessage *) msg1;
- struct BlockHeader *bh1 = (struct BlockHeader *) &msg1[1];
- struct GNUNET_TIME_Absolute expiration_time1 = GNUNET_TIME_absolute_ntoh (
- bh1->expiration_time);
- struct HelloUriMessage *hum2 = (struct HelloUriMessage *) msg2;
- struct BlockHeader *bh2 = (struct BlockHeader *) &msg2[1];
- struct GNUNET_TIME_Absolute expiration_time2 = GNUNET_TIME_absolute_ntoh (
- bh1->expiration_time);
- struct GNUNET_HELLO_Builder *builder1 = GNUNET_HELLO_builder_from_msg (msg1);
- struct GNUNET_HELLO_Builder *builder2 = GNUNET_HELLO_builder_from_msg (msg2);
- struct AddressUriMergeResult *aumr = GNUNET_new (struct
- AddressUriMergeResult);
- struct GNUNET_PeerIdentity *peer1 = GNUNET_HELLO_builder_get_id (builder1);
- struct GNUNET_MQ_Envelope *env;
- struct GNUNET_TIME_Absolute expiration_time;
-
- aumr->builder = builder2;
- GNUNET_HELLO_builder_iterate (builder1, peer1, &merge_hellos1, aumr);
+ struct BlockHeader *bh = (struct BlockHeader *) &msg[1];
- if (GNUNET_YES == aumr->merged)
- {
- if (expiration_time1.abs_value_us < expiration_time2.abs_value_us)
- expiration_time = expiration_time1;
- else
- expiration_time = expiration_time2;
- env = GNUNET_HELLO_builder_to_env (builder2,
- priv,
- GNUNET_TIME_absolute_get_remaining (
- expiration_time));
- }
- else if (expiration_time1.abs_value_us != expiration_time2.abs_value_us)
- {
- if (expiration_time1.abs_value_us < expiration_time2.abs_value_us)
- expiration_time = expiration_time2;
- else
- expiration_time = expiration_time1;
- env = GNUNET_HELLO_builder_to_env (builder2,
- priv,
- GNUNET_TIME_absolute_get_remaining (
- expiration_time));
- }
-
- GNUNET_HELLO_builder_free (builder1);
- GNUNET_HELLO_builder_free (builder2);
- GNUNET_free (aumr);
-
- return env;
+ return GNUNET_TIME_absolute_ntoh (bh->expiration_time);
}
diff --git a/src/hostlist/Makefile.am b/src/hostlist/Makefile.am
index 77c9eb1de..c58147dce 100644
--- a/src/hostlist/Makefile.am
+++ b/src/hostlist/Makefile.am
@@ -28,7 +28,7 @@ gnunet_daemon_hostlist_SOURCES = \
gnunet_daemon_hostlist_LDADD = \
$(top_builddir)/src/core/libgnunetcore.la \
$(top_builddir)/src/hello/libgnunethello.la \
- $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
+ $(top_builddir)/src/peerstore/libgnunetpeerstore.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/transport/libgnunettransport.la \
$(top_builddir)/src/util/libgnunetutil.la \
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c
b/src/hostlist/gnunet-daemon-hostlist_client.c
index 2caf61a1b..2932df07c 100644
--- a/src/hostlist/gnunet-daemon-hostlist_client.c
+++ b/src/hostlist/gnunet-daemon-hostlist_client.c
@@ -25,9 +25,9 @@
*/
#include "platform.h"
#include "gnunet-daemon-hostlist_client.h"
-#include "gnunet_hello_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
-#include "gnunet_peerinfo_service.h"
+#include "gnunet_peerstore_service.h"
#include "gnunet-daemon-hostlist.h"
/* Just included for the right curl.h */
#include "gnunet_curl_lib.h"
@@ -305,9 +305,16 @@ static unsigned int stat_hellos_obtained;
static unsigned int stat_connection_count;
/**
- * Handle to peerinfo service.
+ * Handle to the PEERSTORE service.
*/
-static struct GNUNET_PEERINFO_Handle *pi;
+static struct GNUNET_PEERSTORE_Handle *peerstore;
+
+
+static void
+shc_cont (void *cls, int success)
+{
+ GNUNET_free (cls);
+}
/**
@@ -323,6 +330,7 @@ static size_t
callback_download (void *ptr, size_t size, size_t nmemb, void *ctx)
{
static char download_buffer[GNUNET_MAX_MESSAGE_SIZE - 1];
+ struct GNUNET_PEERSTORE_StoreHelloContext *shc;
const char *cbuf = ptr;
const struct GNUNET_MessageHeader *msg;
size_t total;
@@ -377,7 +385,7 @@ callback_download (void *ptr, size_t size, size_t nmemb,
void *ctx)
GNUNET_assert (left == 0);
break;
}
- if (GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message *) msg) == msize)
+ if (sizeof (msg) == msize)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received valid `%s' message from hostlist server.\n",
@@ -388,11 +396,10 @@ callback_download (void *ptr, size_t size, size_t nmemb,
void *ctx)
1,
GNUNET_NO);
stat_hellos_obtained++;
- (void)
- GNUNET_PEERINFO_add_peer (pi,
- (const struct GNUNET_HELLO_Message *) msg,
- NULL,
- NULL);
+ shc = GNUNET_PEERSTORE_hello_add (peerstore,
+ msg,
+ shc_cont,
+ shc);
}
else
{
@@ -1592,7 +1599,7 @@ GNUNET_HOSTLIST_client_start (const struct
GNUNET_CONFIGURATION_Handle *c,
stats = st;
/* Read proxy configuration */
- pi = GNUNET_PEERINFO_connect (c);
+ peerstore = GNUNET_PEERSTORE_connect (c);
if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", "PROXY", &proxy))
{
@@ -1788,10 +1795,10 @@ GNUNET_HOSTLIST_client_stop ()
proxy_username = NULL;
GNUNET_free (proxy_password);
proxy_password = NULL;
- if (NULL != pi)
+ if (NULL != peerstore)
{
- GNUNET_PEERINFO_disconnect (pi);
- pi = NULL;
+ GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES);
+ peerstore = NULL;
}
cfg = NULL;
}
diff --git a/src/hostlist/gnunet-daemon-hostlist_server.c
b/src/hostlist/gnunet-daemon-hostlist_server.c
index 46b18b266..4c276ce80 100644
--- a/src/hostlist/gnunet-daemon-hostlist_server.c
+++ b/src/hostlist/gnunet-daemon-hostlist_server.c
@@ -28,8 +28,8 @@
#include "platform.h"
#include <microhttpd.h>
#include "gnunet-daemon-hostlist_server.h"
-#include "gnunet_hello_lib.h"
-#include "gnunet_peerinfo_service.h"
+#include "gnunet_hello_uri_lib.h"
+#include "gnunet_peerstore_service.h"
#include "gnunet-daemon-hostlist.h"
#include "gnunet_resolver_service.h"
#include "gnunet_mhd_compat.h"
@@ -69,9 +69,10 @@ static struct GNUNET_STATISTICS_Handle *stats;
static struct GNUNET_CORE_Handle *core;
/**
- * Handle to the peerinfo notify service (NULL until we've connected to it).
+ * Our peerstore notification context. We use notification
+ * to instantly learn about new peers as they are discovered.
*/
-static struct GNUNET_PEERINFO_NotifyContext *notify;
+static struct GNUNET_PEERSTORE_NotifyContext *peerstore_notify;
/**
* Our primary task for IPv4.
@@ -89,9 +90,9 @@ static struct GNUNET_SCHEDULER_Task *hostlist_task_v6;
static struct MHD_Response *response;
/**
- * Handle for accessing peerinfo service.
+ * Handle to the PEERSTORE service.
*/
-static struct GNUNET_PEERINFO_Handle *peerinfo;
+static struct GNUNET_PEERSTORE_Handle *peerstore;
/**
* Set if we are allowed to advertise our hostlist to others.
@@ -112,7 +113,7 @@ struct HostSet
/**
* Iterator used to build @e data (NULL when done).
*/
- struct GNUNET_PEERINFO_IteratorContext *pitr;
+ struct GNUNET_PEERSTORE_IterateContext *pitr;
/**
* Place where we accumulate all of the HELLO messages.
@@ -178,34 +179,6 @@ finish_response ()
}
-/**
- * Set @a cls to #GNUNET_YES (we have an address!).
- *
- * @param cls closure, an `int *`
- * @param address the address (ignored)
- * @param expiration expiration time (call is ignored if this is in the past)
- * @return #GNUNET_SYSERR to stop iterating (unless expiration has occurred)
- */
-static int
-check_has_addr (void *cls,
- const struct GNUNET_HELLO_Address *address,
- struct GNUNET_TIME_Absolute expiration)
-{
- int *arg = cls;
-
- if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us)
- {
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("expired addresses encountered"),
- 1,
- GNUNET_YES);
- return GNUNET_YES; /* ignore this address */
- }
- *arg = GNUNET_YES;
- return GNUNET_SYSERR;
-}
-
-
/**
* Callback that processes each of the known HELLOs for the
* hostlist response construction.
@@ -217,55 +190,65 @@ check_has_addr (void *cls,
*/
static void
host_processor (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello,
- const char *err_msg)
+ const struct GNUNET_PEERSTORE_Record *record,
+ const char *emsg)
{
size_t old;
size_t s;
- int has_addr;
-
- if (NULL != err_msg)
- {
- GNUNET_assert (NULL == peer);
+ struct GNUNET_HELLO_Builder *hello_builder;
+ struct GNUNET_MessageHeader *hello;
+ 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 PEERINFO service: %s\n"),
- err_msg);
+ _ ("Error in communication with PEERSTORE service: %s\n"),
+ emsg);
return;
}
- if (NULL == peer)
+ if (NULL == record)
{
builder->pitr = NULL;
finish_response ();
return;
}
- if (NULL == hello)
- return;
- has_addr = GNUNET_NO;
- GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &check_has_addr,
&has_addr);
- if (GNUNET_NO == has_addr)
+ else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "HELLO for peer `%4s' has no address, not suitable for
hostlist!\n",
- GNUNET_i2s (peer));
- GNUNET_STATISTICS_update (stats,
- gettext_noop (
- "HELLOs without addresses encountered
(ignored)"),
- 1,
- GNUNET_NO);
- return;
+ hello = record->value;
+ if ((0 == record->value_size))
+ {
+ GNUNET_break (0);
+ return;
+ }
+ hello_builder = GNUNET_HELLO_builder_new (&record->peer);
+ hello_exp = GNUNET_HELLO_builder_get_expiration_time (hello_builder,
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);
+ GNUNET_HELLO_builder_free (hello_builder);
+ return;
+ }
}
old = builder->size;
- s = GNUNET_HELLO_size (hello);
+ s = sizeof (hello);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received %u bytes of `%s' from peer `%s' for hostlist.\n",
(unsigned int) s,
"HELLO",
- GNUNET_i2s (peer));
+ GNUNET_i2s (&record->peer));
if ((old + s >= GNUNET_MAX_MALLOC_CHECKED) ||
(old + s >= MAX_BYTES_PER_HOSTLISTS))
{
@@ -275,14 +258,16 @@ host_processor (void *cls,
"bytes not included in hostlist (size limit)"),
s,
GNUNET_NO);
+ GNUNET_HELLO_builder_free (hello_builder);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Adding peer `%s' to hostlist (%u bytes)\n",
- GNUNET_i2s (peer),
+ GNUNET_i2s (&record->peer),
(unsigned int) s);
GNUNET_array_grow (builder->data, builder->size, old + s);
GNUNET_memcpy (&builder->data[old], hello, s);
+ GNUNET_HELLO_builder_free (hello_builder);
}
@@ -506,7 +491,7 @@ connect_handler (void *cls,
/**
- * PEERINFO calls this function to let us know about a possible peer
+ * PEERSTORE calls this function to let us know about a possible peer
* that we might want to connect to.
*
* @param cls closure (not used)
@@ -517,21 +502,21 @@ connect_handler (void *cls,
static void
process_notify (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello,
+ const struct GNUNET_MessageHeader *hello,
const char *err_msg)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peerinfo is notifying us to rebuild our hostlist\n");
+ "Peerstore is notifying us to rebuild our hostlist\n");
if (NULL != err_msg)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _ ("Error in communication with PEERINFO service: %s\n"),
+ _ ("Error in communication with PEERSTORE service: %s\n"),
err_msg);
if (NULL != builder)
{
/* restart re-build already in progress ... */
if (NULL != builder->pitr)
{
- GNUNET_PEERINFO_iterate_cancel (builder->pitr);
+ GNUNET_PEERSTORE_iterate_cancel (builder->pitr);
builder->pitr = NULL;
}
GNUNET_free (builder->data);
@@ -542,9 +527,9 @@ process_notify (void *cls,
{
builder = GNUNET_new (struct HostSet);
}
- GNUNET_assert (NULL != peerinfo);
+ GNUNET_assert (NULL != peerstore);
builder->pitr =
- GNUNET_PEERINFO_iterate (peerinfo, GNUNET_NO, NULL, &host_processor, NULL);
+ GNUNET_PEERSTORE_iterate (peerstore, "hostlist", NULL,
GNUNET_PEERSTORE_HELLO_KEY, &host_processor, NULL);
}
@@ -667,11 +652,11 @@ GNUNET_HOSTLIST_server_start (const struct
GNUNET_CONFIGURATION_Handle *c,
}
cfg = c;
stats = st;
- peerinfo = GNUNET_PEERINFO_connect (cfg);
- if (NULL == peerinfo)
+ peerstore = GNUNET_PEERSTORE_connect (cfg);
+ if (NULL == peerstore)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Could not access PEERINFO service. Exiting.\n"));
+ _ ("Could not access PEERSTORE service. Exiting.\n"));
return GNUNET_SYSERR;
}
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg,
@@ -837,7 +822,7 @@ 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);
- notify = GNUNET_PEERINFO_notify (cfg, GNUNET_NO, &process_notify, NULL);
+ peerstore_notify = GNUNET_PEERSTORE_hello_changed_notify (peerstore,
GNUNET_NO, &process_notify, NULL);
return GNUNET_OK;
}
@@ -874,26 +859,26 @@ GNUNET_HOSTLIST_server_stop ()
MHD_destroy_response (response);
response = NULL;
}
- if (NULL != notify)
+ if (NULL != peerstore_notify)
{
- GNUNET_PEERINFO_notify_cancel (notify);
- notify = NULL;
+ GNUNET_PEERSTORE_hello_changed_notify_cancel (peerstore_notify);
+ peerstore_notify = NULL;
}
if (NULL != builder)
{
if (NULL != builder->pitr)
{
- GNUNET_PEERINFO_iterate_cancel (builder->pitr);
+ GNUNET_PEERSTORE_iterate_cancel (builder->pitr);
builder->pitr = NULL;
}
GNUNET_free (builder->data);
GNUNET_free (builder);
builder = NULL;
}
- if (NULL != peerinfo)
+ if (NULL != peerstore)
{
- GNUNET_PEERINFO_disconnect (peerinfo);
- peerinfo = NULL;
+ GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES);
+ peerstore = NULL;
}
cfg = NULL;
stats = NULL;
diff --git a/src/include/gnunet_hello_uri_lib.h
b/src/include/gnunet_hello_uri_lib.h
index 3aa07d760..ec84f35b0 100644
--- a/src/include/gnunet_hello_uri_lib.h
+++ b/src/include/gnunet_hello_uri_lib.h
@@ -118,13 +118,15 @@ GNUNET_HELLO_builder_from_url (const char *url);
/**
- * Merge to hello uris.
+ * Get the expiration time for this HELLO.
+ *
+ * @param builder builder to serialize
+ * @param msg The hello msg.
+ * @return The expiration time.
*/
-struct GNUNET_MQ_Envelope *
-GNUNET_HELLO_builder_merge_hellos (const struct GNUNET_MessageHeader *msg1,
- const struct GNUNET_MessageHeader *msg2,
- const struct
- GNUNET_CRYPTO_EddsaPrivateKey *priv);
+struct GNUNET_TIME_Absolute
+GNUNET_HELLO_builder_get_expiration_time (struct GNUNET_HELLO_Builder *builder,
+ const struct GNUNET_MessageHeader
*msg);
/**
diff --git a/src/include/gnunet_peerstore_service.h
b/src/include/gnunet_peerstore_service.h
index 6196d8202..1cb60cb04 100644
--- a/src/include/gnunet_peerstore_service.h
+++ b/src/include/gnunet_peerstore_service.h
@@ -246,7 +246,6 @@ GNUNET_PEERSTORE_hello_changed_notify_cancel (struct
struct GNUNET_PEERSTORE_StoreHelloContext *
GNUNET_PEERSTORE_hello_add (struct GNUNET_PEERSTORE_Handle *h,
const struct GNUNET_MessageHeader *msg,
- const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
GNUNET_PEERSTORE_Continuation cont,
void *cont_cls);
@@ -352,7 +351,8 @@ GNUNET_PEERSTORE_iterate_cancel (struct
GNUNET_PEERSTORE_IterateContext *ic);
/**
* Request watching a given key
- * User will be notified with any new values added to key.
+ * User will be notified with any new values added to key,
+ * all existing entries are supplied beforehand.
*
* @param h handle to the PEERSTORE service
* @param sub_system name of sub system
diff --git a/src/nse/nse_api.c b/src/nse/nse_api.c
index 23daa7f12..7f3e03b98 100644
--- a/src/nse/nse_api.c
+++ b/src/nse/nse_api.c
@@ -26,7 +26,6 @@
#include "platform.h"
#include "gnunet_constants.h"
#include "gnunet_arm_service.h"
-#include "gnunet_hello_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_util_lib.h"
#include "gnunet_nse_service.h"
diff --git a/src/peerstore/Makefile.am b/src/peerstore/Makefile.am
index b73bd2477..7220492f2 100644
--- a/src/peerstore/Makefile.am
+++ b/src/peerstore/Makefile.am
@@ -38,6 +38,7 @@ gnunet_service_peerstore_SOURCES = \
gnunet_service_peerstore_CFLAGS = $(AM_CFLAGS)
gnunet_service_peerstore_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
$(GN_LIBINTL)
libgnunetpeerstore_la_SOURCES = \
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c
index 1bac046f2..246bd24b4 100644
--- a/src/peerstore/peerstore_api.c
+++ b/src/peerstore/peerstore_api.c
@@ -357,11 +357,6 @@ struct GNUNET_PEERSTORE_StoreHelloContext
*/
const struct GNUNET_MessageHeader *hello;
- /**
- * Key to sign merged hello.
- */
- const struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
-
/**
* Was this request successful.
*/
@@ -1296,9 +1291,12 @@ store_hello (struct GNUNET_PEERSTORE_StoreHelloContext
*huc,
struct GNUNET_PeerIdentity *pid;
struct GNUNET_PEERSTORE_StoreContext *sc;
struct StoreHelloCls *shu_cls = GNUNET_new (struct StoreHelloCls);
+ struct GNUNET_TIME_Absolute hello_exp;
shu_cls->huc = huc;
builder = GNUNET_HELLO_builder_from_msg (hello);
+ hello_exp = GNUNET_HELLO_builder_get_expiration_time (builder,
+ hello);
pid = GNUNET_HELLO_builder_get_id (builder);
sc = GNUNET_PEERSTORE_store (h,
"peerstore",
@@ -1306,7 +1304,7 @@ store_hello (struct GNUNET_PEERSTORE_StoreHelloContext
*huc,
GNUNET_PEERSTORE_HELLO_KEY,
hello,
sizeof(hello),
- GNUNET_TIME_UNIT_FOREVER_ABS,
+ hello_exp,
GNUNET_PEERSTORE_STOREOPTION_REPLACE,
merge_success,
shu_cls);
@@ -1325,8 +1323,8 @@ merge_uri (void *cls,
struct GNUNET_PEERSTORE_Handle *h = huc->h;
struct GNUNET_PEERSTORE_WatchContext *wc;
struct GNUNET_MessageHeader *hello;
- const struct GNUNET_MessageHeader *merged_hello;
- struct GNUNET_MQ_Envelope *env;
+ struct GNUNET_TIME_Absolute huc_hello_exp_time;
+ struct GNUNET_TIME_Absolute record_hello_exp_time;
const char *val;
if (NULL != emsg)
@@ -1352,20 +1350,28 @@ merge_uri (void *cls,
if (NULL != record)
{
+ struct GNUNET_HELLO_Builder *builder;
+ struct GNUNET_HELLO_Builder *huc_builder;
+
hello = record->value;
- if ((0 == record->value_size) || ('\0' != val[record->value_size - 1]))
+ builder = GNUNET_HELLO_builder_from_msg (hello);
+ huc_builder = GNUNET_HELLO_builder_from_msg (huc->hello);
+ if ((0 == record->value_size))
{
GNUNET_break (0);
return;
}
- env = GNUNET_HELLO_builder_merge_hellos (huc->hello, hello, huc->priv);
- merged_hello = GNUNET_MQ_env_get_msg (env);
- if (NULL != merged_hello)
- store_hello (huc, merged_hello);
+ huc_hello_exp_time = GNUNET_HELLO_builder_get_expiration_time (huc_builder,
+ huc->hello);
+ record_hello_exp_time = GNUNET_HELLO_builder_get_expiration_time (builder,
+ hello);
- GNUNET_free (env);
+ if (GNUNET_TIME_absolute_cmp (huc_hello_exp_time, >,
record_hello_exp_time))
+ store_hello (huc, huc->hello);
+ GNUNET_HELLO_builder_free (builder);
+ GNUNET_HELLO_builder_free (huc_builder);
}
else
{
@@ -1377,23 +1383,26 @@ merge_uri (void *cls,
struct GNUNET_PEERSTORE_StoreHelloContext *
GNUNET_PEERSTORE_hello_add (struct GNUNET_PEERSTORE_Handle *h,
const struct GNUNET_MessageHeader *msg,
- const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
GNUNET_PEERSTORE_Continuation cont,
void *cont_cls)
{
- struct GNUNET_HELLO_Builder *builder;
+ struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (msg);
struct GNUNET_PEERSTORE_StoreHelloContext *huc;
struct GNUNET_PEERSTORE_IterateContext *ic;
struct GNUNET_PeerIdentity *pid;
+ struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+ struct GNUNET_TIME_Absolute hello_exp =
+ GNUNET_HELLO_builder_get_expiration_time (builder,
+ msg);
+
+ if (GNUNET_TIME_absolute_cmp (hello_exp, <, now))
+ return NULL;
huc = GNUNET_new (struct GNUNET_PEERSTORE_StoreHelloContext);
huc->h = h;
huc->cont = cont;
huc->cont_cls = cont_cls;
huc->hello = msg;
- huc->priv = priv;
-
- builder = GNUNET_HELLO_builder_from_msg (msg);
pid = GNUNET_HELLO_builder_get_id (builder);
ic = GNUNET_PEERSTORE_iterate (h,
"peerstore",
diff --git a/src/rps/Makefile.am b/src/rps/Makefile.am
index 3d6214cd0..8f7c104f9 100644
--- a/src/rps/Makefile.am
+++ b/src/rps/Makefile.am
@@ -61,9 +61,8 @@ gnunet_service_rps_SOURCES = \
gnunet_service_rps_LDADD = \
libgnunetrps.la \
$(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
+ $(top_builddir)/src/peerstore/libgnunetpeerstore.la \
$(top_builddir)/src/cadet/libgnunetcadet.la \
- $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
$(top_builddir)/src/nse/libgnunetnse.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/core/libgnunetcore.la \
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index fc11591a0..76e33c87b 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -28,7 +28,7 @@
#include "gnunet_util_lib.h"
#include "gnunet_cadet_service.h"
#include "gnunet_core_service.h"
-#include "gnunet_peerinfo_service.h"
+#include "gnunet_peerstore_service.h"
#include "gnunet_nse_service.h"
#include "gnunet_statistics_service.h"
#include "rps.h"
@@ -499,14 +499,15 @@ static float beta;
static struct GNUNET_NSE_Handle *nse;
/**
- * Handler to PEERINFO.
+ * Handle to the PEERSTORE service.
*/
-static struct GNUNET_PEERINFO_Handle *peerinfo_handle;
+static struct GNUNET_PEERSTORE_Handle *peerstore;
/**
- * Handle for cancellation of iteration over peers.
+ * Our peerstore notification context. We use notification
+ * to instantly learn about new peers as they are discovered.
*/
-static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify_handle;
+static struct GNUNET_PEERSTORE_NotifyContext *peerstore_notify;
#if ENABLE_MALICIOUS
@@ -4697,13 +4698,13 @@ valid_peers_iterator (void *cls,
void
process_peerinfo_peers (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello,
- const char *err_msg)
+ const struct GNUNET_MessageHeader *hello,
+ const char *emsg)
{
struct Sub *sub = cls;
(void) hello;
- (void) err_msg;
+ (void) emsg;
if (NULL != peer)
{
@@ -4743,9 +4744,9 @@ shutdown_task (void *cls)
}
/* Disconnect from other services */
- GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle);
- GNUNET_PEERINFO_disconnect (peerinfo_handle);
- peerinfo_handle = NULL;
+ GNUNET_PEERSTORE_hello_changed_notify_cancel (peerstore_notify);
+ GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES);
+ peerstore = NULL;
GNUNET_NSE_disconnect (nse);
if (NULL != map_single_hop)
{
@@ -4935,7 +4936,7 @@ run (void *cls,
round_interval);
- peerinfo_handle = GNUNET_PEERINFO_connect (cfg);
+ peerstore = GNUNET_PEERSTORE_connect (cfg);
/* connect to NSE */
nse = GNUNET_NSE_connect (cfg, nse_callback, NULL);
@@ -4947,10 +4948,10 @@ run (void *cls,
restore_valid_peers (msub);
get_valid_peers (msub->valid_peers, valid_peers_iterator, msub);
- peerinfo_notify_handle = GNUNET_PEERINFO_notify (cfg,
- GNUNET_NO,
- process_peerinfo_peers,
- msub);
+ peerstore_notify = GNUNET_PEERSTORE_hello_changed_notify (peerstore,
+ GNUNET_NO,
+
process_peerinfo_peers,
+ msub);
LOG (GNUNET_ERROR_TYPE_INFO, "Ready to receive requests from clients\n");
diff --git a/src/topology/gnunet-daemon-topology.c
b/src/topology/gnunet-daemon-topology.c
index 8b2278897..b28269a77 100644
--- a/src/topology/gnunet-daemon-topology.c
+++ b/src/topology/gnunet-daemon-topology.c
@@ -324,7 +324,7 @@ attempt_connect (struct Peer *pos)
gettext_noop ("# connect requests issued to
ATS"),
1,
GNUNET_NO);
- //TODO Use strength somehow.
+ // TODO Use strength somehow.
pos->ash = GNUNET_TRANSPORT_application_suggest (transport,
&pos->pid,
GNUNET_MQ_PRIO_BEST_EFFORT,
@@ -438,11 +438,11 @@ find_advertisable_hello (void *cls,
"find_advertisable_hello\n");
if (pos == fah->peer)
return GNUNET_YES;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"find_advertisable_hello 2\n");
if (pos->hello == NULL)
return GNUNET_YES;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"find_advertisable_hello 3\n");
rst_time = GNUNET_TIME_absolute_get_remaining (pos->filter_expiration);
if (0 == rst_time.rel_value_us)
@@ -455,7 +455,7 @@ find_advertisable_hello (void *cls,
hs = pos->hello->size;
if (hs > fah->max_size)
return GNUNET_YES;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"find_advertisable_hello 4\n");
GNUNET_CRYPTO_hash (&fah->peer->pid,
sizeof(struct GNUNET_PeerIdentity),
@@ -482,7 +482,7 @@ schedule_next_hello (void *cls)
struct GNUNET_TIME_Relative delay;
struct GNUNET_HashCode hc;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"schedule_next_hello\n");
pl->hello_delay_task = NULL;
GNUNET_assert (NULL != pl->mq);
@@ -752,14 +752,26 @@ consider_for_advertising (const struct
GNUNET_MessageHeader *hello)
if (NULL != peer->hello)
{
-
- env = GNUNET_HELLO_builder_merge_hellos (hello, peer->hello,
my_private_key);
- nh = GNUNET_MQ_env_get_msg (env);
- if (NULL == nh)
+ struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+ struct GNUNET_TIME_Absolute new_hello_exp =
GNUNET_HELLO_builder_get_expiration_time (builder,
+
hello);
+ struct GNUNET_HELLO_Builder *peer_builder = GNUNET_HELLO_builder_from_msg
(peer->hello);
+ struct GNUNET_TIME_Absolute old_hello_exp =
GNUNET_HELLO_builder_get_expiration_time (peer_builder,
+
peer->hello);
+
+ if (GNUNET_TIME_absolute_cmp (new_hello_exp, > , now) &&
GNUNET_TIME_absolute_cmp (new_hello_exp, > , old_hello_exp))
+ {
+ GNUNET_free (peer->hello);
+ size = sizeof (hello);
+ peer->hello = GNUNET_malloc (size);
+ GNUNET_memcpy (peer->hello, hello, size);
+ }
+ else
+ {
return;
- GNUNET_free (peer->hello);
- GNUNET_memcpy (peer->hello, nh, sizeof (nh));
- GNUNET_free (env);
+ }
+ GNUNET_HELLO_builder_free (builder);
+ GNUNET_HELLO_builder_free (peer_builder);
}
else
{
@@ -806,7 +818,8 @@ process_peer (void *cls,
err_msg);
GNUNET_PEERSTORE_hello_changed_notify_cancel (peerstore_notify);
peerstore_notify =
- GNUNET_PEERSTORE_hello_changed_notify (ps, GNUNET_NO, &process_peer,
NULL);
+ GNUNET_PEERSTORE_hello_changed_notify (ps, GNUNET_NO, &process_peer,
+ NULL);
return;
}
GNUNET_assert (NULL != peer);
@@ -939,7 +952,8 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle
*cfg)
static int
check_hello (void *cls, const struct GNUNET_MessageHeader *message)
{
- struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg
(message);
+ struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (
+ message);
struct GNUNET_PeerIdentity *pid = GNUNET_HELLO_builder_get_id (builder);
if (NULL == pid)
@@ -951,6 +965,13 @@ check_hello (void *cls, const struct GNUNET_MessageHeader
*message)
}
+static void
+shc_cont (void *cls, int success)
+{
+ GNUNET_free (cls);
+}
+
+
/**
* This function is called whenever an encrypted HELLO message is
* received.
@@ -961,9 +982,11 @@ check_hello (void *cls, const struct GNUNET_MessageHeader
*message)
static void
handle_hello (void *cls, const struct GNUNET_MessageHeader *message)
{
+ struct GNUNET_PEERSTORE_StoreHelloContext *shc;
const struct GNUNET_PeerIdentity *other = cls;
struct Peer *peer;
- struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg
(message);
+ struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (
+ message);
struct GNUNET_PeerIdentity *pid = GNUNET_HELLO_builder_get_id (builder);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -987,7 +1010,8 @@ handle_hello (void *cls, const struct GNUNET_MessageHeader
*message)
(friend_count < minimum_friend_count))
return;
}
- (void) GNUNET_PEERSTORE_hello_add (ps, message, my_private_key, NULL, NULL);
+ GNUNET_HELLO_builder_from_msg (message);
+ shc = GNUNET_PEERSTORE_hello_add (ps, message, &shc_cont, shc);
GNUNET_HELLO_builder_free (builder);
}
diff --git a/src/transport/gnunet-service-tng.c
b/src/transport/gnunet-service-tng.c
index b6039a2ae..5f2504c70 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -78,6 +78,7 @@
#include "gnunet_transport_monitor_service.h"
#include "gnunet_peerstore_service.h"
#include "gnunet_hello_lib.h"
+#include "gnunet_hello_uri_lib.h"
#include "gnunet_signatures.h"
#include "transport.h"
@@ -2765,6 +2766,11 @@ static const struct GNUNET_CONFIGURATION_Handle *GST_cfg;
*/
static struct GNUNET_PeerIdentity GST_my_identity;
+/**
+ * Our HELLO
+ */
+struct GNUNET_HELLO_Builder *GST_my_hello;
+
/**
* Our private key.
*/
@@ -5517,6 +5523,13 @@ peerstore_store_own_cb (void *cls, int success)
}
+static void
+shc_cont (void *cls, int success)
+{
+ GNUNET_free (cls);
+}
+
+
/**
* Ask peerstore to store our address.
*
@@ -5526,9 +5539,13 @@ static void
store_pi (void *cls)
{
struct AddressListEntry *ale = cls;
+ struct GNUNET_PEERSTORE_StoreHelloContext *shc;
void *addr;
size_t addr_len;
struct GNUNET_TIME_Absolute expiration;
+ enum GNUNET_GenericReturnValue add_result;
+ struct GNUNET_MQ_Envelope *env;
+ const struct GNUNET_MessageHeader *msg = GNUNET_MQ_env_get_msg (env);
ale->st = NULL;
expiration = GNUNET_TIME_relative_to_absolute (ale->expiration);
@@ -5536,6 +5553,20 @@ store_pi (void *cls)
"Storing our address `%s' in peerstore until %s!\n",
ale->address,
GNUNET_STRINGS_absolute_time_to_string (expiration));
+ add_result = GNUNET_HELLO_builder_add_address (GST_my_hello,
+ ale->address);
+ env = GNUNET_HELLO_builder_to_env (GST_my_hello,
+ GST_my_private_key,
+ GNUNET_TIME_UNIT_ZERO);
+ if (GNUNET_YES == add_result)
+ shc = GNUNET_PEERSTORE_hello_add (peerstore,
+ msg,
+ shc_cont,
+ shc);
+ else if (GNUNET_SYSERR == add_result)
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Error adding address to peerstore hello!\n");
+
GNUNET_HELLO_sign_address (ale->address,
ale->nt,
hello_mono_time,
@@ -5553,6 +5584,7 @@ store_pi (void *cls)
&peerstore_store_own_cb,
ale);
GNUNET_free (addr);
+ GNUNET_free (env);
if (NULL == ale->sc)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -8733,7 +8765,7 @@ handle_validation_challenge (
ir->wc = GNUNET_PEERSTORE_watch (peerstore,
"transport",
&ir->pid,
- GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY,
+ GNUNET_PEERSTORE_HELLO_KEY,
&handle_hello_for_incoming,
ir);
ir_total++;
@@ -11259,7 +11291,7 @@ handle_suggest (void *cls, const struct
ExpressPreferenceMessage *msg)
pr->wc = GNUNET_PEERSTORE_watch (peerstore,
"transport",
&pr->pid,
- GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY,
+ GNUNET_PEERSTORE_HELLO_KEY,
&handle_hello_for_client,
pr);
GNUNET_SERVICE_client_continue (tc->client);
@@ -11445,6 +11477,11 @@ do_shutdown (void *cls)
GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO);
GST_stats = NULL;
}
+ if (NULL != GST_my_hello)
+ {
+ GNUNET_HELLO_builder_free (GST_my_hello);
+ GST_my_hello = NULL;
+ }
if (NULL != GST_my_private_key)
{
GNUNET_free (GST_my_private_key);
@@ -11555,6 +11592,7 @@ run (void *cls,
GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
GST_my_private_key =
GNUNET_CRYPTO_eddsa_key_create_from_configuration (GST_cfg);
+ GST_my_hello = GNUNET_HELLO_builder_new (&GST_my_identity);
if (NULL == GST_my_private_key)
{
GNUNET_log (
diff --git a/src/transport/plugin_transport_tcp.c
b/src/transport/plugin_transport_tcp.c
index ceae64709..e359185b6 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -1509,7 +1509,7 @@ tcp_nat_port_map_callback (void *cls,
static const char *
tcp_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
{
- static char rbuf[INET6_ADDRSTRLEN + 12];
+ static char rbuf[INET6_ADDRSTRLEN + 16];
char buf[INET6_ADDRSTRLEN];
const void *sb;
struct in_addr a4;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] 22/40: NEWS: Code moved to the core package to get rid of circular dependencies., (continued)
- [gnunet] 22/40: NEWS: Code moved to the core package to get rid of circular dependencies., gnunet, 2023/10/05
- [gnunet] 16/40: TOPOLOGY: Exchanged peerinfo api to store hellos with new peerstore api., gnunet, 2023/10/05
- [gnunet] 19/40: HELLO: Cli tool for changing hello files in contrib can change file from old to new hello design., gnunet, 2023/10/05
- [gnunet] 07/40: NEWS: Added command to execute a script., gnunet, 2023/10/05
- [gnunet] 17/40: PEERSTORE: change watch to return actual values, before watching., gnunet, 2023/10/05
- [gnunet] 32/40: Merge branch 'master' into l20integration, gnunet, 2023/10/05
- [gnunet] 29/40: TNG: Fixed syntax., gnunet, 2023/10/05
- [gnunet] 03/40: News: Merge branch 'l20integration' of ssh://git.gnunet.org/gnunet into l20integration, gnunet, 2023/10/05
- [gnunet] 36/40: Fix warnings; CADET not FTBFS because old hello removed, gnunet, 2023/10/05
- [gnunet] 33/40: Merge branch 'master' into l20integration, gnunet, 2023/10/05
- [gnunet] 18/40: NEWS: The old hello design replaced by the new hello design.,
gnunet <=
- [gnunet] 39/40: Make fs and cadet build again; cadet hello handling suspicious, gnunet, 2023/10/05
- [gnunet] 25/40: Hello: Changed address and hello format to new TNG format., gnunet, 2023/10/05
- [gnunet] 38/40: Remove more traces of old transport, gnunet, 2023/10/05
- [gnunet] 31/40: BUILD: Make meson build without ats, tesbed, peerinfo, gnunet, 2023/10/05
- [gnunet] 37/40: Remove more traces of ATS, gnunet, 2023/10/05
- [gnunet] 30/40: Merge branch 'master' into l20integration, gnunet, 2023/10/05
- [gnunet] 40/40: Update to new transport binary, gnunet, 2023/10/05
- [gnunet] 10/40: TNG: Added Testcase that just runs two peers, and blocks., gnunet, 2023/10/05
- [gnunet] 14/40: NEWS: Added api to store hellos with peerstore service., gnunet, 2023/10/05
- [gnunet] 20/40: PEERSTORE: Moved code to scan and import hello file into peerstore from peerinfo., gnunet, 2023/10/05