41 #define MIN_CONNECTIONS 4 46 #define MAX_NUMBER_HOSTLISTS 30 51 #define SAVING_INTERVAL \ 52 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30) 57 #define TESTING_INTERVAL \ 58 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) 63 #define WAITING_INTERVAL \ 64 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) 73 #define HOSTLIST_INITIAL 10000 78 #define HOSTLIST_FAILED_DOWNLOAD 100 83 #define HOSTLIST_SUCCESSFUL_DOWNLOAD 100 88 #define HOSTLIST_SUCCESSFUL_HELLO 1 327 const char *cbuf = ptr;
334 total = size * nmemb;
343 "# bytes downloaded from hostlist servers"),
360 msize = ntohs (msg->
size);
365 gettext_noop (
"# invalid HELLOs downloaded from hostlist servers"),
369 _ (
"Invalid `%s' message received from hostlist at `%s'\n"),
376 if (download_pos < msize)
384 "Received valid `%s' message from hostlist server.\n",
388 gettext_noop (
"# valid HELLOs downloaded from hostlist servers"),
402 gettext_noop (
"# invalid HELLOs downloaded from hostlist servers"),
406 _ (
"Invalid `%s' message received from hostlist at `%s'\n"),
413 memmove (download_buffer, &download_buffer[msize], download_pos - msize);
414 download_pos -= msize;
445 if (strlen (servers) > 0)
448 pos = strlen (servers) - 1;
451 if (servers[pos] ==
' ')
466 pos = strlen (servers) - 1;
469 if (servers[pos] ==
' ')
495 unsigned int counter;
501 "Using preconfigured bootstrap server\n");
502 current_hostlist = NULL;
509 "Testing new advertised hostlist if it is obtainable\n");
517 "Using preconfigured bootstrap server\n");
518 current_hostlist = NULL;
525 while (counter < index)
531 "Using learned hostlist `%s'\n",
533 current_hostlist = pos;
538 #define CURL_EASY_SETOPT(c, a, b) \ 541 ret = curl_easy_setopt (c, a, b); \ 542 if (CURLE_OK != ret) \ 543 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \ 544 _ ("%s failed at %s:%d: `%s'\n"), \ 545 "curl_easy_setopt", \ 548 curl_easy_strerror (ret)); \ 571 static uint64_t temp;
572 static uint64_t maxv;
635 pos = linked_list_head->
next;
663 "Removing hostlist with URI `%s' which has the worst quality of all (%llu)\n",
665 (
unsigned long long) lowest_quality->
quality);
696 "Updating hostlist statics for URI `%s'\n",
719 current_hostlist = NULL;
752 "Advertised hostlist with URI `%s' could not be downloaded. Advertised URI gets dismissed.\n"),
760 if (NULL != hostlist_to_test)
763 hostlist_to_test = NULL;
768 mret = curl_multi_remove_handle (
multi,
curl);
769 if (mret != CURLM_OK)
772 _ (
"%s failed at %s:%d: `%s'\n"),
773 "curl_multi_remove_handle",
776 curl_multi_strerror (mret));
778 mret = curl_multi_cleanup (
multi);
779 if (mret != CURLM_OK)
781 _ (
"%s failed at %s:%d: `%s'\n"),
782 "curl_multi_cleanup",
785 curl_multi_strerror (mret));
790 curl_easy_cleanup (
curl);
832 mret = curl_multi_fdset (
multi, &rs, &ws, &es, &max);
833 if (mret != CURLM_OK)
836 _ (
"%s failed at %s:%d: `%s'\n"),
840 curl_multi_strerror (mret));
844 mret = curl_multi_timeout (
multi, &timeout);
845 if (mret != CURLM_OK)
848 _ (
"%s failed at %s:%d: `%s'\n"),
849 "curl_multi_timeout",
852 curl_multi_strerror (mret));
864 "Scheduling task for hostlist download using cURL\n");
893 _ (
"Timeout trying to download hostlist from `%s'\n"),
900 "Ready for processing hostlist client request\n");
908 "Download limit of %u bytes exceeded, stopping download\n"),
913 mret = curl_multi_perform (
multi, &running);
918 msg = curl_multi_info_read (
multi, &running);
925 if ((msg->data.result != CURLE_OK) &&
926 (msg->data.result != CURLE_GOT_NOTHING))
928 _ (
"Download of hostlist from `%s' failed: `%s'\n"),
930 curl_easy_strerror (msg->data.result));
934 _ (
"Download of hostlist `%s' completed.\n"),
942 _ (
"Adding successfully tested hostlist `%s' datastore.\n"),
945 hostlist_to_test = NULL;
956 while ((running > 0));
959 while (mret == CURLM_CALL_MULTI_PERFORM);
961 if (mret != CURLM_OK)
964 _ (
"%s failed at %s:%d: `%s'\n"),
965 "curl_multi_perform",
968 curl_multi_strerror (mret));
989 curl = curl_easy_init ();
998 _ (
"Bootstrapping using hostlist at `%s'.\n"),
1022 if (ret != CURLE_OK)
1028 if (ret != CURLE_OK)
1035 CURLOPT_REDIR_PROTOCOLS,
1036 CURLPROTO_HTTP | CURLPROTO_HTTPS);
1041 if (ret != CURLE_OK)
1055 multi = curl_multi_init ();
1062 mret = curl_multi_add_handle (
multi,
curl);
1063 if (mret != CURLM_OK)
1066 _ (
"%s failed at %s:%d: `%s'\n"),
1067 "curl_multi_add_handle",
1070 curl_multi_strerror (mret));
1071 mret = curl_multi_cleanup (
multi);
1072 if (mret != CURLM_OK)
1074 _ (
"%s failed at %s:%d: `%s'\n"),
1075 "curl_multi_cleanup",
1078 curl_multi_strerror (mret));
1091 ti_download_dispatcher_task = NULL;
1101 "Download in progess, have to wait...\n");
1102 ti_download_dispatcher_task =
1121 ti_check_download = NULL;
1124 curl_global_cleanup ();
1128 (NULL == ti_download_dispatcher_task))
1129 ti_download_dispatcher_task =
1144 "# milliseconds between hostlist downloads"),
1154 _ (
"Have %u/%u connections. Will consider downloading hostlist in %s\n"),
1170 ti_testing_intervall_task = NULL;
1173 "Testing new hostlist advertisements is allowed again\n");
1185 ti_saving_task = NULL;
1189 "Hostlists will be saved to file again in %s\n",
1250 uri_size = strlen (uri) + 1;
1252 "Hostlist client recieved advertisement containing URI `%s'\n",
1264 "Currently not accepting new advertisements: interval between to advertisements is not reached\n");
1271 "Currently not accepting new advertisements: we are already testing a hostlist\n");
1280 hostlist_to_test = hostlist;
1284 ti_testing_intervall_task =
1290 "Testing new hostlist advertisements is locked for the next %s\n",
1294 ti_download_dispatcher_task =
1310 if (NULL != ti_check_download)
1313 ti_check_download = NULL;
1318 "Statistics request done, scheduling hostlist download\n");
1358 "Initial time between hostlist downloads is %s\n",
1376 uint32_t hellos_returned;
1396 _ (
"Loading saved hostlist entries from file `%s' \n"),
1401 _ (
"Hostlist file `%s' does not exist\n"),
1412 "Could not open file `%s' for reading to load hostlists: %s\n"),
1426 (int32_t *) &hellos_returned),
1443 "Added hostlist entry eith URI `%s' \n",
1453 _ (
"%u hostlist URIs loaded from file\n"),
1507 "Could not open file `%s' for writing to save hostlists: %s\n"),
1514 _ (
"Writing %u hostlist URIs to `%s'\n"),
1520 while (NULL != (pos = linked_list_head))
1547 _ (
"Error writing hostlist URIs to file `%s'\n"),
1566 _ (
"Error writing hostlist URIs to file `%s'\n"),
1592 char *proxytype_str;
1596 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
1617 "Found proxy username name: `%s'\n",
1628 "Found proxy password name: `%s'\n",
1640 if (0 == strcmp (proxytype_str,
"HTTP"))
1642 else if (0 == strcmp (proxytype_str,
"HTTP_1_0"))
1644 else if (0 == strcmp (proxytype_str,
"SOCKS4"))
1646 else if (0 == strcmp (proxytype_str,
"SOCKS5"))
1648 else if (0 == strcmp (proxytype_str,
"SOCKS4A"))
1650 else if (0 == strcmp (proxytype_str,
"SOCKS5_HOSTNAME"))
1657 "Invalid proxy type: `%s', disabling proxy! Check configuration!\n"),
1676 linked_list_head = NULL;
1677 linked_list_tail = NULL;
1686 _ (
"Learning is enabled on this peer\n"));
1689 "Hostlists will be saved to file again in %s\n",
1699 _ (
"Learning is not enabled on this peer\n"));
1713 "Since learning is not enabled on this peer, hostlist file `%s' was removed\n"),
1724 "Loading stats value on hostlist download frequency\n");
1728 "# milliseconds between hostlist downloads"),
1735 "Statistics request failed, scheduling hostlist download\n");
1763 if (NULL != ti_saving_task)
1766 ti_saving_task = NULL;
1768 if (NULL != ti_download_dispatcher_task)
1771 ti_download_dispatcher_task = NULL;
1773 if (NULL != ti_testing_intervall_task)
1776 ti_testing_intervall_task = NULL;
1778 if (NULL != ti_download)
1785 if (NULL != ti_check_download)
1788 ti_check_download = NULL;
1789 curl_global_cleanup ();
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Structure specifying a writing operation on an IO handle.
struct GNUNET_TIME_Absolute time_last_usage
Last time the hostlist was obtained.
common internal definitions for hostlist daemon
#define GNUNET_BIO_read_spec_end()
End of specifications marker.
static struct GNUNET_CADET_Channel * ch
Channel handle.
#define MAX_URL_LEN
How long can hostlist URLs be?
#define MAX_BYTES_PER_HOSTLISTS
How many bytes do we download at most from a hostlist server?
Handle to the peerinfo service.
A HELLO message is used to exchange information about transports with other peers.
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
struct GNUNET_MessageHeader * msg
#define GNUNET_TIME_UNIT_HOURS
One hour.
uint64_t rel_value_us
The actual value.
static uint64_t checked_add(uint64_t val1, uint64_t val2)
Add val2 to val1 with overflow check.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_HOSTLIST_client_stop()
Stop downloading hostlists from hostlist servers as necessary.
#define TESTING_INTERVAL
Time interval between two hostlist tests.
struct GNUNET_TIME_Absolute time_creation
Time the hostlist advertisement was recieved and the entry was created.
uint64_t quality
Value describing the quality of the hostlist, the bigger the better but (should) never < 0 used for d...
static void task_download(void *cls)
Task that is run when we are ready to receive more data from the hostlist server. ...
static unsigned int stat_connection_count
Number of active connections (according to core service).
struct GNUNET_PEERINFO_Handle * GNUNET_PEERINFO_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the peerinfo service.
#define HOSTLIST_INITIAL
Defines concerning the hostlist quality metric.
#define WAITING_INTERVAL
Time interval for download dispatcher before a download is re-scheduled.
struct GNUNET_BIO_ReadHandle * GNUNET_BIO_read_open_file(const char *fn)
Open a file for reading.
library to make it easy to download JSON replies over HTTP
static int stat_learning
Set if we are allowed to learn new hostlists and use them.
static struct GNUNET_TIME_Absolute end_time
At what time MUST the current hostlist request be done?
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
static struct GNUNET_SCHEDULER_Task * ti_download_dispatcher_task
ID of the task called to initiate a download.
static struct GNUNET_SCHEDULER_Task * ti_saving_task
ID of the task saving the hostlsit in a regular intervall.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void load_hostlist_file()
Method to load persistent hostlist file during hostlist client startup.
void(* GNUNET_CORE_DisconnectEventHandler)(void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls)
Method called whenever a peer disconnects.
#define GNUNET_TIME_UNIT_SECONDS
One second.
static void handler_advertisement(const char *uri)
Method called whenever an advertisement message arrives.
void GNUNET_STATISTICS_get_cancel(struct GNUNET_STATISTICS_GetHandle *gh)
Cancel a GNUNET_STATISTICS_get request.
static struct GNUNET_SCHEDULER_Task * ti_download
ID of the task downloading the hostlist.
static int ok
Return value from 'main' (0 == success)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static curl_proxytype proxy_type
Proxy type we are using (can be NULL).
static int ret
Return value of the commandline.
int GNUNET_BIO_read_spec_commit(struct GNUNET_BIO_ReadHandle *h, struct GNUNET_BIO_ReadSpec *rs)
Execute the read specifications in order.
static int process_stat(void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent)
We've received the previous delay value from statistics.
static void * handler_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a given peer connects.
Linked list of things we still need to do.
static size_t download_pos
Number of bytes valid in 'download_buffer'.
static void primary_task(void *cls, int success)
Continuation called by the statistics code once we go the stat.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
struct Hostlist * next
next entry, used to manage entries in a double linked list
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_int64(const char *what, int64_t *i)
Create the specification to read an (u)int64_t.
static void update_hostlist()
Method updating hostlist statistics.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static char * proxy_username
Proxy username we are using (can be NULL).
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
static char * current_url
Current URL that we are using.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define HOSTLIST_SUCCESSFUL_HELLO
Value added for each valid HELLO recived during a hostlist download.
uint64_t abs_value_us
The actual value.
static char * proxy
Proxy hostname or ip we are using (can be NULL).
int GNUNET_BIO_read_close(struct GNUNET_BIO_ReadHandle *h, char **emsg)
Close an open handle.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
void GNUNET_NETWORK_fdset_copy_native(struct GNUNET_NETWORK_FDSet *to, const fd_set *from, int nfds)
Copy a native fd set into the GNUnet representation.
#define CURL_EASY_SETOPT(c, a, b)
static char * proxy_password
Proxy password we are using (can be NULL).
void *(* GNUNET_CORE_ConnectEventHandler)(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a given peer connects.
#define GNUNET_BIO_write_spec_end()
End of specifications marker.
static void stat_timeout_task(void *cls)
Continuation called by the statistics code once we go the stat.
uint32_t hello_count
Number of HELLO messages obtained during last download.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
void GNUNET_NETWORK_fdset_destroy(struct GNUNET_NETWORK_FDSet *fds)
Releases the associated memory of an fd set.
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_string(const char *what, const char *s)
Create the specification to write a 0-terminated string.
static void insert_hostlist()
Method to insert a hostlist into the datastore.
void(* GNUNET_HOSTLIST_UriHandler)(const char *uri)
Function that handles an advertised URI.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
struct GNUNET_NETWORK_FDSet * GNUNET_NETWORK_fdset_create(void)
Creates an fd set.
void GNUNET_STRINGS_utf8_toupper(const char *input, char *output)
Convert the utf-8 input string to upper case.
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static char * value
Value of the record to add/remove.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
static int stat_testing_allowed
Value controlling if a hostlist testing is allowed at the moment.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
static CURLM * multi
Current multi-CURL handle.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
static int once
Global to mark if we've run the initialization.
static unsigned int stat_download_successful
Value saying if hostlist download was successful.
collection of IO descriptors
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_select(enum GNUNET_SCHEDULER_Priority prio, struct GNUNET_TIME_Relative delay, const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when any of the specified file descriptor set...
static int result
Global testing status.
static int linked_list_contains(const char *uri)
Method to check if a URI is in hostlist linked list.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
const char * hostlist_uri
URI where hostlist can be obtained.
static unsigned int stat_use_bootstrap
Value saying if a preconfigured bootstrap server is used.
Structure specifying a reading operation on an IO handle.
static void task_download_dispatcher(void *cls)
static int stat_bogus_url
Set to GNUNET_YES if the current URL had some problems.
struct Hostlist * prev
previous entry, used to manage entries in a double linked list
static struct Hostlist * linked_list_head
Head of the linked list used to store hostlists.
Handle for buffered writing.
static size_t callback_download(void *ptr, size_t size, size_t nmemb, void *ctx)
Process downloaded bits by calling callback on each HELLO.
static struct Hostlist * linked_list_tail
Tail of the linked list used to store hostlists.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
static void handler_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Method called whenever a given peer disconnects.
struct GNUNET_MQ_Envelope * GNUNET_PEERINFO_add_peer(struct GNUNET_PEERINFO_Handle *h, const struct GNUNET_HELLO_Message *hello, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Add a host to the persistent list.
static struct GNUNET_SCHEDULER_Task * ti_testing_intervall_task
ID of the task controlling the locking between two hostlist tests.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
int GNUNET_BIO_read_string(struct GNUNET_BIO_ReadHandle *h, const char *what, char **result, size_t max_length)
Read 0-terminated string.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
static void task_check(void *cls)
Task that checks if we should try to download a hostlist.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
static void download_hostlist()
Main function that will download a hostlist and process its data.
static struct Hostlist * current_hostlist
Current hostlist used for downloading.
static CURL * curl
Current CURL handle.
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open_file(const char *fn)
Open a file for writing.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_min(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the minimum of two relative time values.
static char * get_bootstrap_server()
Obtain a hostlist URL that we should use.
static unsigned int linked_list_size
Size of the linke list used to store hostlists.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static unsigned int size
Size of the "table".
#define HOSTLIST_SUCCESSFUL_DOWNLOAD
Value added each time a hostlist download is successful.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h, char **emsg)
Close an IO handle.
int GNUNET_HOSTLIST_client_start(const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_STATISTICS_Handle *st, GNUNET_CORE_ConnectEventHandler *ch, GNUNET_CORE_DisconnectEventHandler *dh, GNUNET_HOSTLIST_UriHandler *msgh, int learn)
Start downloading hostlists from hostlist servers as necessary.
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
static unsigned int stat_hellos_obtained
Value saying how many valid HELLO messages were obtained during download.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_int32(const char *what, int32_t *i)
Create the specification to read an (u)int32_t.
Handle to a message queue.
static void download_prepare()
Ask CURL for the select set and then schedule the receiving task with the scheduler.
static void save_hostlist_file(int shutdown)
Method to save hostlist to a file during hostlist client shutdown.
static void clean_up()
Clean up the state from the task that downloaded the hostlist and schedule the next task...
static void task_testing_intervall_reset(void *cls)
This tasks sets hostlist testing to allowed after intervall between to testings is reached...
static struct GNUNET_STATISTICS_GetHandle * sget
Handle for our statistics GET operation.
The identity of the host (wraps the signing key of the peer).
int GNUNET_BIO_write_spec_commit(struct GNUNET_BIO_WriteHandle *h, struct GNUNET_BIO_WriteSpec *ws)
Execute the write specifications in order.
struct GNUNET_STATISTICS_GetHandle * GNUNET_STATISTICS_get(struct GNUNET_STATISTICS_Handle *handle, const char *subsystem, const char *name, GNUNET_STATISTICS_Callback cont, GNUNET_STATISTICS_Iterator proc, void *cls)
Get statistic from the peer.
static struct GNUNET_SCHEDULER_Task * ti_check_download
ID of the task, checking if hostlist download should take plate.
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_int32(const char *what, int32_t *i)
Create the specification to write an (u)int32_t.
uint32_t times_used
Number of times the hostlist was successfully obtained.
struct GNUNET_MQ_Handle * mq
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
#define SAVING_INTERVAL
Time interval hostlists are saved to disk.
static uint32_t stat_bytes_downloaded
How many bytes did we download from the current hostlist URL?
static char * download_get_url()
Method deciding if a preconfigured or advertisied hostlist is used on a 50:50 ratio.
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
void GNUNET_PEERINFO_disconnect(struct GNUNET_PEERINFO_Handle *h)
Disconnect from the peerinfo service.
static void task_hostlist_saving(void *cls)
Task that writes hostlist entries to a file on a regular base.
static struct Hostlist * linked_list_get_lowest_quality()
Method returning the hostlist element with the lowest quality in the datastore.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
#define MAX_NUMBER_HOSTLISTS
Maximum number of hostlist that are saved.
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_int64(const char *what, int64_t *i)
Create the specification to write an (u)int64_t.
Time for absolute times used by GNUnet, in microseconds.
static int stat_download_in_progress
Value controlling if a hostlist download is running at the moment.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
#define HOSTLIST_FAILED_DOWNLOAD
Value subtracted each time a hostlist download fails.
A single hostlist obtained by hostlist advertisements.
#define MIN_CONNECTIONS
Number of connections that we must have to NOT download hostlists anymore.
Run with the default priority (normal P2P operations).
static uint64_t checked_sub(uint64_t val1, uint64_t val2)
Subtract val2 from val1 with underflow check.
static struct GNUNET_SCHEDULER_Task * st
The shutdown task.
static struct GNUNET_STATISTICS_Handle * stats
Statistics handle.
static int stat_testing_hostlist
Value controlling if a hostlist is tested at the moment.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory)...
#define GNUNET_malloc(size)
Wrapper around malloc.
Handle for buffered reading.
static struct Hostlist * hostlist_to_test
Head of the linked list used to store hostlists.
static struct GNUNET_TIME_Relative hostlist_delay
Amount of time we wait between hostlist downloads.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.