gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r15473 - gnunet-setup/src


From: gnunet
Subject: [GNUnet-SVN] r15473 - gnunet-setup/src
Date: Wed, 8 Jun 2011 18:27:40 +0200

Author: toelke
Date: 2011-06-08 18:27:40 +0200 (Wed, 08 Jun 2011)
New Revision: 15473

Modified:
   gnunet-setup/src/gnunet-setup-options.c
Log:
parse the dns config

Modified: gnunet-setup/src/gnunet-setup-options.c
===================================================================
--- gnunet-setup/src/gnunet-setup-options.c     2011-06-08 14:37:07 UTC (rev 
15472)
+++ gnunet-setup/src/gnunet-setup-options.c     2011-06-08 16:27:40 UTC (rev 
15473)
@@ -615,14 +615,78 @@
  * @param section name of the section
  */
 static void
-add_dns_entry_to_list_store (void *cls,
-                            const char *section)
+add_dns_entry_to_list_store (void *cls, const char *section)
 {
   GtkListStore *ls = cls;
-  
-  /* rest of configuration in global 'cfg' */
-  /* gtk_list_store_insert_with_values () --- append */
-  /* FIXME */
+
+  if (0 == strcmp (".gnunet.", section + ((strlen (section) - 8))))
+    {
+      char *sld = strdup (section);
+      sld[strlen (section) - 8] = '\0';
+      long long unsigned int ttl;
+      char *altnames;
+      char *hostname;
+      char *hostport;
+      char *redirect;
+      char *cpy;
+      gboolean udp = FALSE;
+
+      GNUNET_CONFIGURATION_get_value_number (cfg, section, "TTL", &ttl);
+      GNUNET_CONFIGURATION_get_value_string (cfg, section,
+                                             "ALTERNATIVE_NAMES", &altnames);
+
+      do
+        {
+          if (TRUE == udp)
+            GNUNET_CONFIGURATION_get_value_string (cfg, section,
+                                                   "UDP_REDIRECTS", &cpy);
+          else
+            GNUNET_CONFIGURATION_get_value_string (cfg, section,
+                                                   "TCP_REDIRECTS", &cpy);
+
+          for (redirect = strtok (cpy, " "); redirect != NULL;
+               redirect = strtok (NULL, " "))
+            {
+              if (NULL == (hostname = strstr (redirect, ":")))
+                {
+                  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                              "Warning: option %s is not formatted 
correctly!\n",
+                              redirect);
+                  continue;
+                }
+              hostname[0] = '\0';
+              hostname++;
+              if (NULL == (hostport = strstr (hostname, ":")))
+                {
+                  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                              "Warning: option %s is not formatted 
correctly!\n",
+                              redirect);
+                  continue;
+                }
+              hostport[0] = '\0';
+              hostport++;
+
+              int local_port = atoi (redirect);
+              if (!((local_port > 0) && (local_port < 65536)))
+                GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                            "Warning: %s is not a correct port.", redirect);
+
+              gtk_list_store_insert_with_values (ls,
+                                                 NULL,
+                                                 0,
+                                                 0, sld,
+                                                 1, local_port,
+                                                 2, atoi (hostport),
+                                                 3, hostname,
+                                                 4, ttl, 5, altnames, 6, udp,
+                                                 -1);
+            }
+          udp = !udp;
+        }
+      while (udp != FALSE);
+
+      GNUNET_free (altnames);
+    }
 }
 
 




reply via email to

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