gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r6514 - in GNUnet: contrib src/server src/transports


From: gnunet
Subject: [GNUnet-SVN] r6514 - in GNUnet: contrib src/server src/transports
Date: Sun, 2 Mar 2008 15:27:17 -0700 (MST)

Author: grothoff
Date: 2008-03-02 15:27:17 -0700 (Sun, 02 Mar 2008)
New Revision: 6514

Modified:
   GNUnet/contrib/config-daemon.scm
   GNUnet/src/server/tcpserver.c
   GNUnet/src/transports/common.c
Log:
allowing users to disable IPv6 including inet_pton calls

Modified: GNUnet/contrib/config-daemon.scm
===================================================================
--- GNUnet/contrib/config-daemon.scm    2008-03-02 16:54:54 UTC (rev 6513)
+++ GNUnet/contrib/config-daemon.scm    2008-03-02 22:27:17 UTC (rev 6514)
@@ -408,13 +408,13 @@
  (builder
  "GNUNETD"
  "DISABLE-IPV6"
- (_ "Set to YES to disable IPv6 support")
+ (_ "YES disables IPv6 support, NO enables IPv6 support")
  (_ "This option maybe useful on peers where the kernel does not support IPv6. 
 You might also want to set this option if you do not have an IPv6 network 
connection.")
  '()
  #t
  #t
  #t
- 'rare) )
+ 'advanced) )
 
 
 (define (gnunetd-private-network builder)
@@ -511,7 +511,7 @@
  #t
  "::1;"
  '()
- 'advanced) )
+ 'ipv6) )
 
 
 (define (limit-allow builder)
@@ -969,7 +969,7 @@
  #t
  ""
  '()
- 'advanced))
+ 'ipv6))
 
 (define (tcp6-whitelist builder)
  (builder
@@ -981,7 +981,7 @@
  #t
  ""
  '()
- 'advanced))
+ 'ipv6))
 
 
 (define (tcp builder)
@@ -1222,7 +1222,7 @@
  #t
  ""
  '()
- 'advanced))
+ 'ipv6))
 
 (define (udp6-whitelist builder)
  (builder
@@ -1234,7 +1234,7 @@
  #t
  ""
  '()
- 'advanced))
+ 'ipv6))
 
 (define (udp builder)
  (builder
@@ -1292,7 +1292,7 @@
  #t
  ""
  '()
- 'ip6-loaded) )
+ 'ipv6) )
 
 (define (transports builder)
  (builder
@@ -1502,6 +1502,7 @@
      (rare (get-option ctx "Meta" "RARE"))
      (nobasiclimit (not (get-option ctx "LOAD" "BASICLIMITING")))
      (experimental (get-option ctx "Meta" "EXPERIMENTAL"))
+     (ipv6 (not (get-option ctx "GNUNETD" "DISABLE-IPV6")))
      (f2fr (not (get-option ctx "F2F" "RESTRICT") ) )
      (f2f (or (get-option ctx "F2F" "FRIENDS-ONLY")
               (not (eq? (get-option ctx "F2F" "MINIMUM") 0) ) ) )
@@ -1526,6 +1527,7 @@
             ((eq? i 'rare)         (change-visible ctx a b (and advanced 
rare)))
             ((eq? i 'experimental) (change-visible ctx a b (and advanced 
experimental)))
             ((eq? i 'f2f)          (change-visible ctx a b f2f))
+            ((eq? i 'ipv6)         (change-visible ctx a b ipv6))
             ((eq? i 'f2fr)         (change-visible ctx a b f2fr))
             ((eq? i 'mysql)        (change-visible ctx a b mysql))
             ((eq? i 'fs-loaded)    (change-visible ctx a b fs-loaded))

Modified: GNUnet/src/server/tcpserver.c
===================================================================
--- GNUnet/src/server/tcpserver.c       2008-03-02 16:54:54 UTC (rev 6513)
+++ GNUnet/src/server/tcpserver.c       2008-03-02 22:27:17 UTC (rev 6514)
@@ -472,26 +472,30 @@
     }
   GNUNET_free (ch);
 
-  ch = NULL;
-  if (-1 == GNUNET_GC_get_configuration_value_string (cfg,
-                                                      "NETWORK",
-                                                      "TRUSTED6",
-                                                      "::1;", &ch))
-    return GNUNET_SYSERR;
-  GNUNET_GE_ASSERT (ectx, ch != NULL);
-  trustedNetworksV6 = GNUNET_parse_ipv6_network_specification (ectx, ch);
-  if (trustedNetworksV6 == NULL)
+  if (GNUNET_YES != GNUNET_GC_get_configuration_value_yesno (cfg, "GNUNETD", 
"DISABLE-IPV6",
+                                                            GNUNET_YES))
     {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_FATAL | GNUNET_GE_USER | GNUNET_GE_ADMIN |
-                     GNUNET_GE_IMMEDIATE,
-                     _
-                     ("Malformed network specification in the configuration in 
section `%s' for entry `%s': %s\n"),
-                     "NETWORK", "TRUSTED6", ch);
+      ch = NULL;
+      if (-1 == GNUNET_GC_get_configuration_value_string (cfg,
+                                                         "NETWORK",
+                                                         "TRUSTED6",
+                                                         "::1;", &ch))
+       return GNUNET_SYSERR;
+      GNUNET_GE_ASSERT (ectx, ch != NULL);
+      trustedNetworksV6 = GNUNET_parse_ipv6_network_specification (ectx, ch);
+      if (trustedNetworksV6 == NULL)
+       {
+         GNUNET_GE_LOG (ectx,
+                        GNUNET_GE_FATAL | GNUNET_GE_USER | GNUNET_GE_ADMIN |
+                        GNUNET_GE_IMMEDIATE,
+                        _
+                        ("Malformed network specification in the configuration 
in section `%s' for entry `%s': %s\n"),
+                        "NETWORK", "TRUSTED6", ch);
+         GNUNET_free (ch);
+         return GNUNET_SYSERR;
+       }
       GNUNET_free (ch);
-      return GNUNET_SYSERR;
     }
-  GNUNET_free (ch);
 
   GNUNET_CORE_register_handler (GNUNET_CS_PROTO_SHUTDOWN_REQUEST,
                                 &shutdownHandler);

Modified: GNUnet/src/transports/common.c
===================================================================
--- GNUnet/src/transports/common.c      2008-03-02 16:54:54 UTC (rev 6513)
+++ GNUnet/src/transports/common.c      2008-03-02 22:27:17 UTC (rev 6514)
@@ -269,19 +269,24 @@
   else
     allowedNetworksIPv4 = NULL;
   GNUNET_free (ch);
-  GNUNET_free_non_null (filteredNetworksIPv6);
-  GNUNET_free_non_null (allowedNetworksIPv6);
-  GNUNET_GC_get_configuration_value_string (cfg, MY_TRANSPORT_NAME,
-                                            "BLACKLISTV6", "", &ch);
-  filteredNetworksIPv6 = GNUNET_parse_ipv6_network_specification (ectx, ch);
-  GNUNET_free (ch);
-  GNUNET_GC_get_configuration_value_string (cfg, MY_TRANSPORT_NAME,
-                                            "WHITELISTV6", "", &ch);
-  if (strlen (ch) > 0)
-    allowedNetworksIPv6 = GNUNET_parse_ipv6_network_specification (ectx, ch);
-  else
-    allowedNetworksIPv6 = NULL;
-  GNUNET_free (ch);
+
+  if (GNUNET_YES != GNUNET_GC_get_configuration_value_yesno (cfg, "GNUNETD", 
"DISABLE-IPV6",
+                                                            GNUNET_YES))
+    {
+      GNUNET_free_non_null (filteredNetworksIPv6);
+      GNUNET_free_non_null (allowedNetworksIPv6);
+      GNUNET_GC_get_configuration_value_string (cfg, MY_TRANSPORT_NAME,
+                                               "BLACKLISTV6", "", &ch);
+      filteredNetworksIPv6 = GNUNET_parse_ipv6_network_specification (ectx, 
ch);
+      GNUNET_free (ch);
+      GNUNET_GC_get_configuration_value_string (cfg, MY_TRANSPORT_NAME,
+                                               "WHITELISTV6", "", &ch);
+      if (strlen (ch) > 0)
+       allowedNetworksIPv6 = GNUNET_parse_ipv6_network_specification (ectx, 
ch);
+      else
+       allowedNetworksIPv6 = NULL;
+      GNUNET_free (ch);
+    }
   GNUNET_mutex_unlock (lock);
   /* TODO: error handling! */
   return 0;
@@ -369,14 +374,15 @@
     htons (sizeof (GNUNET_MessageHello) + sizeof (HostAddress));
   haddr = (HostAddress *) & msg[1];
 
-  available = VERSION_AVAILABLE_NONE;
-  if ((((upnp != NULL) &&
-        (GNUNET_OK == upnp->get_ip (port,
-                                    MY_TRANSPORT_NAME,
-                                    &haddr->ipv4))) ||
-       (GNUNET_SYSERR !=
-        GNUNET_IP_get_public_ipv4_address (cfg, coreAPI->ectx,
-                                           &haddr->ipv4))))
+  available = available_protocols;
+  if ( (0 != (available & VERSION_AVAILABLE_IPV4)) &&
+       (((upnp != NULL) &&
+        (GNUNET_OK == upnp->get_ip (port,
+                                    MY_TRANSPORT_NAME,
+                                    &haddr->ipv4))) ||
+       (GNUNET_SYSERR !=
+        GNUNET_IP_get_public_ipv4_address (cfg, coreAPI->ectx,
+                                           &haddr->ipv4))) )
     {
       if (0 != memcmp (&haddr->ipv4, &last_addrv4, sizeof (struct in_addr)))
         {
@@ -392,11 +398,16 @@
                          inet_ntop (AF_INET, &in4, dst, INET_ADDRSTRLEN));
           last_addrv4 = haddr->ipv4;
         }
-      available |= VERSION_AVAILABLE_IPV4;
     }
+  else
+    {
+      available ^= VERSION_AVAILABLE_IPV4;
+    }
 
-  if (GNUNET_SYSERR !=
-      GNUNET_IP_get_public_ipv6_address (cfg, coreAPI->ectx, &haddr->ipv6))
+
+  if ( (0 != (available & VERSION_AVAILABLE_IPV6)) &&
+       (GNUNET_SYSERR !=
+       GNUNET_IP_get_public_ipv6_address (cfg, coreAPI->ectx, &haddr->ipv6)) )
     {
       if (0 != memcmp (&haddr->ipv6, &last_addrv6, sizeof (struct in6_addr)))
         {
@@ -412,8 +423,11 @@
                          inet_ntop (AF_INET6, &in6, dst, INET6_ADDRSTRLEN));
           last_addrv6 = haddr->ipv6;
         }
-      available |= VERSION_AVAILABLE_IPV6;
     }
+  else
+    {
+      available ^= VERSION_AVAILABLE_IPV6;
+    }
   if (available == VERSION_AVAILABLE_NONE)
     {
       GNUNET_free (msg);





reply via email to

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