aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-04-13 12:56:48 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-04-13 12:56:48 +0000
commit6ba13deb812b0b55ae5c34de044ad4bf6cb7835d (patch)
tree558c85be9b38dcf40645c8519a1a5fbe0e5c77b6 /src
parentd6af5432c3f6a61cd9c1aea68e89e8da39c6219b (diff)
downloadgnunet-6ba13deb812b0b55ae5c34de044ad4bf6cb7835d.tar.gz
gnunet-6ba13deb812b0b55ae5c34de044ad4bf6cb7835d.zip
added methods to load and write hostfiles
Diffstat (limited to 'src')
-rw-r--r--src/hostlist/hostlist-client.c50
-rw-r--r--src/hostlist/learning_peer2.conf2
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 */
794static 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 */
816static 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]
37HTTPPORT = 12981 37HTTPPORT = 12981
38SERVERS = http://localhost:12980/ 38SERVERS = http://localhost:12980/
39OPTIONS = -b -p -e -a 39OPTIONS = -b -p -e
40DEBUG = YES 40DEBUG = YES
41#BINARY = /home/grothoff/bin/gnunet-daemon-hostlist 41#BINARY = /home/grothoff/bin/gnunet-daemon-hostlist
42 42