*/
uint32_t id GNUNET_PACKED;
+ /**
+ * Only check cached results
+ */
+ uint32_t only_cached GNUNET_PACKED;
+
/**
* Should we look up in the default zone?
*/
* @param zone the zone to start the resolution in
* @param shorten_zone the zone where to shorten names into
* @param type the record type to look up
+ * @param only_cached GNUNET_NO to only check locally not DHT for performance
* @param proc processor to call on result
* @param proc_cls closure for processor
* @return handle to the get
struct GNUNET_CRYPTO_ShortHashCode *zone,
struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
enum GNUNET_GNS_RecordType type,
+ int only_cached,
GNUNET_GNS_LookupResultProcessor proc,
void *proc_cls)
{
lookup_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_LOOKUP);
lookup_msg->header.size = htons (msize);
lookup_msg->id = htonl(qe->r_id);
+ lookup_msg->only_cached = htonl(only_cached);
if (NULL != zone)
{
* @param handle handle to the GNS service
* @param name the name to look up
* @param type the record type to look up
+ * @param only_cached GNUNET_NO to only check locally not DHT for performance
* @param proc processor to call on result
* @param proc_cls closure for processor
* @return handle to the get
GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
const char * name,
enum GNUNET_GNS_RecordType type,
+ int only_cached,
GNUNET_GNS_LookupResultProcessor proc,
void *proc_cls)
{
return GNUNET_GNS_lookup_zone (handle, name,
NULL, NULL,
- type, proc, proc_cls);
+ type, only_cached, proc, proc_cls);
}
/**
if (ctask->mhd->is_ssl)
{
phost = (struct hostent*)gethostbyname (ctask->host);
- ssl_ip = inet_ntoa(*((struct in_addr*)(phost->h_addr)));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "SSL target server: %s\n", ssl_ip);
- sprintf (resolvename, "%s:%d:%s", ctask->leho, HTTPS_PORT, ssl_ip);
- ctask->resolver = curl_slist_append ( ctask->resolver, resolvename);
- curl_easy_setopt (ctask->curl, CURLOPT_RESOLVE, ctask->resolver);
- sprintf (curlurl, "https://%s%s", ctask->leho, ctask->url);
- curl_easy_setopt (ctask->curl, CURLOPT_URL, curlurl);
+
+ if (phost!=NULL)
+ {
+ ssl_ip = inet_ntoa(*((struct in_addr*)(phost->h_addr)));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "SSL target server: %s\n", ssl_ip);
+ sprintf (resolvename, "%s:%d:%s", ctask->leho, HTTPS_PORT, ssl_ip);
+ ctask->resolver = curl_slist_append ( ctask->resolver, resolvename);
+ curl_easy_setopt (ctask->curl, CURLOPT_RESOLVE, ctask->resolver);
+ sprintf (curlurl, "https://%s%s", ctask->leho, ctask->url);
+ curl_easy_setopt (ctask->curl, CURLOPT_URL, curlurl);
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "gethostbyname failed for %s!\n", ctask->host);
+ ctask->download_successful = GNUNET_NO;
+ ctask->download_error = GNUNET_YES;
+ return;
+ }
}
if (CURLM_OK != (mret=curl_multi_add_handle (curl_multi, ctask->curl)))
&local_gns_zone,
&local_shorten_zone,
GNUNET_GNS_RECORD_LEHO,
+ GNUNET_YES, //Only cached for performance
&process_leho_lookup,
ctask);
}
struct GNUNET_CRYPTO_ShortHashCode *zone = NULL;
struct GNUNET_CRYPTO_ShortHashCode *shorten_zone = NULL;
struct GNUNET_CRYPTO_ShortHashCode user_zone;
+ struct GNUNET_CRYPTO_ShortHashCode user_shorten_zone;
struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename;
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
GNUNET_CRYPTO_rsa_key_get_public (key, &pkey);
GNUNET_CRYPTO_short_hash(&pkey,
sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
- &user_zone);
- shorten_zone = &user_zone;
+ &user_shorten_zone);
+ shorten_zone = &user_shorten_zone;
GNUNET_CRYPTO_short_hash_to_enc (shorten_zone, &zonename);
if (!raw)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Using zone: %s!\n", &zonename);
+ "Using shorten zone: %s!\n", &zonename);
GNUNET_CRYPTO_rsa_key_free(key);
}
GNUNET_free(keyfile);
GNUNET_GNS_lookup_zone (gns, lookup_name,
zone, shorten_zone,
rtype,
+ GNUNET_YES, //Use DHT
&process_lookup_result, lookup_name);
}
char* nameptr = name;
struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL;
struct GNUNET_CRYPTO_ShortHashCode zone;
+ int only_cached;
if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientLookupMessage))
{
clh->unique_id = sh_msg->id;
clh->type = ntohl(sh_msg->type);
clh->shorten_key = NULL;
+
+ only_cached = ntohl(sh_msg->only_cached);
if (strlen (name) > MAX_DNS_NAME_LENGTH) {
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
gns_resolver_lookup_record(zone, zone, clh->type, name,
key,
default_lookup_timeout,
+ only_cached,
&send_lookup_response, clh);
}
else
gns_resolver_lookup_record(zone, zone, clh->type, name,
NULL,
default_lookup_timeout,
+ only_cached,
&send_lookup_response, clh);
}
}
gns_resolver_lookup_record(our_zone, our_zone, q->type, q->name,
our_key,
default_lookup_timeout,
+ GNUNET_NO,
&reply_to_dns, ilh);
}
new_name,
rh->priv_key,
GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_NO,
&background_lookup_result_processor,
NULL);
rh->timeout_task = GNUNET_SCHEDULER_NO_TASK;
new_name,
rh->priv_key,
GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_NO,
&background_lookup_result_processor,
NULL);
rh->status);
/**
- * There are 4 conditions that have to met for us to consult the DHT:
+ * There are 5 conditions that have to met for us to consult the DHT:
* 1. The entry in the DHT is RSL_RECORD_EXPIRED AND
* 2. No entry in the NS existed AND
* 3. The zone queried is not the local resolver's zone AND
* because if it was any other canonical name we either already queried
* the DHT for the authority in the authority lookup phase (and thus
* would already have an entry in the NS for the record)
+ * 5. We are not in cache only mode
*/
if (rh->status & (RSL_RECORD_EXPIRED | !RSL_RECORD_EXISTS) &&
GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone,
&rh->private_local_zone) &&
- (strcmp(rh->name, "+") == 0))
+ (strcmp(rh->name, "+") == 0) &&
+ (rh->only_cached == GNUNET_NO))
{
rh->proc = &handle_record_dht;
resolve_record_dht(rh);
}
return;
}
+
+ if (rh->only_cached == GNUNET_YES)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "GNS_PHASE_DELEGATE_NS-%llu: Only cache resolution, no result\n",
+ rh->id, rh->name);
+ finish_lookup(rh, rlh, rd_count, rd);
+ return;
+ }
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"GNS_PHASE_DELEGATE_NS-%llu: Trying to resolve delegation for %s via DHT\n",
* @param name the name to look up
* @param key a private key for use with PSEU import (can be NULL)
* @param timeout timeout for resolution
+ * @param only_cached GNUNET_NO to only check locally not DHT for performance
* @param proc the processor to call on result
* @param cls the closure to pass to proc
*/
const char* name,
struct GNUNET_CRYPTO_RsaPrivateKey *key,
struct GNUNET_TIME_Relative timeout,
+ int only_cached,
RecordLookupProcessor proc,
void* cls)
{
rh->timeout = timeout;
rh->get_handle = NULL;
rh->private_local_zone = pzone;
+ rh->only_cached = only_cached;
if (timeout.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
{
/* has this query been answered? how many matches */
int answered;
+ /* Use only cache */
+ int only_cached;
+
/* the authoritative zone to query */
struct GNUNET_CRYPTO_ShortHashCode authority;
* @param name the name to look up
* @param key optional private key for authority caching
* @param timeout timeout for the resolution
+ * @param only_cached GNUNET_NO to only check locally not DHT for performance
* @param proc the processor to call
* @param cls the closure to pass to proc
*/
const char* name,
struct GNUNET_CRYPTO_RsaPrivateKey *key,
struct GNUNET_TIME_Relative timeout,
+ int only_cached,
RecordLookupProcessor proc,
void* cls);
* @param handle handle to the GNS service
* @param name the name to look up
* @param type the GNUNET_GNS_RecordType to look for
+ * @param only_cached GNUNET_NO to only check locally not DHT for performance
* @param proc function to call on result
* @param proc_cls closure for processor
*
GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
const char * name,
enum GNUNET_GNS_RecordType type,
+ int only_cached,
GNUNET_GNS_LookupResultProcessor proc,
void *proc_cls);
* @param zone the zone to start the resolution in
* @param shorten_zone the zone where to shorten names into
* @param type the GNUNET_GNS_RecordType to look for
+ * @param only_cached GNUNET_NO to only check locally not DHT for performance
* @param proc function to call on result
* @param proc_cls closure for processor
*
struct GNUNET_CRYPTO_ShortHashCode *zone,
struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
enum GNUNET_GNS_RecordType type,
+ int only_cached,
GNUNET_GNS_LookupResultProcessor proc,
void *proc_cls);