2 This file is part of GNUnet.
3 (C) 2001-2010, 2014 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file hostlist/gnunet-daemon-hostlist_client.c
22 * @brief hostlist support. Downloads HELLOs via HTTP.
23 * @author Christian Grothoff
24 * @author Matthias Wachs
27 #include "gnunet-daemon-hostlist_client.h"
28 #include "gnunet_hello_lib.h"
29 #include "gnunet_statistics_service.h"
30 #include "gnunet_transport_service.h"
31 #include "gnunet-daemon-hostlist.h"
32 #include <curl/curl.h>
36 * Number of connections that we must have to NOT download
39 #define MIN_CONNECTIONS 4
42 * Maximum number of hostlist that are saved
44 #define MAX_NUMBER_HOSTLISTS 30
47 * Time interval hostlists are saved to disk
49 #define SAVING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30)
52 * Time interval between two hostlist tests
54 #define TESTING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
57 * Time interval for download dispatcher before a download is re-scheduled
59 #define WAITING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
62 * Defines concerning the hostlist quality metric
66 * Initial quality of a new created hostlist
68 #define HOSTLIST_INITIAL 10000
71 * Value subtracted each time a hostlist download fails
73 #define HOSTLIST_FAILED_DOWNLOAD 100
76 * Value added each time a hostlist download is successful
78 #define HOSTLIST_SUCCESSFUL_DOWNLOAD 100
81 * Value added for each valid HELLO recived during a hostlist download
83 #define HOSTLIST_SUCCESSFUL_HELLO 1
88 * A single hostlist obtained by hostlist advertisements
93 * previous entry, used to manage entries in a double linked list
95 struct Hostlist *prev;
98 * next entry, used to manage entries in a double linked list
100 struct Hostlist *next;
103 * URI where hostlist can be obtained
105 const char *hostlist_uri;
108 * Value describing the quality of the hostlist, the bigger the better but (should) never < 0
109 * used for deciding which hostlist is replaced if MAX_NUMBER_HOSTLISTS in data structure is reached
110 * intial value = HOSTLIST_INITIAL
111 * increased every successful download by HOSTLIST_SUCCESSFULL_DOWNLOAD
112 * increased every successful download by number of obtained HELLO messages
113 * decreased every failed download by HOSTLIST_SUCCESSFULL_DOWNLOAD
118 * Time the hostlist advertisement was recieved and the entry was created
120 struct GNUNET_TIME_Absolute time_creation;
123 * Last time the hostlist was obtained
125 struct GNUNET_TIME_Absolute time_last_usage;
128 * Number of HELLO messages obtained during last download
130 uint32_t hello_count;
133 * Number of times the hostlist was successfully obtained
143 static const struct GNUNET_CONFIGURATION_Handle *cfg;
148 static struct GNUNET_STATISTICS_Handle *stats;
153 static struct GNUNET_TRANSPORT_Handle *transport;
156 * Proxy hostname or ip we are using (can be NULL).
161 * Proxy username we are using (can be NULL).
163 static char *proxy_username;
166 * Proxy password we are using (can be NULL).
168 static char *proxy_password;
171 * Proxy type we are using (can be NULL).
173 static curl_proxytype proxy_type;
176 * Number of bytes valid in 'download_buffer'.
178 static size_t download_pos;
181 * Current URL that we are using.
183 static char *current_url;
186 * Current CURL handle.
191 * Current multi-CURL handle.
196 * How many bytes did we download from the current hostlist URL?
198 static uint32_t stat_bytes_downloaded;
201 * Amount of time we wait between hostlist downloads.
203 static struct GNUNET_TIME_Relative hostlist_delay;
206 * ID of the task, checking if hostlist download should take plate
208 static GNUNET_SCHEDULER_TaskIdentifier ti_check_download;
211 * ID of the task downloading the hostlist
213 static GNUNET_SCHEDULER_TaskIdentifier ti_download;
216 * ID of the task saving the hostlsit in a regular intervall
218 static GNUNET_SCHEDULER_TaskIdentifier ti_saving_task;
221 * ID of the task called to initiate a download
223 static GNUNET_SCHEDULER_TaskIdentifier ti_download_dispatcher_task;
226 * ID of the task controlling the locking between two hostlist tests
228 static GNUNET_SCHEDULER_TaskIdentifier ti_testing_intervall_task;
231 * At what time MUST the current hostlist request be done?
233 static struct GNUNET_TIME_Absolute end_time;
236 * Head of the linked list used to store hostlists
238 static struct Hostlist *linked_list_head;
241 * Tail of the linked list used to store hostlists
243 static struct Hostlist *linked_list_tail;
246 * Current hostlist used for downloading
248 static struct Hostlist *current_hostlist;
251 * Size of the linke list used to store hostlists
253 static unsigned int linked_list_size;
256 * Head of the linked list used to store hostlists
258 static struct Hostlist *hostlist_to_test;
261 * Handle for our statistics GET operation.
263 static struct GNUNET_STATISTICS_GetHandle *sget;
266 * Set to GNUNET_YES if the current URL had some problems.
268 static int stat_bogus_url;
271 * Value controlling if a hostlist is tested at the moment
273 static int stat_testing_hostlist;
276 * Value controlling if a hostlist testing is allowed at the moment
278 static int stat_testing_allowed;
281 * Value controlling if a hostlist download is running at the moment
283 static int stat_download_in_progress;
286 * Value saying if a preconfigured bootstrap server is used
288 static unsigned int stat_use_bootstrap;
291 * Set if we are allowed to learn new hostlists and use them
293 static int stat_learning;
296 * Value saying if hostlist download was successful
298 static unsigned int stat_download_successful;
301 * Value saying how many valid HELLO messages were obtained during download
303 static unsigned int stat_hellos_obtained;
306 * Number of active connections (according to core service).
308 static unsigned int stat_connection_count;
312 * Process downloaded bits by calling callback on each HELLO.
314 * @param ptr buffer with downloaded data
315 * @param size size of a record
316 * @param nmemb number of records downloaded
318 * @return number of bytes that were processed (always size*nmemb)
321 callback_download (void *ptr,
326 static char download_buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1];
327 const char *cbuf = ptr;
328 const struct GNUNET_MessageHeader *msg;
334 total = size * nmemb;
335 stat_bytes_downloaded += total;
336 if ((total == 0) || (stat_bogus_url))
338 return total; /* ok, no data or bogus data */
341 GNUNET_STATISTICS_update (stats,
343 ("# bytes downloaded from hostlist servers"),
344 (int64_t) total, GNUNET_NO);
346 while ((left > 0) || (download_pos > 0))
348 cpy = GNUNET_MIN (left, GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - download_pos);
349 memcpy (&download_buffer[download_pos], cbuf, cpy);
353 if (download_pos < sizeof (struct GNUNET_MessageHeader))
355 GNUNET_assert (0 == left);
358 msg = (const struct GNUNET_MessageHeader *) download_buffer;
359 msize = ntohs (msg->size);
360 if (msize < sizeof (struct GNUNET_MessageHeader))
362 GNUNET_STATISTICS_update (stats,
364 ("# invalid HELLOs downloaded from hostlist servers"),
366 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
367 _("Invalid `%s' message received from hostlist at `%s'\n"),
368 "HELLO", current_url);
369 stat_hellos_obtained++;
373 if (download_pos < msize)
375 GNUNET_assert (left == 0);
378 if (GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message *) msg) == msize)
380 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
381 "Received valid `%s' message from hostlist server.\n",
383 GNUNET_STATISTICS_update (stats,
385 ("# valid HELLOs downloaded from hostlist servers"),
387 stat_hellos_obtained++;
388 GNUNET_TRANSPORT_offer_hello (transport, msg, NULL, NULL);
392 GNUNET_STATISTICS_update (stats,
394 ("# invalid HELLOs downloaded from hostlist servers"),
396 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
397 _("Invalid `%s' message received from hostlist at `%s'\n"),
398 "HELLO", current_url);
399 stat_bogus_url = GNUNET_YES;
400 stat_hellos_obtained++;
403 memmove (download_buffer, &download_buffer[msize], download_pos - msize);
404 download_pos -= msize;
411 * Obtain a hostlist URL that we should use.
413 * @return NULL if there is no URL available
416 get_bootstrap_server ()
424 GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", "SERVERS",
427 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
428 "hostlist", "SERVERS");
433 if (strlen (servers) > 0)
436 pos = strlen (servers) - 1;
439 if (servers[pos] == ' ')
446 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
447 "hostlist", "SERVERS");
448 GNUNET_free (servers);
452 urls = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, urls) + 1;
453 pos = strlen (servers) - 1;
456 if (servers[pos] == ' ')
468 ret = GNUNET_strdup (&servers[pos]);
469 GNUNET_free (servers);
475 * Method deciding if a preconfigured or advertisied hostlist is used on a 50:50 ratio
476 * @return uri to use, NULL if there is no URL available
482 unsigned int counter;
483 struct Hostlist *pos;
485 if (GNUNET_NO == stat_learning)
487 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
488 "Using preconfigured bootstrap server\n");
489 current_hostlist = NULL;
490 return get_bootstrap_server ();
493 if ((GNUNET_YES == stat_testing_hostlist) && (NULL != hostlist_to_test))
495 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
496 "Testing new advertised hostlist if it is obtainable\n");
497 current_hostlist = hostlist_to_test;
498 return GNUNET_strdup (hostlist_to_test->hostlist_uri);
501 if ((GNUNET_YES == stat_use_bootstrap) || (linked_list_size == 0))
503 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
504 "Using preconfigured bootstrap server\n");
505 current_hostlist = NULL;
506 return get_bootstrap_server ();
509 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, linked_list_size);
511 pos = linked_list_head;
512 while (counter < index)
517 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using learned hostlist `%s'\n",
519 current_hostlist = pos;
520 return GNUNET_strdup (pos->hostlist_uri);
524 #define CURL_EASY_SETOPT(c, a, b) do { ret = curl_easy_setopt (c, a, b); if (CURLE_OK != ret) GNUNET_log(GNUNET_ERROR_TYPE_WARNING, _("%s failed at %s:%d: `%s'\n"), "curl_easy_setopt", __FILE__, __LINE__, curl_easy_strerror (ret)); } while (0)
528 * Method to save hostlist to a file during hostlist client shutdown
530 * @param shutdown set if called because of shutdown, entries in linked list will be destroyed
533 save_hostlist_file (int shutdown);
537 * Add val2 to val1 with overflow check
539 * @param val1 value 1
540 * @param val2 value 2
544 checked_add (uint64_t val1,
547 static uint64_t temp;
548 static uint64_t maxv;
561 * Subtract val2 from val1 with underflow check
563 * @param val1 value 1
564 * @param val2 value 2
568 checked_sub (uint64_t val1,
573 return (val1 - val2);
578 * Method to check if a URI is in hostlist linked list
580 * @param uri uri to check
581 * @return #GNUNET_YES if existing in linked list, #GNUNET_NO if not
584 linked_list_contains (const char *uri)
586 struct Hostlist *pos;
588 pos = linked_list_head;
591 if (0 == strcmp (pos->hostlist_uri, uri))
600 * Method returning the hostlist element with the lowest quality in the datastore
601 * @return hostlist with lowest quality
603 static struct Hostlist *
604 linked_list_get_lowest_quality ()
606 struct Hostlist *pos;
607 struct Hostlist *lowest;
609 if (linked_list_size == 0)
611 lowest = linked_list_head;
612 pos = linked_list_head->next;
615 if (pos->quality < lowest->quality)
624 * Method to insert a hostlist into the datastore. If datastore
625 * contains maximum number of elements, the elements with lowest
626 * quality is dismissed
631 struct Hostlist *lowest_quality;
633 if (MAX_NUMBER_HOSTLISTS <= linked_list_size)
635 /* No free entries available, replace existing entry */
636 lowest_quality = linked_list_get_lowest_quality ();
637 GNUNET_assert (lowest_quality != NULL);
638 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
639 "Removing hostlist with URI `%s' which has the worst quality of all (%llu)\n",
640 lowest_quality->hostlist_uri,
641 (unsigned long long) lowest_quality->quality);
642 GNUNET_CONTAINER_DLL_remove (linked_list_head, linked_list_tail,
645 GNUNET_free (lowest_quality);
647 GNUNET_CONTAINER_DLL_insert (linked_list_head, linked_list_tail,
650 GNUNET_STATISTICS_set (stats, gettext_noop ("# advertised hostlist URIs"),
651 linked_list_size, GNUNET_NO);
652 stat_testing_hostlist = GNUNET_NO;
657 * Method updating hostlist statistics
664 if (((stat_use_bootstrap == GNUNET_NO) && (NULL != current_hostlist)) ||
665 ((stat_testing_hostlist == GNUNET_YES) && (NULL != current_hostlist)))
667 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
668 "Updating hostlist statics for URI `%s'\n",
669 current_hostlist->hostlist_uri);
670 current_hostlist->hello_count = stat_hellos_obtained;
671 current_hostlist->time_last_usage = GNUNET_TIME_absolute_get ();
672 current_hostlist->quality =
673 checked_add (current_hostlist->quality,
674 (stat_hellos_obtained * HOSTLIST_SUCCESSFUL_HELLO));
675 if (GNUNET_YES == stat_download_successful)
677 current_hostlist->times_used++;
678 current_hostlist->quality =
679 checked_add (current_hostlist->quality, HOSTLIST_SUCCESSFUL_DOWNLOAD);
680 GNUNET_asprintf (&stat, gettext_noop ("# advertised URI `%s' downloaded"),
681 current_hostlist->hostlist_uri);
683 GNUNET_STATISTICS_update (stats, stat, 1, GNUNET_YES);
687 current_hostlist->quality =
688 checked_sub (current_hostlist->quality, HOSTLIST_FAILED_DOWNLOAD);
690 current_hostlist = NULL;
691 /* Alternating the usage of preconfigured and learned hostlists */
693 if (stat_testing_hostlist == GNUNET_YES)
696 if (GNUNET_YES == stat_learning)
698 if (stat_use_bootstrap == GNUNET_YES)
699 stat_use_bootstrap = GNUNET_NO;
701 stat_use_bootstrap = GNUNET_YES;
704 stat_use_bootstrap = GNUNET_YES;
709 * Clean up the state from the task that downloaded the
710 * hostlist and schedule the next task.
717 if ((stat_testing_hostlist == GNUNET_YES) &&
718 (GNUNET_NO == stat_download_successful) && (NULL != hostlist_to_test))
720 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
722 ("Advertised hostlist with URI `%s' could not be downloaded. Advertised URI gets dismissed.\n"),
723 hostlist_to_test->hostlist_uri);
726 if (stat_testing_hostlist == GNUNET_YES)
728 stat_testing_hostlist = GNUNET_NO;
730 if (NULL != hostlist_to_test)
732 GNUNET_free (hostlist_to_test);
733 hostlist_to_test = NULL;
738 mret = curl_multi_remove_handle (multi, curl);
739 if (mret != CURLM_OK)
741 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
742 "curl_multi_remove_handle", __FILE__, __LINE__,
743 curl_multi_strerror (mret));
745 mret = curl_multi_cleanup (multi);
746 if (mret != CURLM_OK)
747 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
748 "curl_multi_cleanup", __FILE__, __LINE__,
749 curl_multi_strerror (mret));
754 curl_easy_cleanup (curl);
757 GNUNET_free_non_null (current_url);
759 stat_bytes_downloaded = 0;
760 stat_download_in_progress = GNUNET_NO;
765 * Task that is run when we are ready to receive more data from the hostlist
768 * @param cls closure, unused
769 * @param tc task context, unused
772 task_download (void *cls,
773 const struct GNUNET_SCHEDULER_TaskContext *tc);
777 * Ask CURL for the select set and then schedule the
778 * receiving task with the scheduler.
788 struct GNUNET_NETWORK_FDSet *grs;
789 struct GNUNET_NETWORK_FDSet *gws;
791 struct GNUNET_TIME_Relative rtime;
797 mret = curl_multi_fdset (multi, &rs, &ws, &es, &max);
798 if (mret != CURLM_OK)
800 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
801 "curl_multi_fdset", __FILE__, __LINE__,
802 curl_multi_strerror (mret));
806 mret = curl_multi_timeout (multi, &timeout);
807 if (mret != CURLM_OK)
809 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
810 "curl_multi_timeout", __FILE__, __LINE__,
811 curl_multi_strerror (mret));
816 GNUNET_TIME_relative_min (GNUNET_TIME_absolute_get_remaining (end_time),
817 GNUNET_TIME_relative_multiply
818 (GNUNET_TIME_UNIT_MILLISECONDS, timeout));
819 grs = GNUNET_NETWORK_fdset_create ();
820 gws = GNUNET_NETWORK_fdset_create ();
821 GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);
822 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);
823 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
824 "Scheduling task for hostlist download using cURL\n");
826 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
828 &task_download, multi);
829 GNUNET_NETWORK_fdset_destroy (gws);
830 GNUNET_NETWORK_fdset_destroy (grs);
835 * Task that is run when we are ready to receive more data from the hostlist
838 * @param cls closure, unused
839 * @param tc task context, unused
842 task_download (void *cls,
843 const struct GNUNET_SCHEDULER_TaskContext *tc)
849 ti_download = GNUNET_SCHEDULER_NO_TASK;
850 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
852 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
853 "Shutdown requested while trying to download hostlist from `%s'\n",
859 if (0 == GNUNET_TIME_absolute_get_remaining (end_time).rel_value_us)
861 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
862 _("Timeout trying to download hostlist from `%s'\n"),
868 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
869 "Ready for processing hostlist client request\n");
873 if (stat_bytes_downloaded > MAX_BYTES_PER_HOSTLISTS)
875 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
876 _("Download limit of %u bytes exceeded, stopping download\n"),
877 MAX_BYTES_PER_HOSTLISTS);
881 mret = curl_multi_perform (multi, &running);
886 msg = curl_multi_info_read (multi, &running);
887 GNUNET_break (msg != NULL);
893 if ((msg->data.result != CURLE_OK) &&
894 (msg->data.result != CURLE_GOT_NOTHING))
895 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
896 _("Download of hostlist from `%s' failed: `%s'\n"),
898 curl_easy_strerror (msg->data.result));
901 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
902 _("Download of hostlist `%s' completed.\n"),
904 stat_download_successful = GNUNET_YES;
906 if (GNUNET_YES == stat_testing_hostlist)
908 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
910 ("Adding successfully tested hostlist `%s' datastore.\n"),
913 hostlist_to_test = NULL;
914 stat_testing_hostlist = GNUNET_NO;
924 while ((running > 0));
927 while (mret == CURLM_CALL_MULTI_PERFORM);
929 if (mret != CURLM_OK)
931 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("%s failed at %s:%d: `%s'\n"),
932 "curl_multi_perform", __FILE__, __LINE__,
933 curl_multi_strerror (mret));
941 * Main function that will download a hostlist and process its
951 current_url = download_get_url ();
952 if (current_url == NULL)
954 curl = curl_easy_init ();
962 GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
963 _("Bootstrapping using hostlist at `%s'.\n"), current_url);
965 stat_download_in_progress = GNUNET_YES;
966 stat_download_successful = GNUNET_NO;
967 stat_hellos_obtained = 0;
968 stat_bytes_downloaded = 0;
970 GNUNET_STATISTICS_update (stats,
971 gettext_noop ("# hostlist downloads initiated"), 1,
975 CURL_EASY_SETOPT (curl, CURLOPT_PROXY, proxy);
976 CURL_EASY_SETOPT (curl, CURLOPT_PROXYTYPE, proxy_type);
977 if (NULL != proxy_username)
978 CURL_EASY_SETOPT (curl, CURLOPT_PROXYUSERNAME, proxy_username);
979 if (NULL != proxy_password)
980 CURL_EASY_SETOPT (curl, CURLOPT_PROXYPASSWORD, proxy_password);
984 CURL_EASY_SETOPT (curl, CURLOPT_WRITEFUNCTION, &callback_download);
990 CURL_EASY_SETOPT (curl, CURLOPT_WRITEDATA, NULL);
996 CURL_EASY_SETOPT (curl, CURLOPT_FOLLOWLOCATION, 1);
997 CURL_EASY_SETOPT (curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
998 CURL_EASY_SETOPT (curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
999 CURL_EASY_SETOPT (curl, CURLOPT_MAXREDIRS, 4);
1000 /* no need to abort if the above failed */
1001 CURL_EASY_SETOPT (curl, CURLOPT_URL, current_url);
1002 if (ret != CURLE_OK)
1007 CURL_EASY_SETOPT (curl, CURLOPT_FAILONERROR, 1);
1009 CURL_EASY_SETOPT (curl, CURLOPT_VERBOSE, 1);
1011 CURL_EASY_SETOPT (curl, CURLOPT_BUFFERSIZE, GNUNET_SERVER_MAX_MESSAGE_SIZE);
1012 if (0 == strncmp (current_url, "http", 4))
1013 CURL_EASY_SETOPT (curl, CURLOPT_USERAGENT, "GNUnet");
1014 CURL_EASY_SETOPT (curl, CURLOPT_CONNECTTIMEOUT, 60L);
1015 CURL_EASY_SETOPT (curl, CURLOPT_TIMEOUT, 60L);
1016 multi = curl_multi_init ();
1023 mret = curl_multi_add_handle (multi, curl);
1024 if (mret != CURLM_OK)
1026 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
1027 "curl_multi_add_handle", __FILE__, __LINE__,
1028 curl_multi_strerror (mret));
1029 mret = curl_multi_cleanup (multi);
1030 if (mret != CURLM_OK)
1031 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
1032 "curl_multi_cleanup", __FILE__, __LINE__,
1033 curl_multi_strerror (mret));
1038 end_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
1039 download_prepare ();
1044 task_download_dispatcher (void *cls,
1045 const struct GNUNET_SCHEDULER_TaskContext *tc)
1047 ti_download_dispatcher_task = GNUNET_SCHEDULER_NO_TASK;
1048 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1050 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download is initiated...\n");
1051 if (GNUNET_NO == stat_download_in_progress)
1053 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download can start immediately...\n");
1054 download_hostlist ();
1058 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1059 "Download in progess, have to wait...\n");
1060 ti_download_dispatcher_task =
1061 GNUNET_SCHEDULER_add_delayed (WAITING_INTERVAL,
1062 &task_download_dispatcher, NULL);
1068 * Task that checks if we should try to download a hostlist.
1069 * If so, we initiate the download, otherwise we schedule
1070 * this task again for a later time.
1073 task_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1076 struct GNUNET_TIME_Relative delay;
1078 ti_check_download = GNUNET_SCHEDULER_NO_TASK;
1079 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1083 curl_global_cleanup ();
1084 return; /* in shutdown */
1086 if ( (stat_connection_count < MIN_CONNECTIONS) &&
1087 (GNUNET_SCHEDULER_NO_TASK == ti_download_dispatcher_task) )
1088 ti_download_dispatcher_task =
1089 GNUNET_SCHEDULER_add_now (&task_download_dispatcher, NULL);
1091 delay = hostlist_delay;
1092 if (0 == hostlist_delay.rel_value_us)
1093 hostlist_delay = GNUNET_TIME_UNIT_SECONDS;
1095 hostlist_delay = GNUNET_TIME_relative_multiply (hostlist_delay, 2);
1096 if (hostlist_delay.rel_value_us >
1097 GNUNET_TIME_UNIT_HOURS.rel_value_us * (1 + stat_connection_count))
1099 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS,
1100 (1 + stat_connection_count));
1101 GNUNET_STATISTICS_set (stats,
1103 ("# milliseconds between hostlist downloads"),
1104 hostlist_delay.rel_value_us / 1000LL,
1108 delay = GNUNET_TIME_UNIT_ZERO;
1111 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1112 _("Have %u/%u connections. Will consider downloading hostlist in %s\n"),
1113 stat_connection_count, MIN_CONNECTIONS,
1114 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
1115 ti_check_download = GNUNET_SCHEDULER_add_delayed (delay, &task_check, NULL);
1120 * This tasks sets hostlist testing to allowed after intervall between to testings is reached
1122 * @param cls closure
1123 * @param tc TaskContext
1126 task_testing_intervall_reset (void *cls,
1127 const struct GNUNET_SCHEDULER_TaskContext *tc)
1129 ti_testing_intervall_task = GNUNET_SCHEDULER_NO_TASK;
1130 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1132 stat_testing_allowed = GNUNET_OK;
1133 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1134 "Testing new hostlist advertisements is allowed again\n");
1139 * Task that writes hostlist entries to a file on a regular base
1141 * @param cls closure
1142 * @param tc TaskContext
1145 task_hostlist_saving (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1147 ti_saving_task = GNUNET_SCHEDULER_NO_TASK;
1148 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1150 save_hostlist_file (GNUNET_NO);
1152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1153 "Hostlists will be saved to file again in %s\n",
1154 GNUNET_STRINGS_relative_time_to_string(SAVING_INTERVAL, GNUNET_YES));
1156 GNUNET_SCHEDULER_add_delayed (SAVING_INTERVAL, &task_hostlist_saving,
1162 * Method called whenever a given peer connects.
1164 * @param cls closure
1165 * @param peer peer identity this notification is about
1168 handler_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
1170 GNUNET_assert (stat_connection_count < UINT_MAX);
1171 stat_connection_count++;
1172 GNUNET_STATISTICS_update (stats, gettext_noop ("# active connections"), 1,
1178 * Method called whenever a given peer disconnects.
1180 * @param cls closure
1181 * @param peer peer identity this notification is about
1184 handler_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
1186 GNUNET_assert (stat_connection_count > 0);
1187 stat_connection_count--;
1188 GNUNET_STATISTICS_update (stats, gettext_noop ("# active connections"), -1,
1194 * Method called whenever an advertisement message arrives.
1196 * @param cls closure (always NULL)
1197 * @param peer the peer sending the message
1198 * @param message the actual message
1199 * @return #GNUNET_OK to keep the connection open,
1200 * #GNUNET_SYSERR to close it (signal serious error)
1203 handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer,
1204 const struct GNUNET_MessageHeader *message)
1208 const struct GNUNET_MessageHeader *incoming;
1210 struct Hostlist *hostlist;
1212 GNUNET_assert (ntohs (message->type) ==
1213 GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT);
1214 size = ntohs (message->size);
1215 if (size <= sizeof (struct GNUNET_MessageHeader))
1217 GNUNET_break_op (0);
1218 return GNUNET_SYSERR;
1220 incoming = (const struct GNUNET_MessageHeader *) message;
1221 uri = (const char *) &incoming[1];
1222 uri_size = size - sizeof (struct GNUNET_MessageHeader);
1223 if (uri[uri_size - 1] != '\0')
1225 GNUNET_break_op (0);
1226 return GNUNET_SYSERR;
1228 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1229 "Hostlist client recieved advertisement from `%s' containing URI `%s'\n",
1230 GNUNET_i2s (peer), uri);
1231 if (GNUNET_NO != linked_list_contains (uri))
1233 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "URI `%s' is already known\n", uri);
1237 if (GNUNET_NO == stat_testing_allowed)
1239 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1240 "Currently not accepting new advertisements: interval between to advertisements is not reached\n");
1241 return GNUNET_SYSERR;
1243 if (GNUNET_YES == stat_testing_hostlist)
1245 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1246 "Currently not accepting new advertisements: we are already testing a hostlist\n");
1247 return GNUNET_SYSERR;
1250 hostlist = GNUNET_malloc (sizeof (struct Hostlist) + uri_size);
1251 hostlist->hostlist_uri = (const char *) &hostlist[1];
1252 memcpy (&hostlist[1], uri, uri_size);
1253 hostlist->time_creation = GNUNET_TIME_absolute_get ();
1254 hostlist->quality = HOSTLIST_INITIAL;
1255 hostlist_to_test = hostlist;
1257 stat_testing_hostlist = GNUNET_YES;
1258 stat_testing_allowed = GNUNET_NO;
1259 ti_testing_intervall_task =
1260 GNUNET_SCHEDULER_add_delayed (TESTING_INTERVAL,
1261 &task_testing_intervall_reset, NULL);
1263 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1264 "Testing new hostlist advertisements is locked for the next %s\n",
1265 GNUNET_STRINGS_relative_time_to_string (TESTING_INTERVAL,
1268 ti_download_dispatcher_task =
1269 GNUNET_SCHEDULER_add_now (&task_download_dispatcher, NULL);
1276 * Continuation called by the statistics code once
1277 * we go the stat. Initiates hostlist download scheduling.
1279 * @param cls closure
1280 * @param success #GNUNET_OK if statistics were
1281 * successfully obtained, #GNUNET_SYSERR if not.
1284 primary_task (void *cls, int success)
1287 GNUNET_assert (stats != NULL);
1288 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1289 "Statistics request done, scheduling hostlist download\n");
1290 ti_check_download = GNUNET_SCHEDULER_add_now (&task_check, NULL);
1295 * We've received the previous delay value from statistics. Remember it.
1297 * @param cls NULL, unused
1298 * @param subsystem should be "hostlist", unused
1299 * @param name will be "milliseconds between hostlist downloads", unused
1300 * @param value previous delay value, in milliseconds (!)
1301 * @param is_persistent unused, will be #GNUNET_YES
1304 process_stat (void *cls,
1305 const char *subsystem,
1310 hostlist_delay.rel_value_us = value * 1000LL;
1311 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1312 "Initial time between hostlist downloads is %s\n",
1313 GNUNET_STRINGS_relative_time_to_string (hostlist_delay, GNUNET_YES));
1319 * Method to load persistent hostlist file during hostlist client startup
1322 load_hostlist_file ()
1327 struct Hostlist *hostlist;
1328 uint32_t times_used;
1329 uint32_t hellos_returned;
1334 struct GNUNET_BIO_ReadHandle *rh;
1338 GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE",
1341 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
1342 "hostlist", "HOSTLISTFILE");
1346 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1347 _("Loading saved hostlist entries from file `%s' \n"),
1349 if (GNUNET_NO == GNUNET_DISK_file_test (filename))
1351 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1352 _("Hostlist file `%s' does not exist\n"), filename);
1353 GNUNET_free (filename);
1357 rh = GNUNET_BIO_read_open (filename);
1360 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1361 _("Could not open file `%s' for reading to load hostlists: %s\n"),
1362 filename, STRERROR (errno));
1363 GNUNET_free (filename);
1368 while ((GNUNET_OK == GNUNET_BIO_read_string (rh, "url", &uri, MAX_URL_LEN)) &&
1369 (NULL != uri) && (GNUNET_OK == GNUNET_BIO_read_int32 (rh, ×_used))
1370 && (GNUNET_OK == GNUNET_BIO_read_int64 (rh, &quality)) &&
1371 (GNUNET_OK == GNUNET_BIO_read_int64 (rh, &last_used)) &&
1372 (GNUNET_OK == GNUNET_BIO_read_int64 (rh, &created)) &&
1373 (GNUNET_OK == GNUNET_BIO_read_int32 (rh, &hellos_returned)))
1375 hostlist = GNUNET_malloc (sizeof (struct Hostlist) + strlen (uri) + 1);
1376 hostlist->hello_count = hellos_returned;
1377 hostlist->hostlist_uri = (const char *) &hostlist[1];
1378 memcpy (&hostlist[1], uri, strlen (uri) + 1);
1379 hostlist->quality = quality;
1380 hostlist->time_creation.abs_value_us = created;
1381 hostlist->time_last_usage.abs_value_us = last_used;
1382 GNUNET_CONTAINER_DLL_insert (linked_list_head, linked_list_tail, hostlist);
1384 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1385 "Added hostlist entry eith URI `%s' \n",
1386 hostlist->hostlist_uri);
1390 if (counter >= MAX_NUMBER_HOSTLISTS)
1394 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1395 _("%u hostlist URIs loaded from file\n"),
1397 GNUNET_STATISTICS_set (stats,
1398 gettext_noop ("# hostlist URIs read from file"),
1399 counter, GNUNET_YES);
1400 GNUNET_STATISTICS_set (stats,
1401 gettext_noop ("# advertised hostlist URIs"),
1402 linked_list_size, GNUNET_NO);
1404 GNUNET_free_non_null (uri);
1406 (void) GNUNET_BIO_read_close (rh, &emsg);
1409 GNUNET_free (filename);
1414 * Method to save persistent hostlist file during hostlist client shutdown
1416 * @param shutdown set if called because of shutdown, entries in linked list will be destroyed
1419 save_hostlist_file (int shutdown)
1422 struct Hostlist *pos;
1423 struct GNUNET_BIO_WriteHandle *wh;
1428 GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE",
1431 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
1432 "hostlist", "HOSTLISTFILE");
1435 if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename))
1437 GNUNET_free (filename);
1440 wh = GNUNET_BIO_write_open (filename);
1443 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1445 ("Could not open file `%s' for writing to save hostlists: %s\n"),
1446 filename, STRERROR (errno));
1447 GNUNET_free (filename);
1450 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Writing %u hostlist URIs to `%s'\n"),
1451 linked_list_size, filename);
1452 /* add code to write hostlists to file using bio */
1455 while (NULL != (pos = linked_list_head))
1457 if (GNUNET_YES == shutdown)
1459 GNUNET_CONTAINER_DLL_remove (linked_list_head, linked_list_tail, pos);
1462 if (GNUNET_YES == ok)
1464 if ((GNUNET_OK != GNUNET_BIO_write_string (wh, pos->hostlist_uri)) ||
1465 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pos->times_used)) ||
1466 (GNUNET_OK != GNUNET_BIO_write_int64 (wh, pos->quality)) ||
1468 GNUNET_BIO_write_int64 (wh, pos->time_last_usage.abs_value_us)) ||
1470 GNUNET_BIO_write_int64 (wh, pos->time_creation.abs_value_us)) ||
1471 (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pos->hello_count)))
1473 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1474 _("Error writing hostlist URIs to file `%s'\n"), filename);
1479 if (GNUNET_YES == shutdown)
1482 if (counter >= MAX_NUMBER_HOSTLISTS)
1485 GNUNET_STATISTICS_set (stats,
1486 gettext_noop ("# hostlist URIs written to file"),
1487 counter, GNUNET_YES);
1489 if (GNUNET_OK != GNUNET_BIO_write_close (wh))
1490 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1491 _("Error writing hostlist URIs to file `%s'\n"), filename);
1492 GNUNET_free (filename);
1497 * Start downloading hostlists from hostlist servers as necessary.
1499 * @param c configuration to use
1500 * @param st statistics handle to use
1501 * @param ch[OUT] set to handler for CORE connect events
1502 * @param dh[OUT] set to handler for CORE disconnect events
1503 * @param msgh[OUT] set to handler for CORE advertisement messages
1504 * @param learn should we learn hostlist URLs from CORE
1505 * @return #GNUNET_OK on success
1508 GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
1509 struct GNUNET_STATISTICS_Handle *st,
1510 GNUNET_CORE_ConnectEventHandler *ch,
1511 GNUNET_CORE_DisconnectEventHandler *dh,
1512 GNUNET_CORE_MessageCallback *msgh,
1516 char *proxytype_str;
1519 GNUNET_assert (NULL != st);
1520 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
1523 return GNUNET_SYSERR;
1525 transport = GNUNET_TRANSPORT_connect (c, NULL, NULL, NULL, NULL, NULL);
1526 if (NULL == transport)
1528 curl_global_cleanup ();
1529 return GNUNET_SYSERR;
1534 /* Read proxy configuration */
1535 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
1536 "HOSTLIST", "PROXY", &proxy))
1538 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1539 "Found proxy host: `%s'\n",
1541 /* proxy username */
1542 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
1543 "HOSTLIST", "PROXY_USERNAME", &proxy_username))
1545 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1546 "Found proxy username name: `%s'\n",
1550 /* proxy password */
1551 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
1552 "HOSTLIST", "PROXY_PASSWORD", &proxy_password))
1554 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1555 "Found proxy password name: `%s'\n",
1560 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
1561 "HOSTLIST", "PROXY_TYPE", &proxytype_str))
1563 GNUNET_STRINGS_utf8_toupper (proxytype_str, proxytype_str);
1565 proxy_type = CURLPROXY_HTTP;
1566 if (0 == strcmp(proxytype_str, "HTTP"))
1567 proxy_type = CURLPROXY_HTTP;
1568 else if (0 == strcmp(proxytype_str, "HTTP_1_0"))
1569 proxy_type = CURLPROXY_HTTP_1_0;
1570 else if (0 == strcmp(proxytype_str, "SOCKS4"))
1571 proxy_type = CURLPROXY_SOCKS4;
1572 else if (0 == strcmp(proxytype_str, "SOCKS5"))
1573 proxy_type = CURLPROXY_SOCKS5;
1574 else if (0 == strcmp(proxytype_str, "SOCKS4A"))
1575 proxy_type = CURLPROXY_SOCKS4A;
1576 else if (0 == strcmp(proxytype_str, "SOCKS5_HOSTNAME"))
1577 proxy_type = CURLPROXY_SOCKS5_HOSTNAME ;
1580 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1581 _("Invalid proxy type: `%s', disabling proxy! Check configuration!\n"),
1583 GNUNET_free (proxytype_str);
1585 GNUNET_free (proxy);
1587 GNUNET_free_non_null (proxy_username);
1588 proxy_username = NULL;
1589 GNUNET_free_non_null (proxy_password);
1590 proxy_password = NULL;
1592 return GNUNET_SYSERR;
1595 GNUNET_free_non_null (proxytype_str);
1598 stat_learning = learn;
1599 *ch = &handler_connect;
1600 *dh = &handler_disconnect;
1601 linked_list_head = NULL;
1602 linked_list_tail = NULL;
1603 stat_use_bootstrap = GNUNET_YES;
1604 stat_testing_hostlist = GNUNET_NO;
1605 stat_testing_allowed = GNUNET_YES;
1607 if (GNUNET_YES == stat_learning)
1609 *msgh = &handler_advertisement;
1610 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1611 _("Learning is enabled on this peer\n"));
1612 load_hostlist_file ();
1613 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1614 "Hostlists will be saved to file again in %s\n",
1615 GNUNET_STRINGS_relative_time_to_string (SAVING_INTERVAL, GNUNET_YES));
1617 GNUNET_SCHEDULER_add_delayed (SAVING_INTERVAL, &task_hostlist_saving,
1622 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1623 _("Learning is not enabled on this peer\n"));
1626 GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST",
1627 "HOSTLISTFILE", &filename))
1629 if (GNUNET_YES == GNUNET_DISK_file_test (filename))
1631 result = remove (filename);
1633 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1635 ("Since learning is not enabled on this peer, hostlist file `%s' was removed\n"),
1638 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1639 _("Hostlist file `%s' could not be removed\n"), filename);
1642 GNUNET_free (filename);
1644 sget = GNUNET_STATISTICS_get (stats, "hostlist",
1646 ("# milliseconds between hostlist downloads"),
1647 GNUNET_TIME_UNIT_MINUTES, &primary_task, &process_stat,
1654 * Stop downloading hostlists from hostlist servers as necessary.
1657 GNUNET_HOSTLIST_client_stop ()
1659 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostlist client shutdown\n");
1662 GNUNET_STATISTICS_get_cancel (sget);
1666 if (GNUNET_YES == stat_learning)
1667 save_hostlist_file (GNUNET_YES);
1668 if (ti_saving_task != GNUNET_SCHEDULER_NO_TASK)
1670 GNUNET_SCHEDULER_cancel (ti_saving_task);
1671 ti_saving_task = GNUNET_SCHEDULER_NO_TASK;
1674 if (ti_download_dispatcher_task != GNUNET_SCHEDULER_NO_TASK)
1676 GNUNET_SCHEDULER_cancel (ti_download_dispatcher_task);
1677 ti_download_dispatcher_task = GNUNET_SCHEDULER_NO_TASK;
1679 if (ti_testing_intervall_task != GNUNET_SCHEDULER_NO_TASK)
1681 GNUNET_SCHEDULER_cancel (ti_testing_intervall_task);
1682 ti_testing_intervall_task = GNUNET_SCHEDULER_NO_TASK;
1684 if (ti_download != GNUNET_SCHEDULER_NO_TASK)
1686 GNUNET_SCHEDULER_cancel (ti_download);
1687 ti_download = GNUNET_SCHEDULER_NO_TASK;
1689 if (ti_check_download != GNUNET_SCHEDULER_NO_TASK)
1691 GNUNET_SCHEDULER_cancel (ti_check_download);
1692 ti_check_download = GNUNET_SCHEDULER_NO_TASK;
1693 curl_global_cleanup ();
1695 if (NULL != transport)
1697 GNUNET_TRANSPORT_disconnect (transport);
1700 GNUNET_free_non_null (proxy);
1702 GNUNET_free_non_null (proxy_username);
1703 proxy_username = NULL;
1704 GNUNET_free_non_null (proxy_password);
1705 proxy_password = NULL;
1710 /* end of gnunet-daemon-hostlist_client.c */