diff options
Diffstat (limited to 'src/hostlist/gnunet-daemon-hostlist_client.c')
-rw-r--r-- | src/hostlist/gnunet-daemon-hostlist_client.c | 83 |
1 files changed, 21 insertions, 62 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c index 207cc4a811..43b4e45931 100644 --- a/src/hostlist/gnunet-daemon-hostlist_client.c +++ b/src/hostlist/gnunet-daemon-hostlist_client.c @@ -2,20 +2,18 @@ This file is part of GNUnet. Copyright (C) 2001-2010, 2014, 2016 GNUnet e.V. - GNUnet is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3, or (at your - option) any later version. + 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + 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/>. */ /** * @file hostlist/gnunet-daemon-hostlist_client.c @@ -28,6 +26,7 @@ #include "gnunet_hello_lib.h" #include "gnunet_statistics_service.h" #include "gnunet_transport_service.h" +#include "gnunet_peerinfo_service.h" #include "gnunet-daemon-hostlist.h" #if HAVE_CURL_CURL_H #include <curl/curl.h> @@ -142,14 +141,6 @@ struct Hostlist }; -struct HelloOffer -{ - struct HelloOffer *next; - struct HelloOffer *prev; - struct GNUNET_TRANSPORT_OfferHelloHandle *ohh; -}; - - /** * Our configuration. */ @@ -315,24 +306,10 @@ static unsigned int stat_hellos_obtained; */ static unsigned int stat_connection_count; -static struct HelloOffer *ho_head; - -static struct HelloOffer *ho_tail; - - /** - * Hello offer complete. Clean up. + * Handle to peerinfo service. */ -static void -done_offer_hello (void *cls) -{ - struct HelloOffer *ho = cls; - - GNUNET_CONTAINER_DLL_remove (ho_head, - ho_tail, - ho); - GNUNET_free (ho); -} +static struct GNUNET_PEERINFO_Handle *pi; /** @@ -353,7 +330,6 @@ callback_download (void *ptr, static char download_buffer[GNUNET_MAX_MESSAGE_SIZE - 1]; const char *cbuf = ptr; const struct GNUNET_MessageHeader *msg; - struct HelloOffer *ho; size_t total; size_t cpy; size_t left; @@ -413,22 +389,10 @@ callback_download (void *ptr, ("# valid HELLOs downloaded from hostlist servers"), 1, GNUNET_NO); stat_hellos_obtained++; - - ho = GNUNET_new (struct HelloOffer); - ho->ohh = GNUNET_TRANSPORT_offer_hello (cfg, - msg, - &done_offer_hello, - ho); - if (NULL == ho->ohh) - { - GNUNET_free (ho); - } - else - { - GNUNET_CONTAINER_DLL_insert (ho_head, - ho_tail, - ho); - } + (void) GNUNET_PEERINFO_add_peer (pi, + (const struct GNUNET_HELLO_Message *) msg, + NULL, + NULL); } else { @@ -1567,6 +1531,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, stats = st; /* Read proxy configuration */ + pi = GNUNET_PEERINFO_connect (c); if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", @@ -1723,18 +1688,8 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, void GNUNET_HOSTLIST_client_stop () { - struct HelloOffer *ho; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostlist client shutdown\n"); - while (NULL != (ho = ho_head)) - { - GNUNET_CONTAINER_DLL_remove (ho_head, - ho_tail, - ho); - GNUNET_TRANSPORT_offer_hello_cancel (ho->ohh); - GNUNET_free (ho); - } if (NULL != sget) { GNUNET_STATISTICS_get_cancel (sget); @@ -1777,7 +1732,11 @@ GNUNET_HOSTLIST_client_stop () proxy_username = NULL; GNUNET_free_non_null (proxy_password); proxy_password = NULL; - + if (NULL != pi) + { + GNUNET_PEERINFO_disconnect (pi); + pi = NULL; + } cfg = NULL; } |