aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-05-13 19:01:30 +0200
committerChristian Grothoff <christian@grothoff.org>2018-05-13 19:01:30 +0200
commit787ad33cb683431e22a236b890f0e349e1d3f8fb (patch)
tree724471db8644db22270942dd7a84a48ff124960c /src/gns
parentfb77da9477657e2dc077595da2b2a38c52d2123e (diff)
downloadgnunet-787ad33cb683431e22a236b890f0e349e1d3f8fb.tar.gz
gnunet-787ad33cb683431e22a236b890f0e349e1d3f8fb.zip
truly use all DNS results for NS lookup
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gnunet-service-gns_resolver.c55
1 files changed, 41 insertions, 14 deletions
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
109 * Handle for DNS resolution of the DNS nameserver. 109 * Handle for DNS resolution of the DNS nameserver.
110 */ 110 */
111 struct GNUNET_RESOLVER_RequestHandle *dns_rh; 111 struct GNUNET_RESOLVER_RequestHandle *dns_rh;
112
113 /**
114 * How many results did we get?
115 */
116 unsigned int num_results;
112}; 117};
113 118
114 119
@@ -1494,26 +1499,48 @@ handle_gns2dns_ip (void *cls,
1494{ 1499{
1495 struct Gns2DnsPending *gp = cls; 1500 struct Gns2DnsPending *gp = cls;
1496 struct AuthorityChain *ac = gp->ac; 1501 struct AuthorityChain *ac = gp->ac;
1502 struct sockaddr_storage ss;
1503 struct sockaddr_in *v4;
1504 struct sockaddr_in6 *v6;
1497 1505
1498 GNUNET_RESOLVER_request_cancel (gp->dns_rh);
1499 GNUNET_CONTAINER_DLL_remove (ac->authority_info.dns_authority.gp_head,
1500 ac->authority_info.dns_authority.gp_tail,
1501 gp);
1502 GNUNET_free (gp);
1503 if (NULL == addr) 1506 if (NULL == addr)
1504 { 1507 {
1505 /* DNS resolution failed */ 1508 /* DNS resolution finished */
1506 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1509 if (0 == gp->num_results)
1507 "Failed to use DNS to resolve name of DNS resolver\n"); 1510 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1511 "Failed to use DNS to resolve name of DNS resolver\n");
1512 GNUNET_CONTAINER_DLL_remove (ac->authority_info.dns_authority.gp_head,
1513 ac->authority_info.dns_authority.gp_tail,
1514 gp);
1515 GNUNET_free (gp);
1516 continue_with_gns2dns (ac);
1517 return;
1508 } 1518 }
1509 else 1519 memcpy (&ss,
1520 addr,
1521 addrlen);
1522 switch (ss.ss_family)
1510 { 1523 {
1511 if (GNUNET_OK == 1524 case AF_INET:
1512 GNUNET_DNSSTUB_add_dns_sa (ac->authority_info.dns_authority.dns_handle, 1525 v4 = (struct sockaddr_in *) &ss;
1513 addr)) 1526 v4->sin_port = htons (53);
1514 ac->authority_info.dns_authority.found = GNUNET_YES; 1527 gp->num_results++;
1528 break;
1529 case AF_INET6:
1530 v6 = (struct sockaddr_in6 *) &ss;
1531 v6->sin6_port = htons (53);
1532 gp->num_results++;
1533 break;
1534 default:
1535 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1536 "Unsupported AF %d\n",
1537 ss.ss_family);
1538 return;
1515 } 1539 }
1516 continue_with_gns2dns (ac); 1540 if (GNUNET_OK ==
1541 GNUNET_DNSSTUB_add_dns_sa (ac->authority_info.dns_authority.dns_handle,
1542 (struct sockaddr *) &ss))
1543 ac->authority_info.dns_authority.found = GNUNET_YES;
1517} 1544}
1518 1545
1519 1546