gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r20445 - gnunet/src/hostlist


From: gnunet
Subject: [GNUnet-SVN] r20445 - gnunet/src/hostlist
Date: Sun, 11 Mar 2012 23:51:28 +0100

Author: grothoff
Date: 2012-03-11 23:51:28 +0100 (Sun, 11 Mar 2012)
New Revision: 20445

Modified:
   gnunet/src/hostlist/hostlist-server.c
   gnunet/src/hostlist/hostlist.conf
Log:
vminko: implementing BINDTO option for hostlist service (#2140)

Modified: gnunet/src/hostlist/hostlist-server.c
===================================================================
--- gnunet/src/hostlist/hostlist-server.c       2012-03-11 22:49:38 UTC (rev 
20444)
+++ gnunet/src/hostlist/hostlist-server.c       2012-03-11 22:51:28 UTC (rev 
20445)
@@ -537,7 +537,13 @@
 {
   unsigned long long port;
   char *hostname;
+  char *ip;
   size_t size;
+  struct in_addr i4;
+  struct in6_addr i6;
+  struct sockaddr_in v4;
+  struct sockaddr_in6 v6;
+  const struct sockaddr *sa;
 
   advertising = advertise;
   if (!advertising)
@@ -589,6 +595,50 @@
     }
     GNUNET_free (hostname);
   }
+
+  if (GNUNET_CONFIGURATION_have_value (cfg, "HOSTLIST", "BINDTOIP"))
+  {
+    GNUNET_break (GNUNET_OK ==
+                  GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST",
+                                                         "BINDTOIP", &ip));
+  }
+  else 
+    ip = NULL;
+  if (ip != NULL)
+  {
+    if (1 == inet_pton (AF_INET, ip, &i4))
+    {
+      memset (&v4, 0, sizeof (v4));
+      v4.sin_family = AF_INET;
+      v4.sin_addr = i4;
+      v4.sin_port = htons (port);
+#if HAVE_SOCKADDR_IN_SIN_LEN
+      v4.sin_len = sizeof (v4);
+#endif
+      sa = (const struct sockaddr *) &v4;
+    }
+    else if (1 == inet_pton (AF_INET6, ip, &i6))
+    {
+      memset (&v6, 0, sizeof (v6));
+      v6.sin6_family = AF_INET6;
+      v6.sin6_addr = i6;
+      v6.sin6_port = htons (port);
+#if HAVE_SOCKADDR_IN_SIN_LEN
+      v6.sin6_len = sizeof (v6);
+#endif
+      sa = (const struct sockaddr *) &v6;
+    }
+    else
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  _("`%s' is not a valid IP address! Ignoring BINDTOIP.\n"),
+                  ip);
+      sa = NULL;
+    }
+  }
+  else
+    sa = NULL;
+
   daemon_handle_v6 = MHD_start_daemon (MHD_USE_IPv6
 #if DEBUG_HOSTLIST_SERVER
                                        | MHD_USE_DEBUG
@@ -603,7 +653,10 @@
                                        MHD_OPTION_CONNECTION_TIMEOUT,
                                        (unsigned int) 16,
                                        MHD_OPTION_CONNECTION_MEMORY_LIMIT,
-                                       (size_t) (16 * 1024), MHD_OPTION_END);
+                                       (size_t) (16 * 1024),
+                                       MHD_OPTION_SOCK_ADDR,
+                                       sa,
+                                       MHD_OPTION_END);
   daemon_handle_v4 = MHD_start_daemon (MHD_NO_FLAG
 #if DEBUG_HOSTLIST_SERVER
                                        | MHD_USE_DEBUG
@@ -618,7 +671,10 @@
                                        MHD_OPTION_CONNECTION_TIMEOUT,
                                        (unsigned int) 16,
                                        MHD_OPTION_CONNECTION_MEMORY_LIMIT,
-                                       (size_t) (16 * 1024), MHD_OPTION_END);
+                                       (size_t) (16 * 1024),
+                                       MHD_OPTION_SOCK_ADDR,
+                                       sa,
+                                       MHD_OPTION_END);
 
   if ((daemon_handle_v6 == NULL) && (daemon_handle_v4 == NULL))
   {

Modified: gnunet/src/hostlist/hostlist.conf
===================================================================
--- gnunet/src/hostlist/hostlist.conf   2012-03-11 22:49:38 UTC (rev 20444)
+++ gnunet/src/hostlist/hostlist.conf   2012-03-11 22:51:28 UTC (rev 20445)
@@ -10,5 +10,6 @@
 SERVERS = http://v9.gnunet.org:58080/ http://ioerror.gnunet.org:65535/
 # proxy for downloading hostlists
 HTTP-PROXY = 
+# bind hostlist http server to a specific IPv4 or IPv6
+# BINDTOIP =
 
-




reply via email to

[Prev in Thread] Current Thread [Next in Thread]