hostlist support. More...
#include "platform.h"
#include "gnunet-daemon-hostlist_client.h"
#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_peerstore_service.h"
#include "gnunet-daemon-hostlist.h"
#include "gnunet_curl_lib.h"
Go to the source code of this file.
Data Structures | |
struct | Hostlist |
A single hostlist obtained by hostlist advertisements. More... | |
struct | StoreHelloEntry |
Context for a add hello uri request. More... | |
Macros | |
#define | MIN_CONNECTIONS 4 |
Number of connections that we must have to NOT download hostlists anymore. More... | |
#define | MAX_NUMBER_HOSTLISTS 30 |
Maximum number of hostlist that are saved. More... | |
#define | SAVING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30) |
Time interval hostlists are saved to disk. More... | |
#define | TESTING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) |
Time interval between two hostlist tests. More... | |
#define | WAITING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
Time interval for download dispatcher before a download is re-scheduled. More... | |
#define | HOSTLIST_INITIAL 10000 |
Defines concerning the hostlist quality metric. More... | |
#define | HOSTLIST_FAILED_DOWNLOAD 100 |
Value subtracted each time a hostlist download fails. More... | |
#define | HOSTLIST_SUCCESSFUL_DOWNLOAD 100 |
Value added each time a hostlist download is successful. More... | |
#define | HOSTLIST_SUCCESSFUL_HELLO 1 |
Value added for each valid HELLO received during a hostlist download. More... | |
#define | CURL_EASY_SETOPT(c, a, b) |
Functions | |
static void | shc_cont (void *cls, int success) |
static size_t | callback_download (void *ptr, size_t size, size_t nmemb, void *ctx) |
Process downloaded bits by calling callback on each HELLO. More... | |
static char * | get_bootstrap_server () |
Obtain a hostlist URL that we should use. More... | |
static char * | download_get_url () |
Method deciding if a preconfigured or advertisied hostlist is used on a 50:50 ratio. More... | |
static void | save_hostlist_file (int shutdown) |
Method to save hostlist to a file during hostlist client shutdown. More... | |
static uint64_t | checked_add (uint64_t val1, uint64_t val2) |
Add val2 to val1 with overflow check. More... | |
static uint64_t | checked_sub (uint64_t val1, uint64_t val2) |
Subtract val2 from val1 with underflow check. More... | |
static int | linked_list_contains (const char *uri) |
Method to check if a URI is in hostlist linked list. More... | |
static struct Hostlist * | linked_list_get_lowest_quality () |
Method returning the hostlist element with the lowest quality in the datastore. More... | |
static void | insert_hostlist () |
Method to insert a hostlist into the datastore. More... | |
static void | update_hostlist () |
Method updating hostlist statistics. More... | |
static void | clean_up () |
Clean up the state from the task that downloaded the hostlist and schedule the next task. More... | |
static void | task_download (void *cls) |
Task that is run when we are ready to receive more data from the hostlist server. More... | |
static void | download_prepare () |
Ask CURL for the select set and then schedule the receiving task with the scheduler. More... | |
static void | download_hostlist () |
Main function that will download a hostlist and process its data. More... | |
static void | task_download_dispatcher (void *cls) |
static void | task_check (void *cls) |
Task that checks if we should try to download a hostlist. More... | |
static void | task_testing_intervall_reset (void *cls) |
This tasks sets hostlist testing to allowed after interval between to testings is reached. More... | |
static void | task_hostlist_saving (void *cls) |
Task that writes hostlist entries to a file on a regular base. More... | |
static void * | handler_connect (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq) |
Method called whenever a given peer connects. More... | |
static void | handler_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls) |
Method called whenever a given peer disconnects. More... | |
static void | handler_advertisement (const char *uri) |
Method called whenever an advertisement message arrives. More... | |
static void | primary_task (void *cls, int success) |
Continuation called by the statistics code once we go the stat. More... | |
static void | stat_timeout_task (void *cls) |
Continuation called by the statistics code once we go the stat. More... | |
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. More... | |
static void | load_hostlist_file () |
Method to load persistent hostlist file during hostlist client startup. More... | |
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. More... | |
void | GNUNET_HOSTLIST_client_stop () |
Stop downloading hostlists from hostlist servers as necessary. More... | |
Variables | |
static const struct GNUNET_CONFIGURATION_Handle * | cfg |
Our configuration. More... | |
static struct GNUNET_STATISTICS_Handle * | stats |
Statistics handle. More... | |
static char * | proxy |
Proxy hostname or ip we are using (can be NULL). More... | |
static char * | proxy_username |
Proxy username we are using (can be NULL). More... | |
static char * | proxy_password |
Proxy password we are using (can be NULL). More... | |
static curl_proxytype | proxy_type |
Proxy type we are using (can be NULL). More... | |
static size_t | download_pos |
Number of bytes valid in 'download_buffer'. More... | |
static char * | current_url |
Current URL that we are using. More... | |
static CURL * | curl |
Current CURL handle. More... | |
static CURLM * | multi |
Current multi-CURL handle. More... | |
static uint32_t | stat_bytes_downloaded |
How many bytes did we download from the current hostlist URL? More... | |
static struct GNUNET_TIME_Relative | hostlist_delay |
Amount of time we wait between hostlist downloads. More... | |
static struct GNUNET_SCHEDULER_Task * | ti_check_download |
ID of the task, checking if hostlist download should take plate. More... | |
static struct GNUNET_SCHEDULER_Task * | ti_download |
ID of the task downloading the hostlist. More... | |
static struct GNUNET_SCHEDULER_Task * | ti_saving_task |
ID of the task saving the hostlsit in a regular interval. More... | |
static struct GNUNET_SCHEDULER_Task * | ti_download_dispatcher_task |
ID of the task called to initiate a download. More... | |
static struct GNUNET_SCHEDULER_Task * | ti_testing_intervall_task |
ID of the task controlling the locking between two hostlist tests. More... | |
static struct GNUNET_TIME_Absolute | end_time |
At what time MUST the current hostlist request be done? More... | |
static struct StoreHelloEntry * | she_head |
Head of the linkd list to store the store context for hellos. More... | |
static struct StoreHelloEntry * | she_tail |
Tail of the linkd list to store the store context for hellos. More... | |
static struct Hostlist * | linked_list_head |
Head of the linked list used to store hostlists. More... | |
static struct Hostlist * | linked_list_tail |
Tail of the linked list used to store hostlists. More... | |
static struct Hostlist * | current_hostlist |
Current hostlist used for downloading. More... | |
static unsigned int | linked_list_size |
Size of the linked list used to store hostlists. More... | |
static struct Hostlist * | hostlist_to_test |
Head of the linked list used to store hostlists. More... | |
static struct GNUNET_STATISTICS_GetHandle * | sget |
Handle for our statistics GET operation. More... | |
static int | stat_bogus_url |
Set to GNUNET_YES if the current URL had some problems. More... | |
static int | stat_testing_hostlist |
Value controlling if a hostlist is tested at the moment. More... | |
static int | stat_testing_allowed |
Value controlling if a hostlist testing is allowed at the moment. More... | |
static int | stat_download_in_progress |
Value controlling if a hostlist download is running at the moment. More... | |
static unsigned int | stat_use_bootstrap |
Value saying if a preconfigured bootstrap server is used. More... | |
static int | stat_learning |
Set if we are allowed to learn new hostlists and use them. More... | |
static unsigned int | stat_download_successful |
Value saying if hostlist download was successful. More... | |
static unsigned int | stat_hellos_obtained |
Value saying how many valid HELLO messages were obtained during download. More... | |
static unsigned int | stat_connection_count |
Number of active connections (according to core service). More... | |
static struct GNUNET_PEERSTORE_Handle * | peerstore |
Handle to the PEERSTORE service. More... | |
#define MIN_CONNECTIONS 4 |
Number of connections that we must have to NOT download hostlists anymore.
Definition at line 40 of file gnunet-daemon-hostlist_client.c.
#define MAX_NUMBER_HOSTLISTS 30 |
Maximum number of hostlist that are saved.
Definition at line 45 of file gnunet-daemon-hostlist_client.c.
#define SAVING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30) |
Time interval hostlists are saved to disk.
Definition at line 50 of file gnunet-daemon-hostlist_client.c.
#define TESTING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) |
Time interval between two hostlist tests.
Definition at line 56 of file gnunet-daemon-hostlist_client.c.
#define WAITING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
Time interval for download dispatcher before a download is re-scheduled.
Definition at line 62 of file gnunet-daemon-hostlist_client.c.
#define HOSTLIST_INITIAL 10000 |
Defines concerning the hostlist quality metric.
Initial quality of a new created hostlist
Definition at line 72 of file gnunet-daemon-hostlist_client.c.
#define HOSTLIST_FAILED_DOWNLOAD 100 |
Value subtracted each time a hostlist download fails.
Definition at line 77 of file gnunet-daemon-hostlist_client.c.
#define HOSTLIST_SUCCESSFUL_DOWNLOAD 100 |
Value added each time a hostlist download is successful.
Definition at line 82 of file gnunet-daemon-hostlist_client.c.
#define HOSTLIST_SUCCESSFUL_HELLO 1 |
Value added for each valid HELLO received during a hostlist download.
Definition at line 87 of file gnunet-daemon-hostlist_client.c.
#define CURL_EASY_SETOPT | ( | c, | |
a, | |||
b | |||
) |
Definition at line 573 of file gnunet-daemon-hostlist_client.c.
|
static |
Definition at line 344 of file gnunet-daemon-hostlist_client.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_YES, StoreHelloEntry::sc, she_head, and she_tail.
Referenced by callback_download().
|
static |
Process downloaded bits by calling callback on each HELLO.
ptr | buffer with downloaded data |
size | size of a record |
nmemb | number of records downloaded |
ctx | unused |
Definition at line 370 of file gnunet-daemon-hostlist_client.c.
References _, current_url, download_pos, gettext_noop, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MIN, GNUNET_new, GNUNET_NO, GNUNET_PEERSTORE_hello_add(), GNUNET_STATISTICS_update(), msg, peerstore, StoreHelloEntry::sc, shc_cont(), she_head, she_tail, GNUNET_MessageHeader::size, size, stat_bogus_url, stat_bytes_downloaded, stat_hellos_obtained, and stats.
Referenced by download_hostlist().
|
static |
Obtain a hostlist URL that we should use.
Definition at line 461 of file gnunet-daemon-hostlist_client.c.
References cfg, GNUNET_CONFIGURATION_get_value_string(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_config_missing(), GNUNET_OK, GNUNET_strdup, and ret.
Referenced by download_get_url().
|
static |
Method deciding if a preconfigured or advertisied hostlist is used on a 50:50 ratio.
Definition at line 527 of file gnunet-daemon-hostlist_client.c.
References current_hostlist, get_bootstrap_server(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_strdup, GNUNET_YES, hostlist_to_test, Hostlist::hostlist_uri, linked_list_head, linked_list_size, Hostlist::next, stat_learning, stat_testing_hostlist, and stat_use_bootstrap.
Referenced by download_hostlist().
|
static |
Method to save hostlist to a file during hostlist client shutdown.
Method to save persistent hostlist file during hostlist client shutdown.
shutdown | set if called because of shutdown, entries in linked list will be destroyed |
Definition at line 1543 of file gnunet-daemon-hostlist_client.c.
References _, GNUNET_TIME_Absolute::abs_value_us, cfg, filename, gettext_noop, GNUNET_BIO_write_close(), GNUNET_BIO_write_open_file(), GNUNET_BIO_write_spec_commit(), GNUNET_BIO_write_spec_end, GNUNET_BIO_write_spec_int32(), GNUNET_BIO_write_spec_int64(), GNUNET_BIO_write_spec_string(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONTAINER_DLL_remove, GNUNET_DISK_directory_create_for_file(), GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_YES, Hostlist::hello_count, Hostlist::hostlist_uri, linked_list_head, linked_list_size, linked_list_tail, MAX_NUMBER_HOSTLISTS, Hostlist::quality, stats, Hostlist::time_creation, Hostlist::time_last_usage, Hostlist::times_used, and GNUNET_BIO_WriteSpec::wh.
Referenced by GNUNET_HOSTLIST_client_stop(), and task_hostlist_saving().
|
static |
Add val2 to val1 with overflow check.
val1 | value 1 |
val2 | value 2 |
Definition at line 604 of file gnunet-daemon-hostlist_client.c.
Referenced by update_hostlist().
|
static |
Subtract val2 from val1 with underflow check.
val1 | value 1 |
val2 | value 2 |
Definition at line 627 of file gnunet-daemon-hostlist_client.c.
Referenced by update_hostlist().
|
static |
Method to check if a URI is in hostlist linked list.
uri | uri to check |
Definition at line 642 of file gnunet-daemon-hostlist_client.c.
References GNUNET_NO, GNUNET_YES, Hostlist::hostlist_uri, linked_list_head, Hostlist::next, and uri.
Referenced by handler_advertisement().
|
static |
Method returning the hostlist element with the lowest quality in the datastore.
Definition at line 662 of file gnunet-daemon-hostlist_client.c.
References linked_list_head, linked_list_size, Hostlist::next, and Hostlist::quality.
Referenced by insert_hostlist().
|
static |
Method to insert a hostlist into the datastore.
If datastore contains maximum number of elements, the elements with lowest quality is dismissed
Definition at line 687 of file gnunet-daemon-hostlist_client.c.
References gettext_noop, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_set(), hostlist_to_test, Hostlist::hostlist_uri, linked_list_get_lowest_quality(), linked_list_head, linked_list_size, linked_list_tail, MAX_NUMBER_HOSTLISTS, Hostlist::quality, stat_testing_hostlist, and stats.
Referenced by task_download().
|
static |
Method updating hostlist statistics.
Definition at line 723 of file gnunet-daemon-hostlist_client.c.
References checked_add(), checked_sub(), current_hostlist, gettext_noop, GNUNET_asprintf(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_YES, Hostlist::hello_count, HOSTLIST_FAILED_DOWNLOAD, HOSTLIST_SUCCESSFUL_DOWNLOAD, HOSTLIST_SUCCESSFUL_HELLO, Hostlist::hostlist_uri, Hostlist::quality, stat_download_successful, stat_hellos_obtained, stat_learning, stat_testing_hostlist, stat_use_bootstrap, stats, Hostlist::time_last_usage, and Hostlist::times_used.
Referenced by GNUNET_HOSTLIST_client_stop(), and task_download().
|
static |
Clean up the state from the task that downloaded the hostlist and schedule the next task.
Definition at line 777 of file gnunet-daemon-hostlist_client.c.
References _, curl, current_url, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_YES, hostlist_to_test, Hostlist::hostlist_uri, multi, stat_bytes_downloaded, stat_download_in_progress, stat_download_successful, and stat_testing_hostlist.
Referenced by download_hostlist(), download_prepare(), GNUNET_HOSTLIST_client_stop(), and task_download().
|
static |
Task that is run when we are ready to receive more data from the hostlist server.
cls | closure, unused |
Definition at line 911 of file gnunet-daemon-hostlist_client.c.
References _, clean_up(), current_url, download_prepare(), end_time, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NO, GNUNET_TIME_absolute_get_remaining(), GNUNET_YES, hostlist_to_test, insert_hostlist(), MAX_BYTES_PER_HOSTLISTS, msg, multi, stat_bytes_downloaded, stat_download_successful, stat_testing_hostlist, ti_download, and update_hostlist().
Referenced by download_prepare().
|
static |
Ask CURL for the select set and then schedule the receiving task with the scheduler.
Definition at line 850 of file gnunet-daemon-hostlist_client.c.
References _, clean_up(), end_time, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NETWORK_fdset_copy_native(), GNUNET_NETWORK_fdset_create(), GNUNET_NETWORK_fdset_destroy(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_min(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MILLISECONDS, max, multi, task_download(), ti_download, and timeout.
Referenced by download_hostlist(), and task_download().
|
static |
Main function that will download a hostlist and process its data.
Definition at line 1008 of file gnunet-daemon-hostlist_client.c.
References _, callback_download(), clean_up(), curl, CURL_EASY_SETOPT, current_url, download_get_url(), download_pos, download_prepare(), end_time, gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_MINUTES, GNUNET_YES, multi, proxy, proxy_password, proxy_type, proxy_username, ret, stat_bogus_url, stat_bytes_downloaded, stat_download_in_progress, stat_download_successful, stat_hellos_obtained, and stats.
Referenced by task_download_dispatcher().
|
static |
Definition at line 1151 of file gnunet-daemon-hostlist_client.c.
References download_hostlist(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), stat_download_in_progress, task_download_dispatcher(), ti_download_dispatcher_task, and WAITING_INTERVAL.
Referenced by handler_advertisement(), task_check(), and task_download_dispatcher().
|
static |
Task that checks if we should try to download a hostlist.
If so, we initiate the download, otherwise we schedule this task again for a later time.
Definition at line 1178 of file gnunet-daemon-hostlist_client.c.
References _, gettext_noop, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_set(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_HOURS, GNUNET_TIME_UNIT_SECONDS, GNUNET_TIME_UNIT_ZERO, GNUNET_YES, hostlist_delay, MIN_CONNECTIONS, once, GNUNET_TIME_Relative::rel_value_us, stat_connection_count, stats, task_check(), task_download_dispatcher(), ti_check_download, and ti_download_dispatcher_task.
Referenced by GNUNET_HOSTLIST_client_start(), primary_task(), stat_timeout_task(), and task_check().
|
static |
This tasks sets hostlist testing to allowed after interval between to testings is reached.
cls | closure |
Definition at line 1230 of file gnunet-daemon-hostlist_client.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_OK, stat_testing_allowed, and ti_testing_intervall_task.
Referenced by handler_advertisement().
|
static |
Task that writes hostlist entries to a file on a regular base.
cls | closure |
Definition at line 1245 of file gnunet-daemon-hostlist_client.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, save_hostlist_file(), SAVING_INTERVAL, task_hostlist_saving(), and ti_saving_task.
Referenced by GNUNET_HOSTLIST_client_start(), and task_hostlist_saving().
|
static |
Method called whenever a given peer connects.
cls | closure |
peer | peer identity this notification is about |
mq | message queue for transmissions to peer |
Definition at line 1267 of file gnunet-daemon-hostlist_client.c.
References gettext_noop, GNUNET_assert, GNUNET_NO, GNUNET_STATISTICS_update(), stat_connection_count, and stats.
Referenced by GNUNET_HOSTLIST_client_start().
|
static |
Method called whenever a given peer disconnects.
cls | closure |
peer | peer identity this notification is about |
Definition at line 1288 of file gnunet-daemon-hostlist_client.c.
References gettext_noop, GNUNET_assert, GNUNET_NO, GNUNET_STATISTICS_update(), stat_connection_count, and stats.
Referenced by GNUNET_HOSTLIST_client_start().
|
static |
Method called whenever an advertisement message arrives.
uri | the advertised URI |
Definition at line 1307 of file gnunet-daemon-hostlist_client.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_YES, HOSTLIST_INITIAL, hostlist_to_test, Hostlist::hostlist_uri, linked_list_contains(), Hostlist::quality, stat_testing_allowed, stat_testing_hostlist, task_download_dispatcher(), task_testing_intervall_reset(), TESTING_INTERVAL, ti_download_dispatcher_task, ti_testing_intervall_task, Hostlist::time_creation, and uri.
Referenced by GNUNET_HOSTLIST_client_start().
|
static |
Continuation called by the statistics code once we go the stat.
Initiates hostlist download scheduling.
cls | closure |
success | GNUNET_OK if statistics were successfully obtained, GNUNET_SYSERR if not. |
Definition at line 1370 of file gnunet-daemon-hostlist_client.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), sget, stats, task_check(), and ti_check_download.
Referenced by GNUNET_HOSTLIST_client_start().
|
static |
Continuation called by the statistics code once we go the stat.
Initiates hostlist download scheduling.
cls | closure |
Definition at line 1392 of file gnunet-daemon-hostlist_client.c.
References GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_get_cancel(), sget, task_check(), and ti_check_download.
Referenced by GNUNET_HOSTLIST_client_start().
|
static |
We've received the previous delay value from statistics.
Remember it.
cls | NULL, unused |
subsystem | should be "hostlist", unused |
name | will be "milliseconds between hostlist downloads", unused |
value | previous delay value, in milliseconds (!) |
is_persistent | unused, will be GNUNET_YES |
Definition at line 1410 of file gnunet-daemon-hostlist_client.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_OK, GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, hostlist_delay, GNUNET_TIME_Relative::rel_value_us, and value.
Referenced by GNUNET_HOSTLIST_client_start().
|
static |
Method to load persistent hostlist file during hostlist client startup.
Definition at line 1429 of file gnunet-daemon-hostlist_client.c.
References _, GNUNET_TIME_Absolute::abs_value_us, cfg, filename, gettext_noop, GNUNET_BIO_read_close(), GNUNET_BIO_read_open_file(), GNUNET_BIO_read_spec_commit(), GNUNET_BIO_read_spec_end, GNUNET_BIO_read_spec_int32(), GNUNET_BIO_read_spec_int64(), GNUNET_BIO_read_string(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONTAINER_DLL_insert, GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_set(), GNUNET_YES, Hostlist::hello_count, Hostlist::hostlist_uri, linked_list_head, linked_list_size, linked_list_tail, MAX_NUMBER_HOSTLISTS, MAX_URL_LEN, Hostlist::quality, GNUNET_BIO_ReadSpec::rh, stats, Hostlist::time_creation, Hostlist::time_last_usage, Hostlist::times_used, and uri.
Referenced by GNUNET_HOSTLIST_client_start().
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.
c | configuration to use | |
st | statistics handle to use | |
[out] | ch | set to handler for CORE connect events |
[out] | dh | set to handler for CORE disconnect events |
[out] | msgh | set to handler for CORE advertisement messages |
learn | should we learn hostlist URLs from CORE |
Definition at line 1648 of file gnunet-daemon-hostlist_client.c.
References _, cfg, ch, filename, gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror_file, GNUNET_NO, GNUNET_OK, GNUNET_PEERSTORE_connect(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_get(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_STRINGS_utf8_toupper(), GNUNET_SYSERR, GNUNET_TIME_UNIT_MINUTES, GNUNET_YES, handler_advertisement(), handler_connect(), handler_disconnect(), linked_list_head, linked_list_tail, load_hostlist_file(), peerstore, primary_task(), process_stat(), proxy, proxy_password, proxy_type, proxy_username, result, SAVING_INTERVAL, sget, st, stat_learning, stat_testing_allowed, stat_testing_hostlist, stat_timeout_task(), stat_use_bootstrap, stats, task_check(), task_hostlist_saving(), ti_check_download, and ti_saving_task.
Referenced by run().
void GNUNET_HOSTLIST_client_stop | ( | void | ) |
Stop downloading hostlists from hostlist servers as necessary.
Definition at line 1821 of file gnunet-daemon-hostlist_client.c.
References cfg, clean_up(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_PEERSTORE_disconnect(), GNUNET_PEERSTORE_hello_add_cancel(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_get_cancel(), GNUNET_YES, peerstore, proxy, proxy_password, proxy_username, save_hostlist_file(), StoreHelloEntry::sc, sget, she_head, she_tail, stat_learning, stats, ti_check_download, ti_download, ti_download_dispatcher_task, ti_saving_task, ti_testing_intervall_task, and update_hostlist().
Referenced by cleaning_task().
|
static |
Our configuration.
Definition at line 165 of file gnunet-daemon-hostlist_client.c.
Referenced by get_bootstrap_server(), GNUNET_HOSTLIST_client_start(), GNUNET_HOSTLIST_client_stop(), load_hostlist_file(), and save_hostlist_file().
|
static |
Statistics handle.
Definition at line 170 of file gnunet-daemon-hostlist_client.c.
Referenced by callback_download(), download_hostlist(), GNUNET_HOSTLIST_client_start(), GNUNET_HOSTLIST_client_stop(), handler_connect(), handler_disconnect(), insert_hostlist(), load_hostlist_file(), primary_task(), save_hostlist_file(), task_check(), and update_hostlist().
|
static |
Proxy hostname or ip we are using (can be NULL).
Definition at line 175 of file gnunet-daemon-hostlist_client.c.
Referenced by download_hostlist(), GNUNET_HOSTLIST_client_start(), and GNUNET_HOSTLIST_client_stop().
|
static |
Proxy username we are using (can be NULL).
Definition at line 180 of file gnunet-daemon-hostlist_client.c.
Referenced by download_hostlist(), GNUNET_HOSTLIST_client_start(), and GNUNET_HOSTLIST_client_stop().
|
static |
Proxy password we are using (can be NULL).
Definition at line 185 of file gnunet-daemon-hostlist_client.c.
Referenced by download_hostlist(), GNUNET_HOSTLIST_client_start(), and GNUNET_HOSTLIST_client_stop().
|
static |
Proxy type we are using (can be NULL).
Definition at line 190 of file gnunet-daemon-hostlist_client.c.
Referenced by download_hostlist(), and GNUNET_HOSTLIST_client_start().
|
static |
Number of bytes valid in 'download_buffer'.
Definition at line 195 of file gnunet-daemon-hostlist_client.c.
Referenced by callback_download(), and download_hostlist().
|
static |
Current URL that we are using.
Definition at line 200 of file gnunet-daemon-hostlist_client.c.
Referenced by callback_download(), clean_up(), download_hostlist(), and task_download().
|
static |
Current CURL handle.
Definition at line 205 of file gnunet-daemon-hostlist_client.c.
Referenced by clean_up(), and download_hostlist().
|
static |
Current multi-CURL handle.
Definition at line 210 of file gnunet-daemon-hostlist_client.c.
Referenced by clean_up(), download_hostlist(), download_prepare(), GNUNET_CURL_init(), and task_download().
|
static |
How many bytes did we download from the current hostlist URL?
Definition at line 215 of file gnunet-daemon-hostlist_client.c.
Referenced by callback_download(), clean_up(), download_hostlist(), and task_download().
|
static |
Amount of time we wait between hostlist downloads.
Definition at line 220 of file gnunet-daemon-hostlist_client.c.
Referenced by process_stat(), and task_check().
|
static |
ID of the task, checking if hostlist download should take plate.
Definition at line 225 of file gnunet-daemon-hostlist_client.c.
Referenced by GNUNET_HOSTLIST_client_start(), GNUNET_HOSTLIST_client_stop(), primary_task(), stat_timeout_task(), and task_check().
|
static |
ID of the task downloading the hostlist.
Definition at line 230 of file gnunet-daemon-hostlist_client.c.
Referenced by download_prepare(), GNUNET_HOSTLIST_client_stop(), and task_download().
|
static |
ID of the task saving the hostlsit in a regular interval.
Definition at line 235 of file gnunet-daemon-hostlist_client.c.
Referenced by GNUNET_HOSTLIST_client_start(), GNUNET_HOSTLIST_client_stop(), and task_hostlist_saving().
|
static |
ID of the task called to initiate a download.
Definition at line 240 of file gnunet-daemon-hostlist_client.c.
Referenced by GNUNET_HOSTLIST_client_stop(), handler_advertisement(), task_check(), and task_download_dispatcher().
|
static |
ID of the task controlling the locking between two hostlist tests.
Definition at line 245 of file gnunet-daemon-hostlist_client.c.
Referenced by GNUNET_HOSTLIST_client_stop(), handler_advertisement(), and task_testing_intervall_reset().
|
static |
At what time MUST the current hostlist request be done?
Definition at line 250 of file gnunet-daemon-hostlist_client.c.
Referenced by download_hostlist(), download_prepare(), process_job_queue(), and task_download().
|
static |
Head of the linkd list to store the store context for hellos.
Definition at line 255 of file gnunet-daemon-hostlist_client.c.
Referenced by callback_download(), GNUNET_HOSTLIST_client_stop(), and shc_cont().
|
static |
Tail of the linkd list to store the store context for hellos.
Definition at line 260 of file gnunet-daemon-hostlist_client.c.
Referenced by callback_download(), GNUNET_HOSTLIST_client_stop(), and shc_cont().
|
static |
Head of the linked list used to store hostlists.
Definition at line 265 of file gnunet-daemon-hostlist_client.c.
Referenced by download_get_url(), GNUNET_HOSTLIST_client_start(), insert_hostlist(), linked_list_contains(), linked_list_get_lowest_quality(), load_hostlist_file(), and save_hostlist_file().
|
static |
Tail of the linked list used to store hostlists.
Definition at line 270 of file gnunet-daemon-hostlist_client.c.
Referenced by GNUNET_HOSTLIST_client_start(), insert_hostlist(), load_hostlist_file(), and save_hostlist_file().
|
static |
Current hostlist used for downloading.
Definition at line 275 of file gnunet-daemon-hostlist_client.c.
Referenced by download_get_url(), and update_hostlist().
|
static |
Size of the linked list used to store hostlists.
Definition at line 280 of file gnunet-daemon-hostlist_client.c.
Referenced by download_get_url(), insert_hostlist(), linked_list_get_lowest_quality(), load_hostlist_file(), and save_hostlist_file().
|
static |
Head of the linked list used to store hostlists.
Definition at line 285 of file gnunet-daemon-hostlist_client.c.
Referenced by clean_up(), download_get_url(), handler_advertisement(), insert_hostlist(), and task_download().
|
static |
Handle for our statistics GET operation.
Definition at line 290 of file gnunet-daemon-hostlist_client.c.
Referenced by GNUNET_HOSTLIST_client_start(), GNUNET_HOSTLIST_client_stop(), primary_task(), and stat_timeout_task().
|
static |
Set to GNUNET_YES if the current URL had some problems.
Definition at line 295 of file gnunet-daemon-hostlist_client.c.
Referenced by callback_download(), and download_hostlist().
|
static |
Value controlling if a hostlist is tested at the moment.
Definition at line 300 of file gnunet-daemon-hostlist_client.c.
Referenced by clean_up(), download_get_url(), GNUNET_HOSTLIST_client_start(), handler_advertisement(), insert_hostlist(), task_download(), and update_hostlist().
|
static |
Value controlling if a hostlist testing is allowed at the moment.
Definition at line 305 of file gnunet-daemon-hostlist_client.c.
Referenced by GNUNET_HOSTLIST_client_start(), handler_advertisement(), and task_testing_intervall_reset().
|
static |
Value controlling if a hostlist download is running at the moment.
Definition at line 310 of file gnunet-daemon-hostlist_client.c.
Referenced by clean_up(), download_hostlist(), and task_download_dispatcher().
|
static |
Value saying if a preconfigured bootstrap server is used.
Definition at line 315 of file gnunet-daemon-hostlist_client.c.
Referenced by download_get_url(), GNUNET_HOSTLIST_client_start(), and update_hostlist().
|
static |
Set if we are allowed to learn new hostlists and use them.
Definition at line 320 of file gnunet-daemon-hostlist_client.c.
Referenced by download_get_url(), GNUNET_HOSTLIST_client_start(), GNUNET_HOSTLIST_client_stop(), and update_hostlist().
|
static |
Value saying if hostlist download was successful.
Definition at line 325 of file gnunet-daemon-hostlist_client.c.
Referenced by clean_up(), download_hostlist(), task_download(), and update_hostlist().
|
static |
Value saying how many valid HELLO messages were obtained during download.
Definition at line 330 of file gnunet-daemon-hostlist_client.c.
Referenced by callback_download(), download_hostlist(), and update_hostlist().
|
static |
Number of active connections (according to core service).
Definition at line 335 of file gnunet-daemon-hostlist_client.c.
Referenced by handler_connect(), handler_disconnect(), and task_check().
|
static |
Handle to the PEERSTORE service.
Definition at line 340 of file gnunet-daemon-hostlist_client.c.
Referenced by callback_download(), GNUNET_HOSTLIST_client_start(), and GNUNET_HOSTLIST_client_stop().