aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-12-20 21:14:32 +0000
committerChristian Grothoff <christian@grothoff.org>2013-12-20 21:14:32 +0000
commitc56383042a5948c39c1cc84520d584cf166fad30 (patch)
treea90cf33258eb12c87bfe8375a2e9a5e79cfb0a17 /src/gns
parent8e50512f10df78eaffdcce24ce6f247b48540d15 (diff)
downloadgnunet-c56383042a5948c39c1cc84520d584cf166fad30.tar.gz
gnunet-c56383042a5948c39c1cc84520d584cf166fad30.zip
if records from namecache do not match desired record type, go look in the DHT
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gnunet-service-gns_resolver.c88
1 files changed, 85 insertions, 3 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 0aff4564e..ff07a6cf0 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -1973,6 +1973,80 @@ start_dht_request (struct GNS_ResolverHandle *rh,
1973 1973
1974 1974
1975/** 1975/**
1976 * Process a records that were decrypted from a block that we
1977 * got from the namecache. If the desired record type is not
1978 * included, we should query the DHT. Otherwise, we should
1979 * simply call #handle_gns_resolution_result().
1980 *
1981 * @param cls closure with the `struct GNS_ResolverHandle`
1982 * @param rd_count number of entries in @a rd array
1983 * @param rd array of records with data to store
1984 */
1985static void
1986handle_gns_namecache_resolution_result (void *cls,
1987 unsigned int rd_count,
1988 const struct GNUNET_GNSRECORD_Data *rd)
1989{
1990 struct GNS_ResolverHandle *rh = cls;
1991 unsigned int i;
1992 int found;
1993
1994 found = GNUNET_NO;
1995 for (i=0;i<rd_count;i++)
1996 {
1997 if (rd[i].record_type == rh->record_type)
1998 {
1999 found = GNUNET_YES;
2000 break;
2001 }
2002 switch (rd[i].record_type)
2003 {
2004 case GNUNET_GNSRECORD_TYPE_VPN:
2005 if ( (GNUNET_DNSPARSER_TYPE_A == rh->record_type) ||
2006 (GNUNET_DNSPARSER_TYPE_AAAA == rh->record_type) )
2007 {
2008 found = GNUNET_YES;
2009 break;
2010 }
2011 break;
2012 case GNUNET_DNSPARSER_TYPE_CNAME:
2013 case GNUNET_GNSRECORD_TYPE_PKEY:
2014 case GNUNET_GNSRECORD_TYPE_GNS2DNS:
2015 /* delegations always count as 'found' */
2016 found = GNUNET_YES;
2017 break;
2018 default:
2019 break;
2020 }
2021 }
2022 if (GNUNET_YES == found)
2023 {
2024 handle_gns_resolution_result (rh,
2025 rd_count,
2026 rd);
2027 }
2028 else
2029 {
2030 /* try DHT */
2031 struct AuthorityChain *ac = rh->ac_tail;
2032 const char *label = ac->label;
2033 const struct GNUNET_CRYPTO_EcdsaPublicKey *auth = &ac->authority_info.gns_authority;
2034 struct GNUNET_HashCode query;
2035
2036 GNUNET_GNSRECORD_query_from_public_key (auth,
2037 label,
2038 &query);
2039 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2040 "Starting DHT lookup for `%s' in zone `%s' under key `%s'\n",
2041 ac->label,
2042 GNUNET_GNSRECORD_z2s (&ac->authority_info.gns_authority),
2043 GNUNET_h2s (&query));
2044 start_dht_request (rh, &query);
2045 }
2046}
2047
2048
2049/**
1976 * Process a record that was stored in the namecache. 2050 * Process a record that was stored in the namecache.
1977 * 2051 *
1978 * @param cls closure with the `struct GNS_ResolverHandle` 2052 * @param cls closure with the `struct GNS_ResolverHandle`
@@ -2027,12 +2101,20 @@ handle_namecache_block_response (void *cls,
2027 GNUNET_GNSRECORD_block_decrypt (block, 2101 GNUNET_GNSRECORD_block_decrypt (block,
2028 auth, 2102 auth,
2029 label, 2103 label,
2030 &handle_gns_resolution_result, 2104 &handle_gns_namecache_resolution_result,
2031 rh)) 2105 rh))
2032 { 2106 {
2033 GNUNET_break_op (0); /* block was ill-formed */ 2107 GNUNET_break_op (0); /* block was ill-formed */
2034 rh->proc (rh->proc_cls, 0, NULL); 2108 /* try DHT instead */
2035 GNS_resolver_lookup_cancel (rh); 2109 GNUNET_GNSRECORD_query_from_public_key (auth,
2110 label,
2111 &query);
2112 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2113 "Starting DHT lookup for `%s' in zone `%s' under key `%s'\n",
2114 ac->label,
2115 GNUNET_GNSRECORD_z2s (&ac->authority_info.gns_authority),
2116 GNUNET_h2s (&query));
2117 start_dht_request (rh, &query);
2036 return; 2118 return;
2037 } 2119 }
2038} 2120}