diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-13 12:56:48 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-13 12:56:48 +0000 |
commit | 6ba13deb812b0b55ae5c34de044ad4bf6cb7835d (patch) | |
tree | 558c85be9b38dcf40645c8519a1a5fbe0e5c77b6 /src | |
parent | d6af5432c3f6a61cd9c1aea68e89e8da39c6219b (diff) | |
download | gnunet-6ba13deb812b0b55ae5c34de044ad4bf6cb7835d.tar.gz gnunet-6ba13deb812b0b55ae5c34de044ad4bf6cb7835d.zip |
added methods to load and write hostfiles
Diffstat (limited to 'src')
-rw-r--r-- | src/hostlist/hostlist-client.c | 50 | ||||
-rw-r--r-- | src/hostlist/learning_peer2.conf | 2 |
2 files changed, 51 insertions, 1 deletions
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 9e86053fc..78eb8acaa 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c | |||
@@ -787,6 +787,51 @@ process_stat (void *cls, | |||
787 | return GNUNET_OK; | 787 | return GNUNET_OK; |
788 | } | 788 | } |
789 | 789 | ||
790 | /** | ||
791 | * Method to load persistent hostlist file during hostlist client startup | ||
792 | * param c configuration to use | ||
793 | */ | ||
794 | static int load_hostlist_file () | ||
795 | { | ||
796 | char *servers; | ||
797 | |||
798 | if (GNUNET_OK != | ||
799 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
800 | "HOSTLIST", | ||
801 | "HOSTLISTFILE", | ||
802 | &servers)) | ||
803 | { | ||
804 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
805 | _("No `%s' specified in `%s' configuration, cannot load hostlists from file.\n"), | ||
806 | "HOSTLISTFILE", "HOSTLIST"); | ||
807 | return GNUNET_SYSERR; | ||
808 | } | ||
809 | return GNUNET_OK; | ||
810 | } | ||
811 | |||
812 | /** | ||
813 | * Method to load persistent hostlist file during hostlist client shutdown | ||
814 | * param c configuration to use | ||
815 | */ | ||
816 | static int save_hostlist_file () | ||
817 | { | ||
818 | char *servers; | ||
819 | |||
820 | if (GNUNET_OK != | ||
821 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
822 | "HOSTLIST", | ||
823 | "HOSTLISTFILE", | ||
824 | &servers)) | ||
825 | { | ||
826 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
827 | _("No `%s' specified in `%s' configuration, cannot save hostlist to file.\n"), | ||
828 | "HOSTLISTFILE", "HOSTLIST"); | ||
829 | return GNUNET_SYSERR; | ||
830 | } | ||
831 | |||
832 | |||
833 | return GNUNET_OK; | ||
834 | } | ||
790 | 835 | ||
791 | /** | 836 | /** |
792 | * Start downloading hostlists from hostlist servers as necessary. | 837 | * Start downloading hostlists from hostlist servers as necessary. |
@@ -822,6 +867,9 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
822 | *ch = &connect_handler; | 867 | *ch = &connect_handler; |
823 | *dh = &disconnect_handler; | 868 | *dh = &disconnect_handler; |
824 | *msgh = &advertisement_handler; | 869 | *msgh = &advertisement_handler; |
870 | |||
871 | load_hostlist_file (); | ||
872 | |||
825 | GNUNET_STATISTICS_get (stats, | 873 | GNUNET_STATISTICS_get (stats, |
826 | "hostlist", | 874 | "hostlist", |
827 | gettext_noop("# seconds between hostlist downloads"), | 875 | gettext_noop("# seconds between hostlist downloads"), |
@@ -843,6 +891,8 @@ GNUNET_HOSTLIST_client_stop () | |||
843 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 891 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
844 | "Hostlist client shutdown\n"); | 892 | "Hostlist client shutdown\n"); |
845 | #endif | 893 | #endif |
894 | save_hostlist_file (); | ||
895 | |||
846 | if (current_task != GNUNET_SCHEDULER_NO_TASK) | 896 | if (current_task != GNUNET_SCHEDULER_NO_TASK) |
847 | { | 897 | { |
848 | GNUNET_SCHEDULER_cancel (sched, | 898 | GNUNET_SCHEDULER_cancel (sched, |
diff --git a/src/hostlist/learning_peer2.conf b/src/hostlist/learning_peer2.conf index dc1216a86..6d109455e 100644 --- a/src/hostlist/learning_peer2.conf +++ b/src/hostlist/learning_peer2.conf | |||
@@ -36,7 +36,7 @@ WEAKRANDOM = YES | |||
36 | [hostlist] | 36 | [hostlist] |
37 | HTTPPORT = 12981 | 37 | HTTPPORT = 12981 |
38 | SERVERS = http://localhost:12980/ | 38 | SERVERS = http://localhost:12980/ |
39 | OPTIONS = -b -p -e -a | 39 | OPTIONS = -b -p -e |
40 | DEBUG = YES | 40 | DEBUG = YES |
41 | #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist | 41 | #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist |
42 | 42 | ||