gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r15616 - gnunet/src/vpn


From: gnunet
Subject: [GNUnet-SVN] r15616 - gnunet/src/vpn
Date: Wed, 15 Jun 2011 09:15:43 +0200

Author: toelke
Date: 2011-06-15 09:15:43 +0200 (Wed, 15 Jun 2011)
New Revision: 15616

Modified:
   gnunet/src/vpn/gnunet-daemon-exit.c
   gnunet/src/vpn/gnunet-service-dns.c
Log:
read the service-conf from the global config-file

Modified: gnunet/src/vpn/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-exit.c 2011-06-15 07:15:43 UTC (rev 15615)
+++ gnunet/src/vpn/gnunet-daemon-exit.c 2011-06-15 07:15:43 UTC (rev 15616)
@@ -42,11 +42,6 @@
 static const struct GNUNET_CONFIGURATION_Handle *cfg;
 
 /**
- * The handle to the service-configuration
- */
-static struct GNUNET_CONFIGURATION_Handle *servicecfg;
-
-/**
  * The handle to the helper
  */
 struct GNUNET_VPN_HELPER_Handle *helper_handle;
@@ -459,9 +454,13 @@
  *         "OFFERED-PORT:HOSTNAME:HOST-PORT" (SPACE <more of those>)*
  */
 static void
-read_service_conf (void *cls __attribute__((unused)), const char *section, 
const char *option,
-                   const char *value)
+read_service_conf (void *cls __attribute__((unused)), const char *section)
 {
+  if ((strlen(section) < 8) || (0 != strcmp (".gnunet.", section + 
(strlen(section) - 8))))
+    return;
+
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Parsing dns-name %d %s %s\n", 
strlen(section), section, section + (strlen(section) - 8));
+
   char *cpy;
   char *redirect;
   char *hostname;
@@ -473,17 +472,15 @@
 #define TCP 2
 #define UDP 1
 
-  unsigned int proto;
-  if (0 == strcmp ("UDP_REDIRECTS", option))
-    proto = UDP;
-  else if (0 == strcmp ("TCP_REDIRECTS", option))
-    proto = TCP;
-  else
-    proto = 0;
+  int proto = UDP;
 
-  if (0 != proto)
+  do
     {
-      cpy = GNUNET_strdup (value);
+      if (proto == UDP && (GNUNET_OK != 
GNUNET_CONFIGURATION_get_value_string(cfg, section, "UDP_REDIRECTS", &cpy)))
+        goto next;
+      else if (proto == TCP && (GNUNET_OK != 
GNUNET_CONFIGURATION_get_value_string(cfg, section, "TCP_REDIRECTS", &cpy)))
+        goto next;
+
       for (redirect = strtok (cpy, " "); redirect != NULL; redirect = strtok
            (NULL, " "))
         {
@@ -565,7 +562,10 @@
 
         }
       GNUNET_free (cpy);
+next:
+      proto = (proto == UDP) ? TCP : UDP;
     }
+  while (proto != UDP);
 }
 
 /**
@@ -1255,16 +1255,7 @@
   GNUNET_CONFIGURATION_get_value_number (cfg, "exit", "MAX_TCP_CONNECTIONS",
                                          &max_tcp_connections);
 
-  char *services;
-  GNUNET_CONFIGURATION_get_value_filename (cfg, "dns", "SERVICES", &services);
-  servicecfg = GNUNET_CONFIGURATION_create ();
-  if (GNUNET_OK == GNUNET_CONFIGURATION_parse (servicecfg, services))
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Parsing services %s\n", services);
-      GNUNET_CONFIGURATION_iterate (servicecfg, read_service_conf, NULL);
-    }
-  if (NULL != services)
-    GNUNET_free (services);
+  GNUNET_CONFIGURATION_iterate_sections (cfg, read_service_conf, NULL);
 
   GNUNET_SCHEDULER_add_now (start_helper_and_schedule, NULL);
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls);

Modified: gnunet/src/vpn/gnunet-service-dns.c
===================================================================
--- gnunet/src/vpn/gnunet-service-dns.c 2011-06-15 07:15:43 UTC (rev 15615)
+++ gnunet/src/vpn/gnunet-service-dns.c 2011-06-15 07:15:43 UTC (rev 15616)
@@ -64,11 +64,6 @@
 static const struct GNUNET_CONFIGURATION_Handle *cfg;
 
 /**
- * The handle to the service-configuration
- */
-static struct GNUNET_CONFIGURATION_Handle *servicecfg;
-
-/**
  * A list of DNS-Responses that have to be sent to the requesting client
  */
 static struct answer_packet_list *head;
@@ -1043,12 +1038,17 @@
 void
 publish_iterate (void *cls __attribute__((unused)), const char *section)
 {
+  if ((strlen(section) < 8) || (0 != strcmp (".gnunet.", section + 
(strlen(section) - 8))))
+    return;
+
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Parsing dns-name %s\n", section);
+
   char *udp_redirects, *tcp_redirects, *alternative_names, *alternative_name,
     *keyfile;
 
-  GNUNET_CONFIGURATION_get_value_string (servicecfg, section,
+  GNUNET_CONFIGURATION_get_value_string (cfg, section,
                                          "UDP_REDIRECTS", &udp_redirects);
-  GNUNET_CONFIGURATION_get_value_string (servicecfg, section, "TCP_REDIRECTS",
+  GNUNET_CONFIGURATION_get_value_string (cfg, section, "TCP_REDIRECTS",
                                          &tcp_redirects);
 
   if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD",
@@ -1080,7 +1080,7 @@
 
   publish_name (section, ports, service_type, my_private_key);
 
-  GNUNET_CONFIGURATION_get_value_string (servicecfg, section,
+  GNUNET_CONFIGURATION_get_value_string (cfg, section,
                                          "ALTERNATIVE_NAMES",
                                          &alternative_names);
   for (alternative_name = strtok (alternative_names, " ");
@@ -1102,32 +1102,19 @@
 }
 
 /**
- * Publish a DNS-record in the DHT. This is up to now just for testing.
+ * Publish a DNS-record in the DHT.
  */
 static void
 publish_names (void *cls __attribute__((unused)),
                const struct GNUNET_SCHEDULER_TaskContext *tc) {
-    char *services;
     if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
       return;
 
-    if (NULL != servicecfg)
-      GNUNET_CONFIGURATION_destroy(servicecfg);
+    GNUNET_CONFIGURATION_iterate_sections(cfg, publish_iterate, NULL);
 
-    GNUNET_CONFIGURATION_get_value_filename(cfg, "dns", "SERVICES", &services);
-
-    servicecfg = GNUNET_CONFIGURATION_create();
-    if (GNUNET_OK == GNUNET_CONFIGURATION_parse(servicecfg, services))
-      {
-        GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Parsing services %s\n", services);
-        GNUNET_CONFIGURATION_iterate_sections(servicecfg, publish_iterate, 
NULL);
-      }
-    if (NULL != services)
-      GNUNET_free(services);
-
     GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_HOURS,
-                                 publish_names,
-                                 NULL);
+                                  publish_names,
+                                  NULL);
 }
 
 /**




reply via email to

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