Added configuration option to set hostname used for advertisements
authorMatthias Wachs <wachs@net.in.tum.de>
Thu, 29 Apr 2010 14:39:13 +0000 (14:39 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Thu, 29 Apr 2010 14:39:13 +0000 (14:39 +0000)
Fixes problems on systems with misconfigured dns resolution for local hostname

src/hostlist/hostlist-server.c
src/hostlist/test_gnunet_daemon_hostlist_learning.c
src/hostlist/test_learning_adv_peer.conf

index f660da66eb6d1009c18c60a6458f71470933bfd2..7ea495064e95af3f49abefbfbb4a4eddb29c5b48 100644 (file)
@@ -601,10 +601,17 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c,
                                                   "HTTPPORT", 
                                                   &port))
     return GNUNET_SYSERR;
+
+
+  if ( GNUNET_SYSERR  == GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                   "HOSTLIST",
+                                                   "HOSTNAME",
+                                                   &hostname))
+    hostname = GNUNET_RESOLVER_local_fqdn_get ();
+
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-             _("Hostlist service starts on port %llu\n"),
-             port);
-  hostname = GNUNET_RESOLVER_local_fqdn_get ();
+              _("Hostlist service starts on %s:%llu\n"),
+              hostname, port);
   if (NULL != hostname)
     {
       size = strlen (hostname);
index 3098844e957626fb6b94aa0ff22f904179811a87..6510bca338bf504225e47637405c0d1a5809cf37 100644 (file)
@@ -290,7 +290,13 @@ static int ad_arrive_handler (void *cls,
     if ( NULL != expected_uri ) GNUNET_free ( expected_uri );
     return GNUNET_SYSERR;
     }
-  hostname = GNUNET_RESOLVER_local_fqdn_get ();
+
+  if ( GNUNET_SYSERR  == GNUNET_CONFIGURATION_get_value_string (adv_peer.cfg,
+                                                   "HOSTLIST",
+                                                   "HOSTNAME",
+                                                   &hostname))
+    hostname = GNUNET_RESOLVER_local_fqdn_get ();
+
   if (NULL != hostname)
     {
       size = strlen (hostname);
index 0ed2829f95eeb58824b121dc7175acd72c2c5dbd..3888b9f47f89efd5fde761de4a060fa5cc0a77e5 100644 (file)
@@ -34,6 +34,7 @@ PORT = 22970
 WEAKRANDOM = YES
 
 [hostlist]
+HOSTNAME = localhost
 HTTPPORT = 12981
 SERVERS = http://localhost:12981/
 OPTIONS = -p -a