gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: first preparations for GNS


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: first preparations for GNS mapping arbitrary TLDs
Date: Sun, 25 Feb 2018 23:21:35 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 56a9d4001 first preparations for GNS mapping arbitrary TLDs
56a9d4001 is described below

commit 56a9d4001b0844287ecc55b103549370676646a8
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Feb 25 23:21:34 2018 +0100

    first preparations for GNS mapping arbitrary TLDs
---
 contrib/gns-bcd.tex                      |   1 -
 src/exit/gnunet-daemon-exit.c            |   4 +-
 src/gns/Makefile.am                      |   2 +-
 src/gns/gnunet-service-gns.c             | 133 ++++++++++++++++++++++++++++++-
 src/gns/gnunet-service-gns_interceptor.c |   4 +-
 src/gns/gnunet-service-gns_resolver.c    |   7 +-
 6 files changed, 142 insertions(+), 9 deletions(-)

diff --git a/contrib/gns-bcd.tex b/contrib/gns-bcd.tex
index 5e33ffbc7..73a302985 100644
--- a/contrib/gns-bcd.tex
+++ b/contrib/gns-bcd.tex
@@ -18809,4 +18809,3 @@
 %        \card{english}
 %    \end{center}
 %\end{figure}
-
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index d9a5dd684..c624e083e 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -3373,10 +3373,10 @@ add_services (int proto,
 
 
 /**
- * Reads the configuration servicecfg and populates udp_services
+ * Reads the configuration and populates #udp_services and #tcp_services
  *
  * @param cls unused
- * @param section name of section in config, equal to hostname
+ * @param section name of section in config
  */
 static void
 read_service_conf (void *cls,
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index 977eb87e3..e89192414 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -185,7 +185,7 @@ w32nsp_resolve_SOURCES = \
 w32nsp_resolve_LDADD = -lws2_32
 
 gnunet_service_gns_SOURCES = \
- gnunet-service-gns.c \
+ gnunet-service-gns.c gnunet-service-gns.h \
  gnunet-service-gns_resolver.c gnunet-service-gns_resolver.h \
  gnunet-service-gns_interceptor.c gnunet-service-gns_interceptor.h
 gnunet_service_gns_LDADD = \
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 0ca25ac19..e13beb889 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -101,6 +101,38 @@ struct GnsClient
 
 
 /**
+ * Representation of a TLD, mapping the respective TLD string
+ * (i.e. ".gnu") to the respective public key of the zone.
+ */
+struct GNS_TopLevelDomain
+{
+
+  /**
+   * Kept in a DLL, as there are unlikely enough of these to
+   * warrant a hash map.
+   */
+  struct GNS_TopLevelDomain *next;
+
+  /**
+   * Kept in a DLL, as there are unlikely enough of these to
+   * warrant a hash map.
+   */
+  struct GNS_TopLevelDomain *prev;
+
+  /**
+   * Public key associated with the @a tld.
+   */
+  struct GNUNET_CRYPTO_EddsaPublicKey pkey;
+
+  /**
+   * Top-level domain as a string, including leading ".".
+   */
+  char *tld;
+
+};
+
+
+/**
  * Our handle to the DHT
  */
 static struct GNUNET_DHT_Handle *dht_handle;
@@ -136,6 +168,50 @@ static int v4_enabled;
  */
 static struct GNUNET_STATISTICS_Handle *statistics;
 
+/**
+ * Head of DLL of TLDs we map to GNS zones.
+ */
+static struct GNS_TopLevelDomain *tld_head;
+
+/**
+ * Tail of DLL of TLDs we map to GNS zones.
+ */
+static struct GNS_TopLevelDomain *tld_tail;
+
+
+/**
+ * Find GNS zone belonging to TLD @a tld.
+ *
+ * @param tld_str top-level domain to look up
+ * @param[out] pkey public key to set
+ * @return #GNUNET_YES if @a tld was found #GNUNET_NO if not
+ */
+int
+GNS_find_tld (const char *tld_str,
+              struct GNUNET_CRYPTO_EddsaPublicKey *pkey)
+{
+  if ('\0' == *tld_str)
+    return GNUNET_NO;
+  for (struct GNS_TopLevelDomain *tld = tld_head;
+       NULL != tld;
+       tld = tld->next)
+  {
+    if (0 == strcasecmp (tld_str,
+                         tld->tld))
+    {
+      *pkey = tld->pkey;
+      return GNUNET_YES;
+    }
+  }
+  if (GNUNET_OK ==
+      GNUNET_STRINGS_string_to_data (tld_str + 1,
+                                     strlen (tld_str + 1),
+                                     pkey,
+                                     sizeof (*pkey)))
+    return GNUNET_YES; /* TLD string *was* the public key */
+  return GNUNET_NO;
+}
+
 
 /**
  * Task run during shutdown.
@@ -146,6 +222,7 @@ static struct GNUNET_STATISTICS_Handle *statistics;
 static void
 shutdown_task (void *cls)
 {
+  struct GNS_TopLevelDomain *tld;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Shutting down!\n");
   GNS_interceptor_done ();
@@ -176,6 +253,14 @@ shutdown_task (void *cls)
     GNUNET_DHT_disconnect (dht_handle);
     dht_handle = NULL;
   }
+  while (NULL != (tld = tld_head))
+  {
+    GNUNET_CONTAINER_DLL_remove (tld_head,
+                                 tld_tail,
+                                 tld);
+    GNUNET_free (tld->tld);
+    GNUNET_free (tld);
+  }
 }
 
 
@@ -420,6 +505,47 @@ identity_intercept_cb (void *cls,
 
 
 /**
+ * Reads the configuration and populates TLDs
+ *
+ * @param cls unused
+ * @param section name of section in config, always "gns"
+ * @param option name of the option, TLDs start with "."
+ * @param value value for the option, public key for TLDs
+ */
+static void
+read_service_conf (void *cls,
+                   const char *section,
+                   const char *option,
+                   const char *value)
+{
+  struct GNUNET_CRYPTO_EddsaPublicKey pk;
+  struct GNS_TopLevelDomain *tld;
+
+  if (option[0] != '.')
+    return;
+  if (GNUNET_OK !=
+      GNUNET_STRINGS_string_to_data (value,
+                                     strlen (value),
+                                     &pk,
+                                     sizeof (pk)))
+  {
+    GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+                               section,
+                               option,
+                               _("Properly base32-encoded public key 
required"));
+    return;
+  }
+  tld = GNUNET_new (struct GNS_TopLevelDomain);
+  tld->tld = GNUNET_strdup (option);
+  tld->pkey = pk;
+  GNUNET_CONTAINER_DLL_insert (tld_head,
+                               tld_tail,
+                               tld);
+}
+
+
+
+/**
  * Process GNS requests.
  *
  * @param cls closure
@@ -433,6 +559,10 @@ run (void *cls,
 {
   unsigned long long max_parallel_bg_queries = 16;
 
+  GNUNET_CONFIGURATION_iterate_section_values (c,
+                                               "gns",
+                                               &read_service_conf,
+                                               NULL);
   v6_enabled = GNUNET_NETWORK_test_pf (PF_INET6);
   v4_enabled = GNUNET_NETWORK_test_pf (PF_INET);
   namecache_handle = GNUNET_NAMECACHE_connect (c);
@@ -459,7 +589,8 @@ run (void *cls,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 _("Could not connect to DHT!\n"));
-    GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+    GNUNET_SCHEDULER_add_now (&shutdown_task,
+                              NULL);
     return;
   }
 
diff --git a/src/gns/gnunet-service-gns_interceptor.c 
b/src/gns/gnunet-service-gns_interceptor.c
index a9e207891..71aa08dc5 100644
--- a/src/gns/gnunet-service-gns_interceptor.c
+++ b/src/gns/gnunet-service-gns_interceptor.c
@@ -327,7 +327,9 @@ handle_dns_request (void *cls,
   {
     /* Start resolution in GNS */
     ilh = GNUNET_new (struct InterceptLookupHandle);
-    GNUNET_CONTAINER_DLL_insert (ilh_head, ilh_tail, ilh);
+    GNUNET_CONTAINER_DLL_insert (ilh_head,
+                                 ilh_tail,
+                                 ilh);
     ilh->packet = p;
     ilh->request_handle = rh;
     ilh->lookup = GNS_resolver_lookup (&zone,
diff --git a/src/gns/gnunet-service-gns_resolver.c 
b/src/gns/gnunet-service-gns_resolver.c
index 5bf443267..533c0cada 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -2252,7 +2252,7 @@ recursive_resolution (void *cls)
  * Begin the resolution process from 'name', starting with
  * the identification of the zone specified by 'name'.
  *
- * @param cls the `struct GNS_ResolverHandle` 
+ * @param cls the `struct GNS_ResolverHandle`
  */
 static void
 start_resolver_lookup (void *cls)
@@ -2595,10 +2595,11 @@ GNS_resolver_done ()
  *
  * @param name the name to check
  * @param tld the TLD to check for
- * @return GNUNET_YES or GNUNET_NO
+ * @return #GNUNET_YES or #GNUNET_NO
  */
 int
-is_tld (const char* name, const char* tld)
+is_tld (const char* name,
+        const char* tld)
 {
   size_t offset = 0;
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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