X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fgns%2Fgnunet-service-gns_resolver.c;h=1f9e1ab059331f2e27ee471ffddd9f3b2157fe55;hb=65716ac9ff8b09403e0bf55d63133fb103d28062;hp=28ec5843009bd948dfa13d49150157ce3aa41085;hpb=cc846ca686a7e2e894801b731630cfa50408b7e2;p=oweals%2Fgnunet.git diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 28ec58430..1f9e1ab05 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c @@ -1077,9 +1077,13 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh, ac->label = resolver_lookup_get_next_label (rh); /* tigger shortening */ if (NULL != rh->shorten_key) + { + GNUNET_break (0); /* FIXME suggested label*/ GNS_shorten_start (rh->ac_tail->label, + NULL, &ac->authority_info.gns_authority, rh->shorten_key); + } /* add AC to tail */ GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, rh->ac_tail, @@ -1201,6 +1205,13 @@ handle_gns2dns_result (void *cls, size_t sa_len; /* find suitable A/AAAA record */ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Received %u results for IP address of DNS server for GNS2DNS transition\n", + rd_count); + /* enable cleanup of 'rh' handle that comes next... */ + GNUNET_CONTAINER_DLL_insert (rlh_head, + rlh_tail, + rh->g2dc->rh); rh->g2dc->rh = NULL; sa = NULL; sa_len = 0; @@ -1285,6 +1296,10 @@ handle_gns2dns_result (void *cls, GNUNET_free (rh->g2dc->ns); GNUNET_free (rh->g2dc); rh->g2dc = NULL; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Will continue resolution using DNS server `%s' to resolve `%s'\n", + GNUNET_a2s (sa, sa_len), + ac->label); GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, rh->ac_tail, ac); @@ -1322,12 +1337,14 @@ handle_gns_resolution_result (void *cls, struct VpnContext *vpn_ctx; const struct GNUNET_TUN_GnsVpnRecord *vpn; const char *vname; + const char *suggested_label; struct GNUNET_HashCode vhash; int af; char scratch[UINT16_MAX]; size_t scratch_off; size_t scratch_start; size_t off; + int c2; struct GNUNET_GNSRECORD_Data rd_new[rd_count]; unsigned int rd_off; @@ -1601,7 +1618,17 @@ handle_gns_resolution_result (void *cls, /* tigger shortening */ if (NULL != rh->shorten_key) { - GNS_shorten_start (rh->ac_tail->label, + suggested_label = NULL; + for (c2 = 0; c2< rd_count; c2++) + { + if ((GNUNET_GNSRECORD_TYPE_NICK ==rd[c2].record_type) && + (rd[i].data_size > 0) && + (((const char *) rd[c2].data)[rd[c2].data_size -1] == '\0')) + suggested_label = (const char *) rd->data; + } + if (NULL != suggested_label) + GNS_shorten_start (rh->ac_tail->label, + suggested_label, &pub, rh->shorten_key); } @@ -1673,9 +1700,21 @@ handle_gns_resolution_result (void *cls, ac->label = resolver_lookup_get_next_label (rh); /* tigger shortening */ if (NULL != rh->shorten_key) - GNS_shorten_start (rh->ac_tail->label, + { + suggested_label = NULL; + for (c2 = 0; c2< rd_count; c2++) + { + if ((GNUNET_GNSRECORD_TYPE_NICK ==rd[c2].record_type) && + (rd[c2].data_size > 0) && + ((const char *) rd[c2].data)[rd[c2].data_size -1] == '\0') + suggested_label = (const char *) rd[c2].data; + } + if (NULL != suggested_label) + GNS_shorten_start (rh->ac_tail->label, + suggested_label, &ac->authority_info.gns_authority, rh->shorten_key); + } /* add AC to tail */ GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, rh->ac_tail, @@ -1689,55 +1728,36 @@ handle_gns_resolution_result (void *cls, /* resolution continues within DNS */ struct Gns2DnsContext *g2dc; char *ip; - char *at; - char *cp; char *ns; - cp = GNUNET_strndup (rd[i].data, - rd[i].data_size); - at = strchr (cp, '@'); - if (NULL == at) - { - GNUNET_break_op (0); - rh->proc (rh->proc_cls, 0, NULL); - GNS_resolver_lookup_cancel (rh); - return; - } - *at = '\0'; off = 0; - ns = GNUNET_DNSPARSER_parse_name (cp, - strlen (cp), + ns = GNUNET_DNSPARSER_parse_name (rd[i].data, + rd[i].data_size, &off); - if ( (NULL == ns) || - (off != strlen (cp)) ) - { - GNUNET_break_op (0); /* record not well-formed */ - rh->proc (rh->proc_cls, 0, NULL); - GNS_resolver_lookup_cancel (rh); - GNUNET_free (cp); - return; - } - off++; /* skip '@' */ - ip = GNUNET_DNSPARSER_parse_name (cp, - strlen (at + 1), + ip = GNUNET_DNSPARSER_parse_name (rd[i].data, + rd[i].data_size, &off); - if ( (NULL == ip) || + if ( (NULL == ns) || + (NULL == ip) || (off != rd[i].data_size) ) { - GNUNET_break_op (0); /* record not well-formed */ - rh->proc (rh->proc_cls, 0, NULL); - GNS_resolver_lookup_cancel (rh); - GNUNET_free (ns); - GNUNET_free (cp); + GNUNET_break_op (0); + GNUNET_free_non_null (ns); + GNUNET_free_non_null (ip); + rh->proc (rh->proc_cls, 0, NULL); + GNS_resolver_lookup_cancel (rh); return; } - GNUNET_free (cp); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Resolving `%s' to determine IP address of DNS server for GNS2DNS transition\n", + ip); /* resolve 'ip' to determine the IP(s) of the DNS resolver to use */ g2dc = GNUNET_new (struct Gns2DnsContext); g2dc->ns = ns; g2dc->rh = GNUNET_new (struct GNS_ResolverHandle); g2dc->rh->authority_zone = rh->ac_tail->authority_info.gns_authority; + ip = translate_dot_plus (rh, ip); g2dc->rh->name = ip; g2dc->rh->name_resolution_pos = strlen (ip); g2dc->rh->proc = &handle_gns2dns_result;