From a5a401ba8fb2f2cae3c54ef40a986d19d6934a65 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Mon, 26 Mar 2012 09:45:39 +0000 Subject: [PATCH] -fixes --- src/gns/gnunet-service-gns_resolver.c | 141 +++++++++++++++++--------- 1 file changed, 92 insertions(+), 49 deletions(-) diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 2ba10c5da..dbfebc360 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c @@ -279,49 +279,29 @@ process_auth_discovery_dht_result(void* cls, process_pseu_result(gph, NULL); } -/** - * Callback called by namestore for a zone to name - * result - * - * @param cls the closure - * @param zone_key the zone we queried - * @param expire the expiration time of the name - * @param name the name found or NULL - * @param rd_len number of records for the name - * @param rd the record data (PKEY) for the name - * @param signature the signature for the record data - */ static void -process_zone_to_name_discover(void *cls, - const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, - struct GNUNET_TIME_Absolute expire, - const char *name, - unsigned int rd_len, - const struct GNUNET_NAMESTORE_RecordData *rd, - const struct GNUNET_CRYPTO_RsaSignature *signature) +process_auth_discovery_ns_result(void* cls, + const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, + struct GNUNET_TIME_Absolute expiration, + const char *name, unsigned int rd_count, + const struct GNUNET_NAMESTORE_RecordData *rd, + const struct GNUNET_CRYPTO_RsaSignature *signature) { + uint32_t xquery; + struct GNUNET_CRYPTO_ShortHashCode name_hash; + GNUNET_HashCode lookup_key; + struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string; + GNUNET_HashCode name_hash_double; + GNUNET_HashCode zone_hash_double; + int i; struct GetPseuAuthorityHandle* gph = (struct GetPseuAuthorityHandle*)cls; - - /* we found a match in our own zone */ - if (rd_len != 0) - { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "GNS_AUTO_PSEU: name for zone in our root %d\n", strlen(name)); - GNUNET_free(gph); - } - else + + /* no pseu found */ + if (rd_count == 0) { /** - * No name found. * check dht */ - uint32_t xquery; - struct GNUNET_CRYPTO_ShortHashCode name_hash; - GNUNET_HashCode lookup_key; - struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string; - GNUNET_HashCode name_hash_double; - GNUNET_HashCode zone_hash_double; - GNUNET_CRYPTO_short_hash("+", strlen("+"), &name_hash); GNUNET_CRYPTO_short_hash_double (&name_hash, &name_hash_double); GNUNET_CRYPTO_short_hash_double (&gph->new_zone, &zone_hash_double); @@ -348,8 +328,62 @@ process_zone_to_name_discover(void *cls, sizeof(xquery), &process_auth_discovery_dht_result, gph); + return; + } + for (i=0; inew_zone, + "+", + GNUNET_GNS_RECORD_PSEU, + &process_auth_discovery_ns_result, + gph); } + + } @@ -550,7 +584,8 @@ background_lookup_result_processor(void *cls, { //We could do sth verbose/more useful here but it doesn't make any difference GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "GNS_BG: background dht lookup for finished.\n"); + "GNS_BG: background dht lookup for finished. (%d results)\n", + rd_count); } /** @@ -1002,14 +1037,16 @@ dht_authority_lookup_timeout(void *cls, * Start resolution in bg */ GNUNET_snprintf(new_name, MAX_DNS_NAME_LENGTH, - "%s.%s", rh->name, GNUNET_GNS_TLD); + "%s.%s.%s", rh->name, rh->authority_name, GNUNET_GNS_TLD); //strcpy(new_name, rh->name); //strcpy(new_name+strlen(new_name), "."); //memcpy(new_name+strlen(new_name), GNUNET_GNS_TLD, strlen(GNUNET_GNS_TLD)); + strcpy(rh->name, new_name); + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "GNS_PHASE_DELEGATE: Starting background query for %s type %d\n", - new_name, rlh->record_type); + rh->name, rlh->record_type); gns_resolver_lookup_record(rh->authority, rlh->record_type, @@ -1540,14 +1577,14 @@ handle_delegation_dht(void* cls, struct ResolverHandle *rh, if ((rlh->record_type == GNUNET_GNS_RECORD_PKEY)) { GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "GNS_PHASE_DELEGATE: Resolved queried PKEY via DHT.\n"); + "GNS_PHASE_DELEGATE_DHT: Resolved queried PKEY via DHT.\n"); finish_lookup(rh, rlh, rd_count, rd); free_resolver_handle(rh); return; } /* We resolved full name for delegation. resolving record */ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "GNS_PHASE_DELEGATE: Resolved full name for delegation via DHT.\n"); + "GNS_PHASE_DELEGATE_DHT: Resolved full name for delegation via DHT.\n"); strcpy(rh->name, "+\0"); rh->proc = &handle_record_ns; resolve_record_ns(rh); @@ -1560,7 +1597,7 @@ handle_delegation_dht(void* cls, struct ResolverHandle *rh, if (is_canonical(rh->name)) { GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "GNS_PHASE_DELEGATE: Resolving canonical record %s in ns\n", + "GNS_PHASE_DELEGATE_DHT: Resolving canonical record %s in ns\n", rh->name); rh->proc = &handle_record_ns; resolve_record_ns(rh); @@ -1568,7 +1605,7 @@ handle_delegation_dht(void* cls, struct ResolverHandle *rh, } /* give up, cannot resolve */ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "GNS_PHASE_DELEGATE: Cannot fully resolve delegation for %s via DHT!\n", + "GNS_PHASE_DELEGATE_DHT: Cannot fully resolve delegation for %s via DHT!\n", rh->name); finish_lookup(rh, rlh, 0, NULL); free_resolver_handle(rh); @@ -1672,14 +1709,14 @@ handle_delegation_ns(void* cls, struct ResolverHandle *rh, { GNUNET_assert(rd_count == 1); GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "GNS_PHASE_DELEGATE: Resolved queried PKEY in NS.\n"); + "GNS_PHASE_DELEGATE_NS: Resolved queried PKEY in NS.\n"); finish_lookup(rh, rlh, rd_count, rd); free_resolver_handle(rh); return; } /* We resolved full name for delegation. resolving record */ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "GNS_PHASE_DELEGATE: Resolved full name for delegation.\n"); + "GNS_PHASE_DELEGATE_NS: Resolved full name for delegation.\n"); strcpy(rh->name, "+\0"); rh->proc = &handle_record_ns; resolve_record_ns(rh); @@ -1699,7 +1736,7 @@ handle_delegation_ns(void* cls, struct ResolverHandle *rh, if (is_canonical(rh->name)) { GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "GNS_PHASE_DELEGATE: Resolving canonical record %s\n", + "GNS_PHASE_DELEGATE_NS: Resolving canonical record %s\n", rh->name); rh->proc = &handle_record_ns; resolve_record_ns(rh); @@ -1708,15 +1745,16 @@ handle_delegation_ns(void* cls, struct ResolverHandle *rh, { /* give up, cannot resolve */ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "GNS_PHASE_DELEGATE: Cannot fully resolve delegation for %s!\n", + "GNS_PHASE_DELEGATE_NS: Cannot fully resolve delegation for %s!\n", rh->name); - rlh->proc(rlh->proc_cls, 0, NULL); + finish_lookup(rh, rlh, rd_count, rd); + //rlh->proc(rlh->proc_cls, 0, NULL); } return; } GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "GNS_PHASE_DELEGATE: Trying to resolve delegation for %s via DHT\n", + "GNS_PHASE_DELEGATE_NS: Trying to resolve delegation for %s via DHT\n", rh->name); rh->proc = &handle_delegation_dht; resolve_delegation_dht(rh); @@ -1857,6 +1895,11 @@ process_delegation_result_ns(void* cls, rh->authority_chain_tail, auth); + /** try to import pkey if private key available */ + if (rh->priv_key) + process_discovered_authority((char*)name, auth->zone, + rh->authority_chain_tail->zone, + rh->priv_key); /** * We are done with PKEY resolution if name is empty * else resolve again with new authority -- 2.25.1