*/
uint32_t id GNUNET_PACKED;
+ /**
+ * Should we look up in the default zone?
+ */
+ uint32_t use_default_zone GNUNET_PACKED;
+
+ /**
+ * If use_default_zone is empty this zone is used for lookup
+ */
+ struct GNUNET_CRYPTO_ShortHashCode zone;
+
/**
* the type of record to look up
*/
- // FIXME: bad type - should be of GNUNET_GNS_RecordType
enum GNUNET_GNS_RecordType type;
/* Followed by the name to look up */
*/
uint32_t id GNUNET_PACKED;
+ /**
+ * Should we look up in the default zone?
+ */
+ uint32_t use_default_zone GNUNET_PACKED;
+
+ /**
+ * If use_default_zone is empty this zone is used for lookup
+ */
+ struct GNUNET_CRYPTO_ShortHashCode zone;
+
/* Followed by the name to shorten up */
};
*
* @param handle handle to the GNS service
* @param name the name to look up
+ * @param zone the zone to start the resolution in
* @param type the record type to look up
* @param proc processor to call on result
* @param proc_cls closure for processor
* @return handle to the get
*/
struct GNUNET_GNS_QueueEntry *
-GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
+GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
const char * name,
+ struct GNUNET_CRYPTO_ShortHashCode *zone,
enum GNUNET_GNS_RecordType type,
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);
+
+ if (NULL != zone)
+ {
+ lookup_msg->use_default_zone = htonl(0);
+ memcpy(&lookup_msg->zone, zone, sizeof(struct GNUNET_CRYPTO_ShortHashCode));
+ }
+ else
+ {
+ lookup_msg->use_default_zone = htonl(1);
+ memset(&lookup_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode));
+ }
+
lookup_msg->type = htonl(type);
memcpy(&lookup_msg[1], name, strlen(name));
return qe;
}
+/**
+ * Perform an asynchronous Lookup operation on the GNS.
+ *
+ * @param handle handle to the GNS service
+ * @param name the name to look up
+ * @param type the record type to look up
+ * @param proc processor to call on result
+ * @param proc_cls closure for processor
+ * @return handle to the get
+ */
+struct GNUNET_GNS_QueueEntry *
+GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
+ const char * name,
+ enum GNUNET_GNS_RecordType type,
+ GNUNET_GNS_LookupResultProcessor proc,
+ void *proc_cls)
+{
+ return GNUNET_GNS_lookup_zone (handle, name, NULL, type, proc, proc_cls);
+}
/**
* Perform a name shortening operation on the GNS.
*
* @param handle handle to the GNS service
* @param name the name to look up
+ * @param zone the zone to start the resolution in
* @param proc function to call on result
* @param proc_cls closure for processor
* @return handle to the operation
*/
struct GNUNET_GNS_QueueEntry *
-GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
+GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
const char * name,
+ struct GNUNET_CRYPTO_ShortHashCode *zone,
GNUNET_GNS_ShortenResultProcessor proc,
void *proc_cls)
{
shorten_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_SHORTEN);
shorten_msg->header.size = htons (msize);
shorten_msg->id = htonl(qe->r_id);
+
+ if (NULL != zone)
+ {
+ shorten_msg->use_default_zone = htonl(0);
+ memcpy(&shorten_msg->zone, zone,
+ sizeof(struct GNUNET_CRYPTO_ShortHashCode));
+ }
+ else
+ {
+ shorten_msg->use_default_zone = htonl(1);
+ memset(&shorten_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode));
+ }
memcpy(&shorten_msg[1], name, strlen(name));
return qe;
}
-
+/**
+ * Perform a name shortening operation on the GNS.
+ *
+ * @param handle handle to the GNS service
+ * @param name the name to look up
+ * @param proc function to call on result
+ * @param proc_cls closure for processor
+ * @return handle to the operation
+ */
+struct GNUNET_GNS_QueueEntry *
+GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
+ const char * name,
+ GNUNET_GNS_ShortenResultProcessor proc,
+ void *proc_cls)
+{
+ return GNUNET_GNS_shorten_zone (handle, name, NULL, proc, proc_cls);
+}
/**
* Perform an authority lookup for a given name.
*
/* request type */
enum GNUNET_GNS_RecordType type;
+ /* optional zone private key used for lookup */
+ struct GNUNET_CRYPTO_RsaPrivateKey *zone_key;
+
/* name to shorten */
char* name;
/* request type */
enum GNUNET_GNS_RecordType type;
+ /* optional zone private key used for lookup */
+ struct GNUNET_CRYPTO_RsaPrivateKey *zone_key;
+
/* the name to look up */
char* name; //Needed?
};
NULL);
}
+/**
+ * Lookup the private key for the zone
+ *
+ * @param zone the zone we want a private key for
+ * @return NULL of not found else the key
+ */
+struct GNUNET_CRYPTO_RsaPrivateKey*
+lookup_private_key(struct GNUNET_CRYPTO_ShortHashCode *zone)
+{
+ char* keydir;
+ struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename;
+ char* location;
+ struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL;
+
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (GNS_cfg,
+ "namestore",
+ "ZONEFILE_DIRECTORY", &keydir))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "No zonefile directory!\n");
+ return NULL;
+ }
+
+ GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename);
+
+ GNUNET_asprintf(&location, "%s%s%s.zkey", keydir,
+ DIR_SEPARATOR_STR, zonename);
+
+ if (GNUNET_YES == GNUNET_DISK_file_test (location))
+ key = GNUNET_CRYPTO_rsa_key_create_from_file (location);
+
+ GNUNET_free(location);
+ GNUNET_free(keydir);
+
+ return key;
+
+}
/* END DHT ZONE PROPAGATION */
GNUNET_free(rmsg);
GNUNET_free_non_null(csh->name);
+ GNUNET_free_non_null(csh->zone_key);
GNUNET_free(csh);
}
struct ClientShortenHandle *csh;
char name[MAX_DNS_NAME_LENGTH];
char* nameptr = name;
+ struct GNUNET_CRYPTO_ShortHashCode zone;
+ struct GNUNET_CRYPTO_RsaPrivateKey *key;
if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientShortenMessage))
{
csh = GNUNET_malloc(sizeof(struct ClientShortenHandle));
csh->client = client;
csh->unique_id = sh_msg->id;
+ csh->zone_key = NULL;
GNUNET_STRINGS_utf8_tolower((char*)&sh_msg[1], &nameptr);
GNUNET_SERVER_notification_context_add (nc, client);
+ if (1 == ntohl(sh_msg->use_default_zone))
+ zone = zone_hash; //Default zone
+ else
+ zone = sh_msg->zone;
+
/* Start shortening */
if (GNUNET_YES == auto_import_pkey)
- gns_resolver_shorten_name(zone_hash, name, zone_key,
+ {
+ if (1 == ntohl(sh_msg->use_default_zone))
+ key = zone_key;
+ else
+ {
+ key = lookup_private_key(&sh_msg->zone);
+ csh->zone_key = key;
+ }
+ gns_resolver_shorten_name(zone, name, key,
&send_shorten_response, csh);
+ }
else
- gns_resolver_shorten_name(zone_hash, name, NULL,
+ gns_resolver_shorten_name(zone, name, NULL,
&send_shorten_response, csh);
}
}
+
/**
* Reply to client with the result from our lookup.
*
GNUNET_free(rmsg);
GNUNET_free(clh->name);
+
+ if (NULL != clh->zone_key)
+ GNUNET_free(clh->zone_key);
+
GNUNET_free(clh);
}
char name[MAX_DNS_NAME_LENGTH];
struct ClientLookupHandle *clh;
char* nameptr = name;
+ struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL;
+ struct GNUNET_CRYPTO_ShortHashCode zone;
if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientLookupMessage))
{
strcpy(clh->name, name);
clh->unique_id = sh_msg->id;
clh->type = ntohl(sh_msg->type);
+ clh->zone_key = NULL;
if (strlen (name) > MAX_DNS_NAME_LENGTH) {
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
send_lookup_response(clh, 0, NULL);
return;
}
+
+ if (1 == ntohl(sh_msg->use_default_zone))
+ zone = zone_hash; //Default zone
+ else
+ zone = sh_msg->zone;
if (GNUNET_YES == auto_import_pkey)
{
- gns_resolver_lookup_record(zone_hash, clh->type, name,
- zone_key,
+ if (1 == ntohl(sh_msg->use_default_zone))
+ key = zone_key;
+ else
+ {
+ key = lookup_private_key(&sh_msg->zone);
+ clh->zone_key = key;
+ }
+
+ gns_resolver_lookup_record(zone, clh->type, name,
+ key,
default_lookup_timeout,
&send_lookup_response, clh);
}
else
{
- gns_resolver_lookup_record(zone_hash, clh->type, name,
+ gns_resolver_lookup_record(zone, clh->type, name,
NULL,
default_lookup_timeout,
&send_lookup_response, clh);
{&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0}
};
+ GNS_cfg = c;
+
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "gns",
"ZONEKEY", &keyfile))
{
/**
- * Perform an asynchronous lookup operation on the GNS.
+ * Perform an asynchronous lookup operation on the GNS
+ * in the default zone.
*
* @param handle handle to the GNS service
* @param name the name to look up
GNUNET_GNS_LookupResultProcessor proc,
void *proc_cls);
+/**
+ * Perform an asynchronous lookup operation on the GNS
+ * in the zone specified by 'zone'.
+ *
+ * @param handle handle to the GNS service
+ * @param name the name to look up
+ * @param zone the zone to start the resolution in
+ * @param type the GNUNET_GNS_RecordType to look for
+ * @param proc function to call on result
+ * @param proc_cls closure for processor
+ *
+ * @return handle to the queued request
+ */
+struct GNUNET_GNS_QueueEntry *
+GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
+ const char * name,
+ struct GNUNET_CRYPTO_ShortHashCode *zone,
+ enum GNUNET_GNS_RecordType type,
+ GNUNET_GNS_LookupResultProcessor proc,
+ void *proc_cls);
/* *************** Standard API: shorten ******************* */
void *proc_cls);
+/**
+ * Perform a name shortening operation on the GNS.
+ *
+ * @param handle handle to the GNS service
+ * @param name the name to look up
+ * @param zone the zone to start the resolution in
+ * @param proc function to call on result
+ * @param proc_cls closure for processor
+ * @return handle to the operation
+ */
+struct GNUNET_GNS_QueueEntry *
+GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
+ const char * name,
+ struct GNUNET_CRYPTO_ShortHashCode *zone,
+ GNUNET_GNS_ShortenResultProcessor proc,
+ void *proc_cls);
+
/* *************** Standard API: get authority ******************* */