From: Christian Grothoff Date: Tue, 13 Mar 2012 13:57:50 +0000 (+0000) Subject: -adding capability to install static list of HELLOs with the original software to... X-Git-Tag: initial-import-from-subversion-38251~14278 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c8e04709c3941b832261c4eff9dbee058a46c841;p=oweals%2Fgnunet.git -adding capability to install static list of HELLOs with the original software to avoid need for hostlist server accessibility --- diff --git a/contrib/Makefile.am b/contrib/Makefile.am index df6bdc275..d5797adb4 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -45,3 +45,25 @@ check_PROGRAMS = \ test_gnunet_prefix_SOURCES = \ test_gnunet_prefix.c + +pkghellodir= $(pkgdatadir)/hellos + +install-data-local: + $(mkinstalldirs) $(DESTDIR)$(pkghellodir) + @$(NORMAL_INSTALL) + for hello in $(srcdir)/hellos/*; do \ + if test -f $$hello; then \ + $(INSTALL_DATA) $$hello $(DESTDIR)$(pkghellodir)/ ; \ + fi \ + done + +dist-hook: + if test -d $(srcdir)/hellos; then \ + mkdir -p $(distdir)/hellos; \ + for hello in $(srcdir)/hellos/*; do \ + if test -f $$hello; then \ + cp -p $$hello $(distdir)/hellos; \ + fi \ + done \ + fi + diff --git a/contrib/hellos/02UKDQ8B827SF4HR5D57BAIQA2A7IJ96EP15APKS08SE6EI90CDM35QAT4135KH7IPB4DMKVRNDJOUHOIBQ2JBIAIOHPSJHUGGBL30O b/contrib/hellos/02UKDQ8B827SF4HR5D57BAIQA2A7IJ96EP15APKS08SE6EI90CDM35QAT4135KH7IPB4DMKVRNDJOUHOIBQ2JBIAIOHPSJHUGGBL30O new file mode 100644 index 000000000..2454b128a Binary files /dev/null and b/contrib/hellos/02UKDQ8B827SF4HR5D57BAIQA2A7IJ96EP15APKS08SE6EI90CDM35QAT4135KH7IPB4DMKVRNDJOUHOIBQ2JBIAIOHPSJHUGGBL30O differ diff --git a/contrib/hellos/1G1MOK6389P2HV5DUK7RH3BLASHGMMVNUFFC2C26NO93SRSRQBQ9GALGBFMR1IC71608CPU0EB4FRFIDDI15S81G5UC00D7PQKI3JS0 b/contrib/hellos/1G1MOK6389P2HV5DUK7RH3BLASHGMMVNUFFC2C26NO93SRSRQBQ9GALGBFMR1IC71608CPU0EB4FRFIDDI15S81G5UC00D7PQKI3JS0 new file mode 100644 index 000000000..48d1b34d3 Binary files /dev/null and b/contrib/hellos/1G1MOK6389P2HV5DUK7RH3BLASHGMMVNUFFC2C26NO93SRSRQBQ9GALGBFMR1IC71608CPU0EB4FRFIDDI15S81G5UC00D7PQKI3JS0 differ diff --git a/contrib/hellos/7RAVI0QOIAVHL0TE0F54JQL4FUAEQ8V6PL8U1RNDRMRU33E2HU7D0IUBKUDQGTCIQTUEJSRJ9V0IU9TRVTLDUPLNEACRI5BOGQTPC4G b/contrib/hellos/7RAVI0QOIAVHL0TE0F54JQL4FUAEQ8V6PL8U1RNDRMRU33E2HU7D0IUBKUDQGTCIQTUEJSRJ9V0IU9TRVTLDUPLNEACRI5BOGQTPC4G new file mode 100644 index 000000000..77c48987d Binary files /dev/null and b/contrib/hellos/7RAVI0QOIAVHL0TE0F54JQL4FUAEQ8V6PL8U1RNDRMRU33E2HU7D0IUBKUDQGTCIQTUEJSRJ9V0IU9TRVTLDUPLNEACRI5BOGQTPC4G differ diff --git a/contrib/hellos/8B4TV9KRVBMHNPFIP8ISM4GRNR8EAJ39JBQNRRE1QRLTLPOQGEV9S9285D9GEMNCDUG1SST0HNF40IFEHVAUOVI7AME8T4QPD089H28 b/contrib/hellos/8B4TV9KRVBMHNPFIP8ISM4GRNR8EAJ39JBQNRRE1QRLTLPOQGEV9S9285D9GEMNCDUG1SST0HNF40IFEHVAUOVI7AME8T4QPD089H28 new file mode 100644 index 000000000..c486e59e7 Binary files /dev/null and b/contrib/hellos/8B4TV9KRVBMHNPFIP8ISM4GRNR8EAJ39JBQNRRE1QRLTLPOQGEV9S9285D9GEMNCDUG1SST0HNF40IFEHVAUOVI7AME8T4QPD089H28 differ diff --git a/contrib/hellos/94CH5M5L43QCBDJBPVUA3SJT4L92P8IS3JQ0J3V0EE6QSG9P7OM03KGJD58LNB1HNNEE7Q830GQJSPM7LBKR1CP4KSMMPQ80M8GSPTG b/contrib/hellos/94CH5M5L43QCBDJBPVUA3SJT4L92P8IS3JQ0J3V0EE6QSG9P7OM03KGJD58LNB1HNNEE7Q830GQJSPM7LBKR1CP4KSMMPQ80M8GSPTG new file mode 100644 index 000000000..9a732bc1e Binary files /dev/null and b/contrib/hellos/94CH5M5L43QCBDJBPVUA3SJT4L92P8IS3JQ0J3V0EE6QSG9P7OM03KGJD58LNB1HNNEE7Q830GQJSPM7LBKR1CP4KSMMPQ80M8GSPTG differ diff --git a/contrib/hellos/ATF475IOUC8E9A6208VK1RP2STLI3J1E7NP1CKAL5O4L3KP65RM20SKTHEBHFI0TMOETLKQQN3K5PGBLKA1O6USS6CEOED75BOEFJ0G b/contrib/hellos/ATF475IOUC8E9A6208VK1RP2STLI3J1E7NP1CKAL5O4L3KP65RM20SKTHEBHFI0TMOETLKQQN3K5PGBLKA1O6USS6CEOED75BOEFJ0G new file mode 100644 index 000000000..6947c4f3c Binary files /dev/null and b/contrib/hellos/ATF475IOUC8E9A6208VK1RP2STLI3J1E7NP1CKAL5O4L3KP65RM20SKTHEBHFI0TMOETLKQQN3K5PGBLKA1O6USS6CEOED75BOEFJ0G differ diff --git a/contrib/hellos/F1GTBM1J301AEJNJCMOMGTR3DLRHFOUMOQ504SPSVTBS47AOD4H6GMN46J9UMFUU2OMV082E2VMCOR71ONQBB73IO296RCJHSK73MDO b/contrib/hellos/F1GTBM1J301AEJNJCMOMGTR3DLRHFOUMOQ504SPSVTBS47AOD4H6GMN46J9UMFUU2OMV082E2VMCOR71ONQBB73IO296RCJHSK73MDO new file mode 100644 index 000000000..57e95b18d Binary files /dev/null and b/contrib/hellos/F1GTBM1J301AEJNJCMOMGTR3DLRHFOUMOQ504SPSVTBS47AOD4H6GMN46J9UMFUU2OMV082E2VMCOR71ONQBB73IO296RCJHSK73MDO differ diff --git a/contrib/hellos/KD9VVK7H5TJII7OEOMCK9AI5H6EKABCO85OHPPEO72T2K6QGE9IG0LUQTOKOSJSNR9I7HF0CVPJ6C464EM7LMPTVRPU75MP6OIRJQJ0 b/contrib/hellos/KD9VVK7H5TJII7OEOMCK9AI5H6EKABCO85OHPPEO72T2K6QGE9IG0LUQTOKOSJSNR9I7HF0CVPJ6C464EM7LMPTVRPU75MP6OIRJQJ0 new file mode 100644 index 000000000..ca800ed6a Binary files /dev/null and b/contrib/hellos/KD9VVK7H5TJII7OEOMCK9AI5H6EKABCO85OHPPEO72T2K6QGE9IG0LUQTOKOSJSNR9I7HF0CVPJ6C464EM7LMPTVRPU75MP6OIRJQJ0 differ diff --git a/contrib/hellos/KUPL5G20GSVQQ29GOD7QMTC4IRQ67KGSQ1IOMOIQL7TE78L8UQ2V9SNJQTSIEQ29F7JGPV6VNKG509S048CH31NQH8VIH2T58K8PVM0 b/contrib/hellos/KUPL5G20GSVQQ29GOD7QMTC4IRQ67KGSQ1IOMOIQL7TE78L8UQ2V9SNJQTSIEQ29F7JGPV6VNKG509S048CH31NQH8VIH2T58K8PVM0 new file mode 100644 index 000000000..c7b6a5dd2 Binary files /dev/null and b/contrib/hellos/KUPL5G20GSVQQ29GOD7QMTC4IRQ67KGSQ1IOMOIQL7TE78L8UQ2V9SNJQTSIEQ29F7JGPV6VNKG509S048CH31NQH8VIH2T58K8PVM0 differ diff --git a/contrib/hellos/LJR8FV49LJJOCPJFS5894IVT9RU10TENLAM1D61J83BQN629NE1OU56GM54DMIAKS4DAE6UFJBO4BRKDLIOI2OVS6J480QLOGIEPRDG b/contrib/hellos/LJR8FV49LJJOCPJFS5894IVT9RU10TENLAM1D61J83BQN629NE1OU56GM54DMIAKS4DAE6UFJBO4BRKDLIOI2OVS6J480QLOGIEPRDG new file mode 100644 index 000000000..1927951ad Binary files /dev/null and b/contrib/hellos/LJR8FV49LJJOCPJFS5894IVT9RU10TENLAM1D61J83BQN629NE1OU56GM54DMIAKS4DAE6UFJBO4BRKDLIOI2OVS6J480QLOGIEPRDG differ diff --git a/contrib/hellos/R69QGJB2I9T359F3CLA5HDV9NQUDF87FQQH9F8DKIQUCRAQSPJ1FIF3GVL9QIJ8JDLQA5MS09EBVATKUKVFP8RK5Q8QA0LMRIIUTD70 b/contrib/hellos/R69QGJB2I9T359F3CLA5HDV9NQUDF87FQQH9F8DKIQUCRAQSPJ1FIF3GVL9QIJ8JDLQA5MS09EBVATKUKVFP8RK5Q8QA0LMRIIUTD70 new file mode 100644 index 000000000..e901e056f Binary files /dev/null and b/contrib/hellos/R69QGJB2I9T359F3CLA5HDV9NQUDF87FQQH9F8DKIQUCRAQSPJ1FIF3GVL9QIJ8JDLQA5MS09EBVATKUKVFP8RK5Q8QA0LMRIIUTD70 differ diff --git a/contrib/hellos/R6OVGTG5M5EKRS0MBLGI5VEOG360RCJS2TCUU7OCTGKN5CSBIGCC7C75IU6J1P3F4OQC2D21203VECHCKQ95IBUMO6C46SH5MPAO9J8 b/contrib/hellos/R6OVGTG5M5EKRS0MBLGI5VEOG360RCJS2TCUU7OCTGKN5CSBIGCC7C75IU6J1P3F4OQC2D21203VECHCKQ95IBUMO6C46SH5MPAO9J8 new file mode 100644 index 000000000..8703e2745 Binary files /dev/null and b/contrib/hellos/R6OVGTG5M5EKRS0MBLGI5VEOG360RCJS2TCUU7OCTGKN5CSBIGCC7C75IU6J1P3F4OQC2D21203VECHCKQ95IBUMO6C46SH5MPAO9J8 differ diff --git a/contrib/hellos/RL7P1AO4M4LOI3JPVER5FJKG6A847K3O86NS4Q07J1721371FO7RB6IFVMNI1NKLFTRCM7O5AGJPQ3UDD8MST8QQHLNOC4GUL6731O0 b/contrib/hellos/RL7P1AO4M4LOI3JPVER5FJKG6A847K3O86NS4Q07J1721371FO7RB6IFVMNI1NKLFTRCM7O5AGJPQ3UDD8MST8QQHLNOC4GUL6731O0 new file mode 100644 index 000000000..4341512fe Binary files /dev/null and b/contrib/hellos/RL7P1AO4M4LOI3JPVER5FJKG6A847K3O86NS4Q07J1721371FO7RB6IFVMNI1NKLFTRCM7O5AGJPQ3UDD8MST8QQHLNOC4GUL6731O0 differ diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index d6e52d4b4..90ab6d5bf 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c @@ -32,12 +32,9 @@ */ #include "platform.h" -#include "gnunet_crypto_lib.h" -#include "gnunet_container_lib.h" -#include "gnunet_disk_lib.h" +#include "gnunet_util_lib.h" #include "gnunet_hello_lib.h" #include "gnunet_protocols.h" -#include "gnunet_service_lib.h" #include "gnunet_statistics_service.h" #include "peerinfo.h" @@ -51,6 +48,7 @@ */ #define DATA_HOST_CLEAN_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 60) + /** * In-memory cache of known hosts. */ @@ -95,6 +93,9 @@ static struct GNUNET_STATISTICS_Handle *stats; /** * Notify all clients in the notify list about the * given host entry changing. + * + * @param he entry of the host for which we generate a notification + * @return generated notification message */ static struct InfoMessage * make_info_message (const struct HostEntry *he) @@ -141,6 +142,8 @@ discard_expired (void *cls, const struct GNUNET_HELLO_Address *address, /** * Get the filename under which we would store the GNUNET_HELLO_Message * for the given host and protocol. + * + * @param id peer for which we need the filename for the HELLO * @return filename of the form DIRECTORY/HOSTID */ static char * @@ -229,6 +232,8 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) /** * Remove a file that should not be there. LOG * success or failure. + * + * @param fullname name of the file to remove */ static void remove_garbage (const char *fullname) @@ -244,6 +249,15 @@ remove_garbage (const char *fullname) } +/** + * Function that is called on each HELLO file in a particular directory. + * Try to parse the file and add the HELLO to our list. + * + * @param cls pointer to 'unsigned int' to increment for each file, or NULL + * if the file is from a read-only, read-once resource directory + * @param fullname name of the file to parse + * @return GNUNET_OK (continue iteration) + */ static int hosts_directory_scan_callback (void *cls, const char *fullname) { @@ -255,7 +269,8 @@ hosts_directory_scan_callback (void *cls, const char *fullname) return GNUNET_OK; /* ignore non-files */ if (strlen (fullname) < sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) { - remove_garbage (fullname); + if (NULL != matched) + remove_garbage (fullname); return GNUNET_OK; } filename = @@ -263,16 +278,19 @@ hosts_directory_scan_callback (void *cls, const char *fullname) sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) + 1]; if (filename[-1] != DIR_SEPARATOR) { - remove_garbage (fullname); + if (NULL != matched) + remove_garbage (fullname); return GNUNET_OK; } if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (filename, &identity.hashPubKey)) { - remove_garbage (fullname); + if (NULL != matched) + remove_garbage (fullname); return GNUNET_OK; } - (*matched)++; + if (NULL != matched) + (*matched)++; add_host_to_known_hosts (&identity); return GNUNET_OK; } @@ -280,6 +298,9 @@ hosts_directory_scan_callback (void *cls, const char *fullname) /** * Call this method periodically to scan data/hosts for new hosts. + * + * @param cls unused + * @param tc scheduler context, aborted if reason is shutdown */ static void cron_scan_directory_data_hosts (void *cls, @@ -362,7 +383,6 @@ bind_address (const struct GNUNET_PeerIdentity *peer, } - /** * Do transmit info about peer to given host. * @@ -401,6 +421,10 @@ add_to_tc (void *cls, const GNUNET_HashCode * key, void *value) /** * @brief delete expired HELLO entries in data/hosts/ + * + * @param cls pointer to current time (struct GNUNET_TIME_Absolute) + * @param fn filename to test to see if the HELLO expired + * @return GNUNET_OK (continue iteration) */ static int discard_hosts_helper (void *cls, const char *fn) @@ -442,7 +466,11 @@ discard_hosts_helper (void *cls, const char *fn) /** - * Call this method periodically to scan data/hosts for new hosts. + * Call this method periodically to scan data/hosts for ancient + * HELLOs to expire. + * + * @param cls unused + * @param tc scheduler context, aborted if reason is shutdown */ static void cron_clean_data_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) @@ -541,6 +569,9 @@ handle_get_all (void *cls, struct GNUNET_SERVER_Client *client, } +/** + * FIXME. + */ static int do_notify_entry (void *cls, const GNUNET_HashCode * key, void *value) { @@ -576,6 +607,9 @@ handle_notify (void *cls, struct GNUNET_SERVER_Client *client, } +/** + * FIXME. + */ static int free_host_entry (void *cls, const GNUNET_HashCode * key, void *value) { @@ -586,6 +620,7 @@ free_host_entry (void *cls, const GNUNET_HashCode * key, void *value) return GNUNET_YES; } + /** * Clean up our state. Called during shutdown. * @@ -608,7 +643,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /** - * Process statistics requests. + * Start up peerinfo service. * * @param cls closure * @param server the initialized server @@ -628,6 +663,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, sizeof (struct GNUNET_MessageHeader)}, {NULL, NULL, 0, 0} }; + char *peerdir; + char *ip; hostmap = GNUNET_CONTAINER_multihashmap_create (1024); stats = GNUNET_STATISTICS_create ("peerinfo", cfg); @@ -644,11 +681,22 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); GNUNET_SERVER_add_handlers (server, handlers); + ip = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); + GNUNET_asprintf (&peerdir, + "%shellos", + ip); + GNUNET_free (ip); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + _("Importing HELLOs from `%s'\n"), + peerdir); + GNUNET_DISK_directory_scan (peerdir, + &hosts_directory_scan_callback, NULL); + GNUNET_free (peerdir); } /** - * The main function for the statistics service. + * The main function for the peerinfo service. * * @param argc number of arguments from the command line * @param argv command line arguments