commit 25367ba7583d04a826416da45f0badfecf943427
parent 36e4cde861b6db54608100e9f77586c86304a479
Author: Jacki <jacki@thejackimonster.de>
Date: Tue, 24 Mar 2026 17:29:25 +0100
Replace old function calls to access local peer identity with pils service
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
10 files changed, 98 insertions(+), 47 deletions(-)
diff --git a/meson.build b/meson.build
@@ -39,9 +39,11 @@ gnunetchat_deps = [
dependency('gnunetfs'),
dependency('gnunetgns'),
dependency('gnunetgnsrecord'),
+ dependency('gnunethello'),
dependency('gnunetidentity'),
dependency('gnunetmessenger'),
dependency('gnunetnamestore'),
+ dependency('gnunetpils'),
dependency('gnunetreclaim'),
dependency('gnunetregex'),
dependency('gnunetutil'),
diff --git a/src/gnunet_chat_context.c b/src/gnunet_chat_context.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2021--2025 GNUnet e.V.
+ Copyright (C) 2021--2026 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
@@ -33,6 +33,7 @@
#include <gnunet/gnunet_messenger_service.h>
#include <gnunet/gnunet_namestore_service.h>
#include <gnunet/gnunet_scheduler_lib.h>
+#include <gnunet/gnunet_util_lib.h>
#include <string.h>
static const unsigned int initial_map_size_of_room = 8;
@@ -455,7 +456,9 @@ context_write_records (struct GNUNET_CHAT_Context *context)
context->handle
);
- if (!zone)
+ const struct GNUNET_PeerIdentity *pid = context->handle->pid;
+
+ if ((!zone) || (!pid))
return;
const struct GNUNET_HashCode *hash = GNUNET_MESSENGER_room_get_key(
@@ -465,7 +468,7 @@ context_write_records (struct GNUNET_CHAT_Context *context)
struct GNUNET_TIME_Absolute expiration = GNUNET_TIME_absolute_get_forever_();
struct GNUNET_MESSENGER_RoomEntryRecord room_entry;
- GNUNET_CRYPTO_get_peer_identity(context->handle->cfg, &(room_entry.door));
+ GNUNET_memcpy(&(room_entry.door), pid, sizeof(*pid));
GNUNET_memcpy(
&(room_entry.key),
diff --git a/src/gnunet_chat_group_intern.c b/src/gnunet_chat_group_intern.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2021--2025 GNUnet e.V.
+ Copyright (C) 2021--2026 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
@@ -48,10 +48,9 @@ search_group_by_topic(void *cls,
(group->context->room)
);
- struct GNUNET_PeerIdentity peer;
- GNUNET_CRYPTO_get_peer_identity(group->handle->cfg, &peer);
+ const struct GNUNET_PeerIdentity *pid = group->handle->pid;
- if (0 == GNUNET_memcmp(&peer, door))
+ if ((pid != NULL) && (0 == GNUNET_memcmp(pid, door)))
return;
union GNUNET_MESSENGER_RoomKey key;
diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c
@@ -30,6 +30,7 @@
#include <gnunet/gnunet_arm_service.h>
#include <gnunet/gnunet_common.h>
#include <gnunet/gnunet_messenger_service.h>
+#include <gnunet/gnunet_pils_service.h>
#include <gnunet/gnunet_reclaim_service.h>
#include <gnunet/gnunet_scheduler_lib.h>
#include <gnunet/gnunet_util_lib.h>
@@ -151,10 +152,17 @@ handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg,
handle->cfg
);
+ handle->pils = GNUNET_PILS_connect(
+ handle->cfg,
+ NULL,
+ handle
+ );
+
handle->reclaim = GNUNET_RECLAIM_connect(
handle->cfg
);
+ handle->pid = NULL;
handle->public_key = NULL;
handle->user_pointer = NULL;
return handle;
@@ -224,6 +232,15 @@ handle_destroy (struct GNUNET_CHAT_Handle *handle)
if (handle->reclaim)
GNUNET_RECLAIM_disconnect(handle->reclaim);
+ if (handle->pils)
+ GNUNET_PILS_disconnect(handle->pils);
+
+ if (handle->pid)
+ {
+ GNUNET_free(handle->pid);
+ handle->pid = NULL;
+ }
+
if (handle->namestore)
GNUNET_NAMESTORE_disconnect(handle->namestore);
diff --git a/src/gnunet_chat_handle.h b/src/gnunet_chat_handle.h
@@ -43,6 +43,7 @@
#include <gnunet/gnunet_identity_service.h>
#include <gnunet/gnunet_messenger_service.h>
#include <gnunet/gnunet_namestore_service.h>
+#include <gnunet/gnunet_pils_service.h>
#include <gnunet/gnunet_reclaim_lib.h>
#include <gnunet/gnunet_reclaim_service.h>
#include <gnunet/gnunet_time_lib.h>
@@ -139,8 +140,10 @@ struct GNUNET_CHAT_Handle
struct GNUNET_IDENTITY_Handle *identity;
struct GNUNET_MESSENGER_Handle *messenger;
struct GNUNET_NAMESTORE_Handle *namestore;
+ struct GNUNET_PILS_Handle *pils;
struct GNUNET_RECLAIM_Handle *reclaim;
+ struct GNUNET_PeerIdentity *pid;
char *public_key;
void *user_pointer;
};
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c
@@ -39,6 +39,7 @@
#include <gnunet/gnunet_arm_service.h>
#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_hello_uri_lib.h>
#include <gnunet/gnunet_identity_service.h>
#include <gnunet/gnunet_messenger_service.h>
#include <gnunet/gnunet_reclaim_service.h>
@@ -57,6 +58,7 @@ static const char gnunet_service_name_gns [] = "gns";
static const char gnunet_service_name_identity [] = "identity";
static const char gnunet_service_name_messenger [] = "messenger";
static const char gnunet_service_name_namestore [] = "namestore";
+static const char gnunet_service_name_pils [] = "pils";
static const char gnunet_service_name_reclaim [] = "reclaim";
void
@@ -131,14 +133,18 @@ on_handle_arm_connection(void *cls,
GNUNET_assert((chat) && (chat->arm));
- if (GNUNET_YES == connected) {
+ if (GNUNET_YES == connected)
+ {
_request_service_via_arm(chat, gnunet_service_name_identity);
_request_service_via_arm(chat, gnunet_service_name_messenger);
_request_service_via_arm(chat, gnunet_service_name_fs);
_request_service_via_arm(chat, gnunet_service_name_gns);
_request_service_via_arm(chat, gnunet_service_name_namestore);
+ _request_service_via_arm(chat, gnunet_service_name_pils);
_request_service_via_arm(chat, gnunet_service_name_reclaim);
- } else {
+ }
+ else
+ {
_request_service_via_arm(chat, gnunet_service_name_arm);
}
}
@@ -655,6 +661,8 @@ scan_handle_room_members (void* cls,
{
struct GNUNET_CHAT_Handle *handle = cls;
+ GNUNET_assert((handle) && (member));
+
if (GNUNET_OK == intern_provide_contact_for_member(handle, member, NULL))
return GNUNET_YES;
else
@@ -669,19 +677,41 @@ on_monitor_namestore_record(void *cls,
unsigned int count,
const struct GNUNET_GNSRECORD_Data *data)
{
- struct GNUNET_CHAT_Handle *chat = cls;
+ struct GNUNET_CHAT_Handle *handle = cls;
+
+ GNUNET_assert((handle) && (label) && (data));
- if (chat->destruction)
+ if (handle->destruction)
{
- GNUNET_NAMESTORE_zone_monitor_stop(chat->monitor);
- chat->monitor = NULL;
+ GNUNET_NAMESTORE_zone_monitor_stop(handle->monitor);
+ handle->monitor = NULL;
return;
}
- handle_process_records(chat, label, count, data);
+ handle_process_records(handle, label, count, data);
+
+ if (handle->monitor)
+ GNUNET_NAMESTORE_zone_monitor_next(handle->monitor, 1);
+}
+
+void
+on_pils_identity_changed(void *cls,
+ const struct GNUNET_HELLO_Parser *parser,
+ GNUNET_UNUSED const struct GNUNET_HashCode *hash)
+{
+ struct GNUNET_CHAT_Handle *handle = cls;
+
+ GNUNET_assert((handle) && (parser));
+
+ const struct GNUNET_PeerIdentity *id = GNUNET_HELLO_parser_get_id(parser);
+
+ if (!id)
+ return;
+
+ if (!handle->pid)
+ handle->pid = GNUNET_new(struct GNUNET_PeerIdentity);
- if (chat->monitor)
- GNUNET_NAMESTORE_zone_monitor_next(chat->monitor, 1);
+ GNUNET_memcpy(handle->pid, id, sizeof(struct GNUNET_PeerIdentity));
}
void
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
@@ -1489,6 +1489,11 @@ GNUNET_CHAT_group_invite_contact (struct GNUNET_CHAT_Group *group,
if (!context)
return GNUNET_SYSERR;
+ const struct GNUNET_PeerIdentity *pid = context->handle->pid;
+
+ if (!pid)
+ return GNUNET_SYSERR;
+
union GNUNET_MESSENGER_RoomKey key;
GNUNET_memcpy(
&(key.hash),
@@ -1504,7 +1509,7 @@ GNUNET_CHAT_group_invite_contact (struct GNUNET_CHAT_Group *group,
memset(&msg, 0, sizeof(msg));
msg.header.kind = GNUNET_MESSENGER_KIND_INVITE;
- GNUNET_CRYPTO_get_peer_identity(group->handle->cfg, &(msg.body.invite.door));
+ GNUNET_memcpy(&(msg.body.invite.door), pid, sizeof(msg.body.invite.door));
GNUNET_memcpy(&(msg.body.invite.key), &key, sizeof(msg.body.invite.key));
GNUNET_MESSENGER_send_message(context->room, &msg, contact->member);
@@ -1658,20 +1663,20 @@ GNUNET_CHAT_context_request (struct GNUNET_CHAT_Context *context)
if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(
handle->contexts, &(key.hash)))
return GNUNET_SYSERR;
+
+ const struct GNUNET_PeerIdentity *pid = handle->pid;
+
+ if (!pid)
+ return GNUNET_SYSERR;
struct GNUNET_MESSENGER_Room *room;
if (GNUNET_YES == owned)
{
- struct GNUNET_PeerIdentity door;
- if (GNUNET_OK == GNUNET_CRYPTO_get_peer_identity(
- handle->cfg, &door))
- room = GNUNET_MESSENGER_enter_room(
- handle->messenger,
- &door,
- &key
- );
- else
- room = NULL;
+ room = GNUNET_MESSENGER_enter_room(
+ handle->messenger,
+ pid,
+ &key
+ );
}
else
room = GNUNET_MESSENGER_open_room(
@@ -1697,7 +1702,7 @@ GNUNET_CHAT_context_request (struct GNUNET_CHAT_Context *context)
memset(&msg, 0, sizeof(msg));
msg.header.kind = GNUNET_MESSENGER_KIND_INVITE;
- GNUNET_CRYPTO_get_peer_identity(handle->cfg, &(msg.body.invite.door));
+ GNUNET_memcpy(&(msg.body.invite.door), pid, sizeof(msg.body.invite.door));
GNUNET_memcpy(&(msg.body.invite.key), &key, sizeof(msg.body.invite.key));
GNUNET_MESSENGER_send_message(other->room, &msg, context->contact);
diff --git a/src/gnunet_chat_lobby_intern.c b/src/gnunet_chat_lobby_intern.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2022--2025 GNUnet e.V.
+ Copyright (C) 2022--2026 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
@@ -90,10 +90,16 @@ cont_lobby_identity_create (void *cls,
lobby->context->room
);
+ const struct GNUNET_PeerIdentity *pid = lobby->handle->pid;
+
struct GNUNET_MESSENGER_RoomEntryRecord room;
- GNUNET_CRYPTO_get_peer_identity(lobby->handle->cfg, &(room.door));
GNUNET_memcpy(&(room.key), key, sizeof(room.key));
+ if (pid)
+ GNUNET_memcpy(&(room.door), pid, sizeof(room.door));
+ else
+ memset(&(room.door), 0, sizeof(room.door));
+
struct GNUNET_GNSRECORD_Data data [1];
data[0].record_type = GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY;
data[0].data = &room;
diff --git a/tools/gnunet_messenger_ping.c b/tools/gnunet_messenger_ping.c
@@ -491,18 +491,10 @@ ego_lookup (void *cls,
tool
);
- struct GNUNET_PeerIdentity peer;
- GNUNET_CRYPTO_get_peer_identity(
- tool->cfg,
- &peer
- );
-
if (tool->auto_pong)
- printf("PONG ");
+ printf("PONG");
else
- printf("PING ");
-
- printf("%s", GNUNET_i2s(&peer));
+ printf("PING");
union GNUNET_MESSENGER_RoomKey rkey;
if (tool->room_name)
diff --git a/tools/gnunet_messenger_uml.c b/tools/gnunet_messenger_uml.c
@@ -415,12 +415,6 @@ ego_lookup (void *cls,
tool
);
- struct GNUNET_PeerIdentity peer;
- GNUNET_CRYPTO_get_peer_identity(
- tool->cfg,
- &peer
- );
-
struct GNUNET_HashCode hash;
if (tool->room_name)
@@ -443,7 +437,7 @@ ego_lookup (void *cls,
GNUNET_MESSENGER_enter_room(
tool->handle,
- &peer,
+ NULL,
&rkey
);
}