[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: TOPOLOGY: Remove libgnunetfriends
From: |
gnunet |
Subject: |
[gnunet] branch master updated: TOPOLOGY: Remove libgnunetfriends |
Date: |
Sat, 14 Oct 2023 09:13:33 +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 e02377c74 TOPOLOGY: Remove libgnunetfriends
e02377c74 is described below
commit e02377c74d59f839240b245c010857dd6249da73
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Sat Oct 14 09:10:55 2023 +0200
TOPOLOGY: Remove libgnunetfriends
---
src/include/gnunet_friends_lib.h | 124 -----------------
src/topology/Makefile.am | 13 --
src/topology/friends.c | 246 ----------------------------------
src/topology/gnunet-daemon-topology.c | 169 ++---------------------
4 files changed, 10 insertions(+), 542 deletions(-)
diff --git a/src/include/gnunet_friends_lib.h b/src/include/gnunet_friends_lib.h
deleted file mode 100644
index 4f4d5e88b..000000000
--- a/src/include/gnunet_friends_lib.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2013 Christian Grothoff
-
- 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
- */
-
-/**
- * @addtogroup Backbone
- * @{
- *
- * @author Christian Grothoff
- *
- * @file
- * Library to read and write the FRIENDS file
- *
- * @defgroup friends Friends library
- * Library to read and write the FRIENDS file
- * @{
- */
-#ifndef GNUNET_FRIENDS_LIB_H
-#define GNUNET_FRIENDS_LIB_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-
-#include "gnunet_util_lib.h"
-
-
-/**
- * Signature of a function called on each friend found.
- *
- * @param cls closure
- * @param friend_id peer identity of the friend
- */
-typedef void (*GNUNET_FRIENDS_Callback)(void *cls,
- const struct
- GNUNET_PeerIdentity *friend_id);
-
-
-/**
- * Parse the FRIENDS file.
- *
- * @param cfg our configuration
- * @param cb function to call on each friend found
- * @param cb_cls closure for @a cb
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on parsing errors
- */
-int
-GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_FRIENDS_Callback cb,
- void *cb_cls);
-
-
-/**
- * Handle for writing a friends file.
- */
-struct GNUNET_FRIENDS_Writer;
-
-
-/**
- * Start writing a fresh FRIENDS file. Will make a backup of the
- * old one.
- *
- * @param cfg configuration to use.
- * @return NULL on error
- */
-struct GNUNET_FRIENDS_Writer *
-GNUNET_FRIENDS_write_start (const struct GNUNET_CONFIGURATION_Handle *cfg);
-
-
-/**
- * Finish writing out the friends file.
- *
- * @param w write handle
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
- */
-int
-GNUNET_FRIENDS_write_stop (struct GNUNET_FRIENDS_Writer *w);
-
-
-/**
- * Add a friend to the friends file.
- *
- * @param w write handle
- * @param friend_id friend to add
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
- */
-int
-GNUNET_FRIENDS_write (struct GNUNET_FRIENDS_Writer *w,
- const struct GNUNET_PeerIdentity *friend_id);
-
-
-#if 0 /* keep Emacsens' auto-indent happy */
-{
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-/** @} */ /* end of group */
-
-/** @} */ /* end of group addition to backbone */
diff --git a/src/topology/Makefile.am b/src/topology/Makefile.am
index aeb05eec7..6ec2ba137 100644
--- a/src/topology/Makefile.am
+++ b/src/topology/Makefile.am
@@ -13,25 +13,12 @@ dist_pkgcfg_DATA = \
topology.conf
-lib_LTLIBRARIES = libgnunetfriends.la
-
-libgnunetfriends_la_SOURCES = \
- friends.c
-libgnunetfriends_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(GN_LIBINTL) $(XLIB)
-libgnunetfriends_la_LDFLAGS = \
- $(GN_LIB_LDFLAGS) \
- -version-info 0:0:0
-
-
libexec_PROGRAMS = \
gnunet-daemon-topology
gnunet_daemon_topology_SOURCES = \
gnunet-daemon-topology.c
gnunet_daemon_topology_LDADD = \
- libgnunetfriends.la \
$(top_builddir)/src/core/libgnunetcore.la \
$(top_builddir)/src/peerstore/libgnunetpeerstore.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
diff --git a/src/topology/friends.c b/src/topology/friends.c
deleted file mode 100644
index 65c7e81d7..000000000
--- a/src/topology/friends.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2013 Christian Grothoff
-
- 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 topology/friends.c
- * @brief library to read and write the FRIENDS file
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "gnunet_friends_lib.h"
-
-
-/**
- * Parse the FRIENDS file.
- *
- * @param cfg our configuration
- * @param cb function to call on each friend found
- * @param cb_cls closure for @a cb
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on parsing errors
- */
-int
-GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_FRIENDS_Callback cb,
- void *cb_cls)
-{
- char *fn;
- char *data;
- size_t pos;
- size_t start;
- struct GNUNET_PeerIdentity pid;
- uint64_t fsize;
- ssize_t ssize;
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg,
- "TOPOLOGY",
- "FRIENDS",
- &fn))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "topology",
- "FRIENDS");
- return GNUNET_SYSERR;
- }
- if ((GNUNET_OK !=
- GNUNET_DISK_file_test (fn)) &&
- (GNUNET_OK !=
- GNUNET_DISK_fn_write (fn,
- NULL,
- 0,
- GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE
- | GNUNET_DISK_OPEN_CREATE)))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
- "write",
- fn);
- if ((GNUNET_OK !=
- GNUNET_DISK_file_size (fn,
- &fsize,
- GNUNET_NO,
- GNUNET_YES)) ||
- (0 == fsize))
- {
- GNUNET_free (fn);
- return GNUNET_OK;
- }
- data = GNUNET_malloc_large (fsize);
- if (NULL == data)
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "malloc");
- GNUNET_free (fn);
- return GNUNET_SYSERR;
- }
- ssize = GNUNET_DISK_fn_read (fn,
- data,
- fsize);
- if ((ssize < 0) ||
- (fsize != (uint64_t) ssize))
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "read",
- "fn");
- GNUNET_free (fn);
- GNUNET_free (data);
- return GNUNET_SYSERR;
- }
- start = 0;
- pos = 0;
- while (pos < fsize)
- {
- while ((pos < fsize) &&
- (! isspace ((unsigned char) data[pos])))
- pos++;
- if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_public_key_from_string (&data[start],
- pos - start,
- &pid.public_key))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _ (
- "Syntax error in FRIENDS file at offset %llu, skipping
bytes `%.*s'.\n"),
- (unsigned long long) pos,
- (int) (pos - start),
- &data[start]);
- pos++;
- start = pos;
- continue;
- }
- pos++;
- start = pos;
- cb (cb_cls, &pid);
- }
- GNUNET_free (data);
- GNUNET_free (fn);
- return GNUNET_OK;
-}
-
-
-/**
- * Handle for writing a friends file.
- */
-struct GNUNET_FRIENDS_Writer
-{
- /**
- * Handle to the file.
- */
- struct GNUNET_DISK_FileHandle *fh;
-};
-
-
-/**
- * Start writing a fresh FRIENDS file. Will make a backup of the
- * old one.
- *
- * @param cfg configuration to use.
- * @return NULL on error
- */
-struct GNUNET_FRIENDS_Writer *
-GNUNET_FRIENDS_write_start (const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct GNUNET_FRIENDS_Writer *w;
- char *fn;
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg, "TOPOLOGY", "FRIENDS",
&fn))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "topology", "FRIENDS");
- return NULL;
- }
- if (GNUNET_OK !=
- GNUNET_DISK_directory_create_for_file (fn))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _ ("Directory for file `%s' does not seem to be writable.\n"),
- fn);
- GNUNET_free (fn);
- return NULL;
- }
- if (GNUNET_OK == GNUNET_DISK_file_test (fn))
- GNUNET_DISK_file_backup (fn);
- w = GNUNET_new (struct GNUNET_FRIENDS_Writer);
- w->fh = GNUNET_DISK_file_open (fn,
- GNUNET_DISK_OPEN_CREATE
- | GNUNET_DISK_OPEN_WRITE
- | GNUNET_DISK_OPEN_FAILIFEXISTS,
- GNUNET_DISK_PERM_USER_READ);
- GNUNET_free (fn);
- if (NULL == w->fh)
- {
- GNUNET_free (w);
- return NULL;
- }
- return w;
-}
-
-
-/**
- * Finish writing out the friends file.
- *
- * @param w write handle
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
- */
-int
-GNUNET_FRIENDS_write_stop (struct GNUNET_FRIENDS_Writer *w)
-{
- int ret;
-
- ret = GNUNET_DISK_file_close (w->fh);
- GNUNET_free (w);
- return ret;
-}
-
-
-/**
- * Add a friend to the friends file.
- *
- * @param w write handle
- * @param friend_id friend to add
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
- */
-int
-GNUNET_FRIENDS_write (struct GNUNET_FRIENDS_Writer *w,
- const struct GNUNET_PeerIdentity *friend_id)
-{
- char *buf;
- char *ret;
- size_t slen;
-
- ret = GNUNET_CRYPTO_eddsa_public_key_to_string (&friend_id->public_key);
- GNUNET_asprintf (&buf,
- "%s\n",
- ret);
- GNUNET_free (ret);
- slen = strlen (buf);
- if (slen !=
- GNUNET_DISK_file_write (w->fh,
- buf,
- slen))
- {
- GNUNET_free (buf);
- return GNUNET_SYSERR;
- }
- GNUNET_free (buf);
- return GNUNET_OK;
-}
-
-
-/* end of friends.c */
diff --git a/src/topology/gnunet-daemon-topology.c
b/src/topology/gnunet-daemon-topology.c
index 61bcce502..efabac0fc 100644
--- a/src/topology/gnunet-daemon-topology.c
+++ b/src/topology/gnunet-daemon-topology.c
@@ -23,23 +23,13 @@
* @brief code for maintaining the overlay topology
* @author Christian Grothoff
*
- * This daemon combines three functions:
- * - suggesting to ATS which peers we might want to connect to
- * - enforcing the F2F restrictions (by blacklisting)
+ * This daemon combines one Function:
* - gossping HELLOs
*
- * All three require similar information (who are our friends
- * impacts connectivity suggestions; connectivity suggestions
- * should consider blacklisting; connectivity suggestions
- * should consider available/known HELLOs; gossip requires
- * connectivity data; connectivity suggestions require
- * connectivity data), which is why they are combined in this
- * program.
*/
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_uri_lib.h"
-#include "gnunet_friends_lib.h"
#include "gnunet_constants.h"
#include "gnunet_core_service.h"
#include "gnunet_protocols.h"
@@ -48,9 +38,6 @@
#include "gnunet_transport_application_service.h"
-// TODO Remove all occurrencies of friends_only and minimum_friend_count.
-
-
/**
* At what frequency do we sent HELLOs to a peer?
*/
@@ -65,7 +52,7 @@
/**
- * Record for neighbours, friends and blacklisted peers.
+ * Record for neighbours and blacklisted peers.
*/
struct Peer
{
@@ -117,10 +104,6 @@ struct Peer
*/
uint32_t strength;
- /**
- * Is this peer listed here because it is a friend?
- */
- int is_friend;
};
@@ -168,7 +151,7 @@ static struct GNUNET_PeerIdentity my_identity;
static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key;
/**
- * All of our friends, all of our current neighbours and all peers for
+ * All of our current neighbours and all peers for
* which we have HELLOs. So pretty much everyone. Maps peer identities
* to `struct Peer *` values.
*/
@@ -186,18 +169,7 @@ static struct GNUNET_STATISTICS_Handle *stats;
static struct GNUNET_SCHEDULER_Task *add_task;
/**
- * Flag to disallow non-friend connections (pure F2F mode).
- */
-static int friends_only;
-
-/**
- * Minimum number of friends to have in the
- * connection set before we allow non-friends.
- */
-static unsigned int minimum_friend_count;
-
-/**
- * Number of peers (friends and others) that we are currently connected to.
+ * Number of peers that we are currently connected to.
*/
static unsigned int connection_count;
@@ -206,12 +178,6 @@ static unsigned int connection_count;
*/
static unsigned int target_connection_count;
-/**
- * Number of friends that we are currently connected to.
- */
-static unsigned int friend_count;
-
-
/**
* Free all resources associated with the given peer.
*
@@ -271,15 +237,6 @@ attempt_connect (struct Peer *pos)
strength = 1;
else
strength = 0;
- if ((friend_count < minimum_friend_count) || (GNUNET_YES == friends_only))
- {
- if (pos->is_friend)
- strength += 10; /* urgently needed */
- else
- strength = 0; /* disallowed */
- }
- if (pos->is_friend)
- strength *= 2; /* friends always count more */
if (NULL != pos->mq)
strength *= 2; /* existing connections preferred */
if (strength == pos->strength)
@@ -315,19 +272,16 @@ attempt_connect (struct Peer *pos)
*
* @param peer identity of the new entry
* @param hello hello message, can be NULL
- * @param is_friend is the new entry for a friend?
* @return the new entry
*/
static struct Peer *
make_peer (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *hello,
- int is_friend)
+ const struct GNUNET_MessageHeader *hello)
{
struct Peer *ret;
ret = GNUNET_new (struct Peer);
ret->pid = *peer;
- ret->is_friend = is_friend;
if (NULL != hello)
{
ret->hello = GNUNET_malloc (ntohs (hello->size));
@@ -571,22 +525,13 @@ connect_notify (void *cls,
pos = GNUNET_CONTAINER_multipeermap_get (peers, peer);
if (NULL == pos)
{
- pos = make_peer (peer, NULL, GNUNET_NO);
+ pos = make_peer (peer, NULL);
}
else
{
GNUNET_assert (NULL == pos->mq);
}
pos->mq = mq;
- if (pos->is_friend)
- {
- friend_count++;
-
- GNUNET_STATISTICS_set (stats,
- gettext_noop ("# friends connected"),
- friend_count,
- GNUNET_NO);
- }
reschedule_hellos (NULL, peer, pos);
return pos;
}
@@ -659,16 +604,7 @@ disconnect_notify (void *cls,
gettext_noop ("# peers connected"),
connection_count,
GNUNET_NO);
- if (pos->is_friend)
- {
- friend_count--;
- GNUNET_STATISTICS_set (stats,
- gettext_noop ("# friends connected"),
- friend_count,
- GNUNET_NO);
- }
- if (((connection_count < target_connection_count) ||
- (friend_count < minimum_friend_count)) &&
+ if ((connection_count < target_connection_count) &&
(NULL == add_task))
add_task = GNUNET_SCHEDULER_add_now (&add_peer_task, NULL);
@@ -733,7 +669,7 @@ consider_for_advertising (const struct GNUNET_MessageHeader
*hello)
peer = GNUNET_CONTAINER_multipeermap_get (peers, pid);
if (NULL == peer)
{
- peer = make_peer (pid, hello, GNUNET_NO);
+ peer = make_peer (pid, hello);
}
else if (NULL != peer->hello)
{
@@ -830,7 +766,7 @@ process_peer (void *cls,
GNUNET_CONTAINER_bloomfilter_free (pos->filter);
pos->filter = NULL;
}
- if ((NULL == pos->mq) && (GNUNET_NO == pos->is_friend))
+ if (NULL == pos->mq)
free_peer (NULL, &pos->pid, pos);
}
return;
@@ -838,7 +774,7 @@ process_peer (void *cls,
consider_for_advertising (hello);
pos = GNUNET_CONTAINER_multipeermap_get (peers, peer);
if (NULL == pos)
- pos = make_peer (peer, hello, GNUNET_NO);
+ pos = make_peer (peer, hello);
attempt_connect (pos);
}
@@ -878,70 +814,6 @@ core_init (void *cls, const struct GNUNET_PeerIdentity
*my_id)
}
-/**
- * Process friend found in FRIENDS file.
- *
- * @param cls pointer to an `unsigned int` to be incremented per friend found
- * @param pid identity of the friend
- */
-static void
-handle_friend (void *cls, const struct GNUNET_PeerIdentity *pid)
-{
- unsigned int *entries_found = cls;
- struct Peer *fl;
-
- if (0 == GNUNET_memcmp (pid, &my_identity))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _ ("Found myself `%s' in friend list (useless, ignored)\n"),
- GNUNET_i2s (pid));
- return;
- }
- (*entries_found)++;
- fl = make_peer (pid, NULL, GNUNET_YES);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _ ("Found friend `%s' in configuration\n"),
- GNUNET_i2s (&fl->pid));
-}
-
-
-/**
- * Read the friends file.
- */
-static void
-read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- unsigned int entries_found;
-
- entries_found = 0;
- if (GNUNET_OK != GNUNET_FRIENDS_parse (cfg, &handle_friend, &entries_found))
- {
- if ((GNUNET_YES == friends_only) || (minimum_friend_count > 0))
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _ ("Encountered errors parsing friends list!\n"));
- }
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# friends in configuration"),
- entries_found,
- GNUNET_NO);
- if ((minimum_friend_count > entries_found) && (GNUNET_NO == friends_only))
- {
- GNUNET_log (
- GNUNET_ERROR_TYPE_WARNING,
- _ (
- "Fewer friends specified than required by minimum friend count. Will
only connect to friends.\n"));
- }
- if ((minimum_friend_count > target_connection_count) &&
- (GNUNET_NO == friends_only))
- {
- GNUNET_log (
- GNUNET_ERROR_TYPE_WARNING,
- _ (
- "More friendly connections required than target total number of
connections.\n"));
- }
-}
-
-
/**
* This function is called whenever an encrypted HELLO message is
* received.
@@ -998,20 +870,6 @@ handle_hello (void *cls, const struct GNUNET_MessageHeader
*message)
gettext_noop ("# HELLO messages received"),
1,
GNUNET_NO);
- peer = GNUNET_CONTAINER_multipeermap_get (peers, pid);
- if (NULL == peer)
- {
- if ((GNUNET_YES == friends_only) || (friend_count < minimum_friend_count))
- return;
- }
- else
- {
- if ((GNUNET_YES != peer->is_friend) && (GNUNET_YES == friends_only))
- return;
- if ((GNUNET_YES != peer->is_friend) &&
- (friend_count < minimum_friend_count))
- return;
- }
GNUNET_HELLO_builder_from_msg (message);
shc = GNUNET_PEERSTORE_hello_add (ps, message, &shc_cont, shc);
GNUNET_HELLO_builder_free (builder);
@@ -1094,7 +952,6 @@ run (void *cls,
GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg);
stats = GNUNET_STATISTICS_create ("topology", cfg);
- minimum_friend_count = 0;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (cfg,
"TOPOLOGY",
@@ -1104,12 +961,6 @@ run (void *cls,
target_connection_count = (unsigned int) opt;
peers = GNUNET_CONTAINER_multipeermap_create (target_connection_count * 2,
GNUNET_NO);
- read_friends_file (cfg);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Topology would like %u connections with at least %u friends\n",
- target_connection_count,
- minimum_friend_count);
-
transport = GNUNET_TRANSPORT_application_init (cfg);
ps = GNUNET_PEERSTORE_connect (cfg);
handle = GNUNET_CORE_connect (cfg,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: TOPOLOGY: Remove libgnunetfriends,
gnunet <=