gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: truly use all DNS results f


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: truly use all DNS results for NS lookup
Date: Sun, 13 May 2018 19:01:32 +0200

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 787ad33cb truly use all DNS results for NS lookup
787ad33cb is described below

commit 787ad33cb683431e22a236b890f0e349e1d3f8fb
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun May 13 19:01:30 2018 +0200

    truly use all DNS results for NS lookup
---
 src/dns/dnsstub.c                     |  5 ++--
 src/gns/gnunet-service-gns_resolver.c | 55 ++++++++++++++++++++++++++---------
 src/gnsrecord/gnsrecord.c             |  3 +-
 3 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/src/dns/dnsstub.c b/src/dns/dnsstub.c
index 6eb3612c2..647ce70cc 100644
--- a/src/dns/dnsstub.c
+++ b/src/dns/dnsstub.c
@@ -508,9 +508,10 @@ transmit_query (void *cls)
                                     sa,
                                     salen))
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("Failed to send DNS request to %s\n"),
+               _("Failed to send DNS request to %s: %s\n"),
                GNUNET_a2s (sa,
-                            salen));
+                            salen),
+                STRERROR (errno));
   else
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                _("Sent DNS request to %s\n"),
diff --git a/src/gns/gnunet-service-gns_resolver.c 
b/src/gns/gnunet-service-gns_resolver.c
index 92e03bc69..71d4e95d8 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -109,6 +109,11 @@ struct Gns2DnsPending
    * Handle for DNS resolution of the DNS nameserver.
    */
   struct GNUNET_RESOLVER_RequestHandle *dns_rh;
+
+  /**
+   * How many results did we get?
+   */
+  unsigned int num_results;
 };
 
 
@@ -1494,26 +1499,48 @@ handle_gns2dns_ip (void *cls,
 {
   struct Gns2DnsPending *gp = cls;
   struct AuthorityChain *ac = gp->ac;
+  struct sockaddr_storage ss;
+  struct sockaddr_in *v4;
+  struct sockaddr_in6 *v6;
 
-  GNUNET_RESOLVER_request_cancel (gp->dns_rh);
-  GNUNET_CONTAINER_DLL_remove (ac->authority_info.dns_authority.gp_head,
-                               ac->authority_info.dns_authority.gp_tail,
-                               gp);
-  GNUNET_free (gp);
   if (NULL == addr)
   {
-    /* DNS resolution failed */
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Failed to use DNS to resolve name of DNS resolver\n");
+    /* DNS resolution finished */
+    if (0 == gp->num_results)
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "Failed to use DNS to resolve name of DNS resolver\n");
+    GNUNET_CONTAINER_DLL_remove (ac->authority_info.dns_authority.gp_head,
+                                 ac->authority_info.dns_authority.gp_tail,
+                                 gp);
+    GNUNET_free (gp);
+    continue_with_gns2dns (ac);
+    return;
   }
-  else
+  memcpy (&ss,
+          addr,
+          addrlen);
+  switch (ss.ss_family)
   {
-    if (GNUNET_OK ==
-        GNUNET_DNSSTUB_add_dns_sa (ac->authority_info.dns_authority.dns_handle,
-                                   addr))
-      ac->authority_info.dns_authority.found = GNUNET_YES;
+  case AF_INET:
+    v4 = (struct sockaddr_in *) &ss;
+    v4->sin_port = htons (53);
+    gp->num_results++;
+    break;
+  case AF_INET6:
+    v6 = (struct sockaddr_in6 *) &ss;
+    v6->sin6_port = htons (53);
+    gp->num_results++;
+    break;
+  default:
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unsupported AF %d\n",
+                ss.ss_family);
+    return;
   }
-  continue_with_gns2dns (ac);
+  if (GNUNET_OK ==
+      GNUNET_DNSSTUB_add_dns_sa (ac->authority_info.dns_authority.dns_handle,
+                                 (struct sockaddr *) &ss))
+    ac->authority_info.dns_authority.found = GNUNET_YES;
 }
 
 
diff --git a/src/gnsrecord/gnsrecord.c b/src/gnsrecord/gnsrecord.c
index 35005b5ca..8fc039fc6 100644
--- a/src/gnsrecord/gnsrecord.c
+++ b/src/gnsrecord/gnsrecord.c
@@ -207,7 +207,6 @@ GNUNET_GNSRECORD_string_to_value (uint32_t type,
 uint32_t
 GNUNET_GNSRECORD_typename_to_number (const char *dns_typename)
 {
-  unsigned int i;
   struct Plugin *plugin;
   uint32_t ret;
 
@@ -215,7 +214,7 @@ GNUNET_GNSRECORD_typename_to_number (const char 
*dns_typename)
                        "ANY"))
     return GNUNET_GNSRECORD_TYPE_ANY;
   init ();
-  for (i = 0; i < num_plugins; i++)
+  for (unsigned int i = 0; i < num_plugins; i++)
   {
     plugin = gns_plugins[i];
     if (UINT32_MAX != (ret = plugin->api->typename_to_number (plugin->api->cls,

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



reply via email to

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