diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-05-13 19:01:30 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-05-13 19:01:30 +0200 |
commit | 787ad33cb683431e22a236b890f0e349e1d3f8fb (patch) | |
tree | 724471db8644db22270942dd7a84a48ff124960c /src | |
parent | fb77da9477657e2dc077595da2b2a38c52d2123e (diff) | |
download | gnunet-787ad33cb683431e22a236b890f0e349e1d3f8fb.tar.gz gnunet-787ad33cb683431e22a236b890f0e349e1d3f8fb.zip |
truly use all DNS results for NS lookup
Diffstat (limited to 'src')
-rw-r--r-- | src/dns/dnsstub.c | 5 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 55 | ||||
-rw-r--r-- | 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) | |||
508 | sa, | 508 | sa, |
509 | salen)) | 509 | salen)) |
510 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 510 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
511 | _("Failed to send DNS request to %s\n"), | 511 | _("Failed to send DNS request to %s: %s\n"), |
512 | GNUNET_a2s (sa, | 512 | GNUNET_a2s (sa, |
513 | salen)); | 513 | salen), |
514 | STRERROR (errno)); | ||
514 | else | 515 | else |
515 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 516 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
516 | _("Sent DNS request to %s\n"), | 517 | _("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 | |||
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 | ||
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, | |||
207 | uint32_t | 207 | uint32_t |
208 | GNUNET_GNSRECORD_typename_to_number (const char *dns_typename) | 208 | GNUNET_GNSRECORD_typename_to_number (const char *dns_typename) |
209 | { | 209 | { |
210 | unsigned int i; | ||
211 | struct Plugin *plugin; | 210 | struct Plugin *plugin; |
212 | uint32_t ret; | 211 | uint32_t ret; |
213 | 212 | ||
@@ -215,7 +214,7 @@ GNUNET_GNSRECORD_typename_to_number (const char *dns_typename) | |||
215 | "ANY")) | 214 | "ANY")) |
216 | return GNUNET_GNSRECORD_TYPE_ANY; | 215 | return GNUNET_GNSRECORD_TYPE_ANY; |
217 | init (); | 216 | init (); |
218 | for (i = 0; i < num_plugins; i++) | 217 | for (unsigned int i = 0; i < num_plugins; i++) |
219 | { | 218 | { |
220 | plugin = gns_plugins[i]; | 219 | plugin = gns_plugins[i]; |
221 | if (UINT32_MAX != (ret = plugin->api->typename_to_number (plugin->api->cls, | 220 | if (UINT32_MAX != (ret = plugin->api->typename_to_number (plugin->api->cls, |