diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-02-16 15:03:59 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-02-16 15:03:59 +0000 |
commit | dd8fd9eba9be423a1d71bdca2e3d33c3f46924c6 (patch) | |
tree | 59363a428aca345a3665813ab1bad6688befd80f /src | |
parent | 12abf39dc040f3418b3bfc2e3888d48098ec7bbf (diff) | |
download | gnunet-dd8fd9eba9be423a1d71bdca2e3d33c3f46924c6.tar.gz gnunet-dd8fd9eba9be423a1d71bdca2e3d33c3f46924c6.zip |
if we found any non-expired block in the namecache, that is sufficient reason to not go to the DHT -- and essentially quickly return NXDOMAIN (#3325)
Diffstat (limited to 'src')
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 72 |
1 files changed, 10 insertions, 62 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index ff07a6cf0..8e4de4b7d 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -1973,10 +1973,8 @@ 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 | 1976 | * Process a records that were decrypted from a block that we got from |
1977 | * got from the namecache. If the desired record type is not | 1977 | * the namecache. Simply calls #handle_gns_resolution_result(). |
1978 | * included, we should query the DHT. Otherwise, we should | ||
1979 | * simply call #handle_gns_resolution_result(). | ||
1980 | * | 1978 | * |
1981 | * @param cls closure with the `struct GNS_ResolverHandle` | 1979 | * @param cls closure with the `struct GNS_ResolverHandle` |
1982 | * @param rd_count number of entries in @a rd array | 1980 | * @param rd_count number of entries in @a rd array |
@@ -1988,61 +1986,10 @@ handle_gns_namecache_resolution_result (void *cls, | |||
1988 | const struct GNUNET_GNSRECORD_Data *rd) | 1986 | const struct GNUNET_GNSRECORD_Data *rd) |
1989 | { | 1987 | { |
1990 | struct GNS_ResolverHandle *rh = cls; | 1988 | struct GNS_ResolverHandle *rh = cls; |
1991 | unsigned int i; | ||
1992 | int found; | ||
1993 | 1989 | ||
1994 | found = GNUNET_NO; | 1990 | handle_gns_resolution_result (rh, |
1995 | for (i=0;i<rd_count;i++) | 1991 | rd_count, |
1996 | { | 1992 | rd); |
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 | } | 1993 | } |
2047 | 1994 | ||
2048 | 1995 | ||
@@ -2140,10 +2087,11 @@ recursive_gns_resolution_namecache (struct GNS_ResolverHandle *rh) | |||
2140 | &query); | 2087 | &query); |
2141 | if (GNUNET_YES == use_cache) | 2088 | if (GNUNET_YES == use_cache) |
2142 | { | 2089 | { |
2143 | rh->namecache_qe = GNUNET_NAMECACHE_lookup_block (namecache_handle, | 2090 | rh->namecache_qe |
2144 | &query, | 2091 | = GNUNET_NAMECACHE_lookup_block (namecache_handle, |
2145 | &handle_namecache_block_response, | 2092 | &query, |
2146 | rh); | 2093 | &handle_namecache_block_response, |
2094 | rh); | ||
2147 | GNUNET_assert (NULL != rh->namecache_qe); | 2095 | GNUNET_assert (NULL != rh->namecache_qe); |
2148 | } | 2096 | } |
2149 | else | 2097 | else |