BINARY = gnunet-service-gns
UNIXPATH = /tmp/gnunet-service-gns.sock
ZONEKEY = $SERVICEHOME/gns/zonekey.zkey
-PRIVATE_ZONE = private
PRIVATE_ZONEKEY = $SERVICEHOME/gns/zonekey_priv.zkey
-SHORTEN_ZONE = short
SHORTEN_ZONEKEY = $SERVICEHOME/gns/zonekey_short.zkey
HIJACK_DNS = NO
AUTO_IMPORT_PKEY = YES
-AUTO_IMPORT_ZONEKEY = $SERVICEHOME/gns/shorten_zonekey.zkey
AUTO_IMPORT_CONFIRMATION_REQ = NO
MAX_PARALLEL_BACKGROUND_QUERIES = 25
DEFAULT_LOOKUP_TIMEOUT = 10
* If use_default_zone is empty this zone is used for lookup
*/
struct GNUNET_CRYPTO_ShortHashCode zone;
+
+ /**
+ * Shorten zone
+ */
+ struct GNUNET_CRYPTO_ShortHashCode shorten_zone;
+
+ /**
+ * Private zone
+ */
+ struct GNUNET_CRYPTO_ShortHashCode private_zone;
/* Followed by the name to shorten up */
};
*
* @param handle handle to the GNS service
* @param name the name to look up
+ * @param private_zone the public zone of the private zone
+ * @param shorten_zone the public zone of the shorten zone
* @param zone the zone to start the resolution in
* @param proc function to call on result
* @param proc_cls closure for processor
*/
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)
+ const char * name,
+ struct GNUNET_CRYPTO_ShortHashCode *private_zone,
+ struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
+ struct GNUNET_CRYPTO_ShortHashCode *zone,
+ GNUNET_GNS_ShortenResultProcessor proc,
+ void *proc_cls)
{
/* IPC to shorten gns names, return shorten_handle */
struct GNUNET_GNS_ClientShortenMessage *shorten_msg;
shorten_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_SHORTEN);
shorten_msg->header.size = htons (msize);
shorten_msg->id = htonl(qe->r_id);
+ shorten_msg->private_zone = *private_zone;
+ shorten_msg->shorten_zone = *shorten_zone;
if (NULL != zone)
{
*
* @param handle handle to the GNS service
* @param name the name to look up
+ * @param private_zone the public zone of the private zone
+ * @param shorten_zone the public zone of the shorten zone
* @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,
+ struct GNUNET_CRYPTO_ShortHashCode *private_zone,
+ struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
GNUNET_GNS_ShortenResultProcessor proc,
void *proc_cls)
{
- return GNUNET_GNS_shorten_zone (handle, name, NULL, proc, proc_cls);
+ return GNUNET_GNS_shorten_zone (handle, name,
+ private_zone, shorten_zone,
+ NULL, proc, proc_cls);
}
/**
* Perform an authority lookup for a given name.
/* The users local GNS zone hash */
static struct GNUNET_CRYPTO_ShortHashCode local_gns_zone;
+/* The users local private zone */
+static struct GNUNET_CRYPTO_ShortHashCode local_private_zone;
+
+/* The users local shorten zone */
+static struct GNUNET_CRYPTO_ShortHashCode local_shorten_zone;
+
/* The CA for SSL certificate generation */
static struct ProxyCA proxy_ca;
ctask->is_postprocessing = GNUNET_YES;
ctask->pp_finished = GNUNET_NO;
- GNUNET_GNS_shorten (gns_handle,
- ctask->pp_buf,
- &process_shorten,
- ctask);
+ GNUNET_GNS_shorten_zone (gns_handle,
+ ctask->pp_buf,
+ &local_private_zone,
+ &local_shorten_zone,
+ &local_gns_zone,
+ &process_shorten,
+ ctask);
return 0;
}
"Using zone: %s!\n", &zonename);
GNUNET_CRYPTO_rsa_key_free(key);
GNUNET_free(keyfile);
+
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
+ "PRIVATE_ZONEKEY", &keyfile))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unable to load private zone key config value!\n");
+ return GNUNET_NO;
+ }
+
+ if (GNUNET_NO == GNUNET_DISK_file_test (keyfile))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unable to load private zone key %s!\n", keyfile);
+ GNUNET_free(keyfile);
+ return GNUNET_NO;
+ }
+
+ key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+ GNUNET_CRYPTO_rsa_key_get_public (key, &pkey);
+ GNUNET_CRYPTO_short_hash(&pkey,
+ sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
+ &local_private_zone);
+ GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using private zone: %s!\n", &zonename);
+ GNUNET_CRYPTO_rsa_key_free(key);
+ GNUNET_free(keyfile);
+
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
+ "SHORTEN_ZONEKEY", &keyfile))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unable to load shorten zone key config value!\n");
+ return GNUNET_NO;
+ }
+
+ if (GNUNET_NO == GNUNET_DISK_file_test (keyfile))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unable to load shorten zone key %s!\n", keyfile);
+ GNUNET_free(keyfile);
+ return GNUNET_NO;
+ }
+
+ key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+ GNUNET_CRYPTO_rsa_key_get_public (key, &pkey);
+ GNUNET_CRYPTO_short_hash(&pkey,
+ sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
+ &local_shorten_zone);
+ GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using shorten zone: %s!\n", &zonename);
+ GNUNET_CRYPTO_rsa_key_free(key);
+ GNUNET_free(keyfile);
return GNUNET_YES;
}
struct GNUNET_CRYPTO_ShortHashCode user_zone;
struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename;
struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key = NULL;
+ struct GNUNET_CRYPTO_RsaPrivateKey *private_key = NULL;
+ struct GNUNET_CRYPTO_ShortHashCode private_zone;
+ struct GNUNET_CRYPTO_ShortHashCode shorten_zone;
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
"ZONEKEY", &keyfile))
if (GNUNET_YES == GNUNET_DISK_file_test (keyfile))
{
shorten_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+ GNUNET_CRYPTO_rsa_key_get_public (key, &pkey);
+ GNUNET_CRYPTO_short_hash(&pkey,
+ sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
+ &shorten_zone);
+ GNUNET_CRYPTO_short_hash_to_enc (&shorten_zone, &zonename);
+ if (!raw)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using shorten zone: %s!\n", &zonename);
+
+ }
+ GNUNET_free(keyfile);
+ }
+
+
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
+ "PRIVATE_ZONEKEY", &keyfile))
+ {
+ if (!raw)
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "No private zone key found!\n");
+ shorten_key = NULL;
+ }
+ else
+ {
+ if (GNUNET_YES == GNUNET_DISK_file_test (keyfile))
+ {
+ private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+ GNUNET_CRYPTO_rsa_key_get_public (key, &pkey);
+ GNUNET_CRYPTO_short_hash(&pkey,
+ sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
+ &private_zone);
+ GNUNET_CRYPTO_short_hash_to_enc (&private_zone, &zonename);
+ if (!raw)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using private zone: %s!\n", &zonename);
+
}
GNUNET_free(keyfile);
+ GNUNET_CRYPTO_rsa_key_free (private_key);
}
+
gns = GNUNET_GNS_connect (cfg);
if (lookup_type != NULL)
rtype = GNUNET_NAMESTORE_typename_to_number(lookup_type);
{
/** shorten name */
GNUNET_GNS_shorten_zone (gns, shorten_name,
+ &private_zone,
+ &shorten_zone,
zone,
&process_shorten_result,
shorten_name);
*/
struct ClientShortenHandle
{
+
+ /* DLL */
+ struct ClientShortenHandle *next;
+
+ /* DLL */
+ struct ClientShortenHandle *prev;
+
/* the requesting client that */
struct GNUNET_SERVER_Client *client;
/* request type */
enum GNUNET_GNS_RecordType type;
- /* optional zone private key used for shorten */
- struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key;
-
/* name to shorten */
char name[MAX_DNS_NAME_LENGTH];
+ /* name of private zone (relative to root) */
+ char private_zone_id[MAX_DNS_NAME_LENGTH];
+
+ /* name of shorten zone (relative to root) */
+ char shorten_zone_id[MAX_DNS_NAME_LENGTH];
+
/* root zone */
struct GNUNET_CRYPTO_ShortHashCode root_zone;
/* shorten zone */
struct GNUNET_CRYPTO_ShortHashCode shorten_zone;
+
+ /* Namestore lookup task */
+ struct GNUNET_NAMESTORE_QueueEntry *namestore_task;
+
};
*/
struct ClientLookupHandle
{
+
/* the requesting client that */
struct GNUNET_SERVER_Client *client;
/* lookup timeout */
static struct GNUNET_TIME_Relative default_lookup_timeout;
-/* name of the private zone */
-static char *private_zone_id;
-
-/* name of the public zone */
-static char *shorten_zone_id;
-
/* ipv6 support */
static int v6_enabled;
/* ipv4 support */
static int v4_enabled;
+/* Shorten DLL for cancelling NS requests */
+static struct ClientShortenHandle *csh_head;
+
+/* Shorten DLL for cancelling NS requests */
+static struct ClientShortenHandle *csh_tail;
+
+/**
+ * Send shorten response back to client
+ *
+ * @param cls the closure containing a client shorten handle
+ * @param name the shortened name result or NULL if cannot be shortened
+ */
+static void
+send_shorten_response(void* cls, const char* name);
+
+
/**
* Continue shutdown
*/
static void
shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ struct ClientShortenHandle *csh_tmp = csh_head;
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Shutting down!");
+ while (csh_tmp != NULL)
+ {
+ GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh_tmp);
+ send_shorten_response (csh_tmp, csh_tmp->name);
+ }
GNUNET_SERVER_notification_context_destroy (nc);
(const struct GNUNET_MessageHeader *) rmsg,
GNUNET_NO);
GNUNET_SERVER_receive_done (csh->client, GNUNET_OK);
+
+ if (NULL != csh->namestore_task)
+ GNUNET_NAMESTORE_cancel (csh->namestore_task);
GNUNET_free(rmsg);
- GNUNET_free_non_null(csh->shorten_key);
GNUNET_free(csh);
}
+/**
+ * Lookup the zone infos and shorten name
+ *
+ * @param csh the shorten handle
+ *
+ */
static void
-process_shorten_zone_shorten (void *cls,
+process_shorten_in_private_zone_lookup (void *cls,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key,
struct GNUNET_TIME_Absolute expiration,
const char *name,
const struct GNUNET_CRYPTO_RsaSignature *signature)
{
struct ClientShortenHandle *csh = cls;
- struct GNUNET_TIME_Relative remaining_time;
- struct GNUNET_TIME_Absolute et;
+ csh->namestore_task = NULL;
+ struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone;
+ struct GNUNET_CRYPTO_ShortHashCode *pzone = &csh->private_zone;
+
+ if (0 == strcmp (csh->private_zone_id, ""))
+ pzone = NULL;
+
+ if (rd_count == 0)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "No shorten zone in private zone!\n");
- remaining_time = GNUNET_TIME_absolute_get_remaining (expiration);
+ strcpy (csh->shorten_zone_id, "");
+ szone = NULL;
- if ((rd_count == 1) &&
- (remaining_time.rel_value != 0))
+ }
+ else
{
- GNUNET_break (0 == (rd->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
- et.abs_value = rd->expiration_time;
- remaining_time = GNUNET_TIME_absolute_get_remaining (et);
- if ((rd->record_type == GNUNET_GNS_RECORD_PKEY) &&
- (remaining_time.rel_value != 0))
- {
- csh->shorten_zone = *((struct GNUNET_CRYPTO_ShortHashCode*)rd->data);
- }
+
+ GNUNET_assert (rd_count == 1);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Shorten zone %s found in private zone %s\n",
+ name, csh->private_zone_id);
+
+ sprintf (csh->shorten_zone_id, "%s.%s", name, csh->private_zone_id);
}
+
+ GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh);
+
gns_resolver_shorten_name (&csh->root_zone,
- &csh->private_zone,
- &csh->shorten_zone,
+ pzone,
+ szone,
csh->name,
- private_zone_id,
- shorten_zone_id,
+ csh->private_zone_id,
+ csh->shorten_zone_id,
&send_shorten_response, csh);
}
+/**
+ * Lookup the zone infos and shorten name
+ *
+ * @param csh the shorten handle
+ *
+ */
static void
-process_private_zone_shorten (void *cls,
+process_shorten_in_root_zone_lookup (void *cls,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key,
struct GNUNET_TIME_Absolute expiration,
const char *name,
const struct GNUNET_NAMESTORE_RecordData *rd,
const struct GNUNET_CRYPTO_RsaSignature *signature)
{
- struct GNUNET_TIME_Relative remaining_time;
struct ClientShortenHandle *csh = cls;
- struct GNUNET_TIME_Absolute et;
-
- remaining_time = GNUNET_TIME_absolute_get_remaining (expiration);
+ csh->namestore_task = NULL;
+ struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone;
+ struct GNUNET_CRYPTO_ShortHashCode *pzone = &csh->private_zone;
+
+ if (0 == strcmp (csh->private_zone_id, ""))
+ pzone = NULL;
- if ((rd_count == 1) &&
- (remaining_time.rel_value != 0))
+ if (rd_count == 0)
{
- GNUNET_break (0 == (rd->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
- et.abs_value = rd->expiration_time;
- remaining_time = GNUNET_TIME_absolute_get_remaining (et);
- if ((rd->record_type == GNUNET_GNS_RECORD_PKEY) &&
- (remaining_time.rel_value != 0))
- {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "No shorten zone in zone and no private zone!\n");
+ strcpy (csh->shorten_zone_id, "");
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Looking for shorten zone in private zone\n");
- csh->private_zone = *((struct GNUNET_CRYPTO_ShortHashCode*)rd->data);
- GNUNET_NAMESTORE_lookup_record (namestore_handle,
- &csh->private_zone,
- shorten_zone_id,
- GNUNET_GNS_RECORD_ANY,
- &process_shorten_zone_shorten,
- cls);
- }
+ GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh);
+ szone = NULL;
+
+ gns_resolver_shorten_name (&csh->root_zone,
+ pzone,
+ szone,
+ csh->name,
+ csh->private_zone_id,
+ csh->shorten_zone_id,
+ &send_shorten_response, csh);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "No private zone found!\n");
- gns_resolver_shorten_name (&csh->root_zone,
- &csh->private_zone,
- &csh->shorten_zone,
- csh->name,
- private_zone_id,
- shorten_zone_id,
- &send_shorten_response, csh);
+ GNUNET_assert (rd_count == 1);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Private zone %s found in root zone\n", name);
+
+ strcpy (csh->private_zone_id, name);
+
+ csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
+ pzone,
+ szone,
+ &process_shorten_in_private_zone_lookup,
+ csh);
+}
+
+
+/**
+ * Lookup the zone infos and shorten name
+ *
+ * @param csh the shorten handle
+ *
+ */
+static void
+process_private_in_root_zone_lookup (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)
+{
+ struct ClientShortenHandle *csh = cls;
+ csh->namestore_task = NULL;
+
+ if (rd_count == 0)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "No private zone in root zone\n");
+
+ strcpy (csh->private_zone_id, "");
+
+ csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
+ &csh->root_zone,
+ &csh->shorten_zone,
+ &process_shorten_in_root_zone_lookup,
+ csh);
+ return;
+ }
+
+ GNUNET_assert (rd_count == 1);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Private zone %s found in root zone\n", name);
+
+ strcpy (csh->private_zone_id, name);
+
+ csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
+ &csh->private_zone,
+ &csh->shorten_zone,
+ &process_shorten_in_private_zone_lookup,
+ csh);
}
/**
start_shorten_name (struct ClientShortenHandle *csh)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Looking for private zone in root zone\n");
+ "Looking for private zone name in root zone\n");
- GNUNET_NAMESTORE_lookup_record (namestore_handle,
+ csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
&csh->root_zone,
- private_zone_id,
- GNUNET_GNS_RECORD_ANY,
- &process_private_zone_shorten,
+ &csh->private_zone,
+ &process_private_in_root_zone_lookup,
csh);
}
csh = GNUNET_malloc(sizeof(struct ClientShortenHandle));
csh->client = client;
csh->unique_id = sh_msg->id;
- csh->shorten_key = NULL;
+
+ GNUNET_CONTAINER_DLL_insert (csh_head, csh_tail, csh);
GNUNET_STRINGS_utf8_tolower((char*)&sh_msg[1], &nameptr);
return;
}
+ csh->shorten_zone = sh_msg->shorten_zone;
+ csh->private_zone = sh_msg->private_zone;
+
strcpy (csh->name, name);
GNUNET_SERVER_notification_context_add (nc, client);
}
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (c, "gns",
- "PRIVATE_ZONE",
- &private_zone_id))
- {
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Private zone id: %s\n", private_zone_id);
- }
-
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (c, "gns",
- "SHORTEN_ZONE",
- &shorten_zone_id))
- {
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Shorten zone id: %s\n", shorten_zone_id);
- }
-
dht_max_update_interval = GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL;
if (GNUNET_OK ==
/* we found a match in our own root zone */
if (rd_len != 0)
{
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "result strlen %d\n", strlen(name));
answer_len = strlen(rh->name) + strlen(name) + strlen(GNUNET_GNS_TLD) + 3;
memset(result, 0, answer_len);
if (strlen(rh->name) > 0)
{
- sprintf (result, "%s.%s.%s.%s.%s",
+ sprintf (result, "%s.%s.%s.%s",
rh->name, name,
- nsh->shorten_zone_name, nsh->private_zone_name,
+ nsh->shorten_zone_name,
GNUNET_GNS_TLD);
}
else
{
- sprintf (result, "%s.%s.%s.%s", name,
- nsh->shorten_zone_name, nsh->private_zone_name,
+ sprintf (result, "%s.%s.%s", name,
+ nsh->shorten_zone_name,
GNUNET_GNS_TLD);
}
* shorten to our zone to a "" record??)
*/
- sprintf (result, "%s.%s.%s.%s",
+ sprintf (result, "%s.%s.%s",
rh->name,
- nsh->shorten_zone_name, nsh->private_zone_name,
+ nsh->shorten_zone_name,
GNUNET_GNS_TLD);
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Our zone: Found %s as shorten result\n", result);
/* we found a match in our own root zone */
if (rd_len != 0)
{
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "result strlen %d\n", strlen(name));
answer_len = strlen(rh->name) + strlen(name) + strlen(GNUNET_GNS_TLD) + 3;
memset(result, 0, answer_len);
strcpy (nsh->result, result);
}
- if (nsh->shorten_zone != NULL)
+ if (0 != strcmp (nsh->shorten_zone_name, ""))
{
/* backtrack authorities for names in priv zone */
rh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
/* we found a match in our own root zone */
if (rd_len != 0)
{
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "result strlen %d\n", strlen(name));
answer_len = strlen(rh->name) + strlen(name) + strlen(GNUNET_GNS_TLD) + 3;
memset(result, 0, answer_len);
strcpy (nsh->result, result);
}
- if (nsh->private_zone != NULL)
+ if (0 != strcmp (nsh->private_zone_name, ""))
{
/* backtrack authorities for names in priv zone */
rh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
&process_zone_to_name_shorten_private,
rh);
}
+ else if (0 != strcmp (nsh->shorten_zone_name, ""))
+ {
+ /* backtrack authorities for names in shorten zone */
+ rh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
+ nsh->shorten_zone,
+ &rh->authority_chain_head->zone,
+ &process_zone_to_name_shorten_shorten,
+ rh);
+ }
else
{
/**
* (it shouldn't be, usually FIXME what happens if we
* shorten to our zone to a "" record??)
*/
+ if (0 != strcmp (nsh->private_zone_name, ""))
+ {
- sprintf (result, "%s.%s.%s",
- rh->name, nsh->private_zone_name, GNUNET_GNS_TLD);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Our zone: Found %s as shorten result %s\n", result);
+ sprintf (result, "%s.%s.%s",
+ rh->name, nsh->private_zone_name, GNUNET_GNS_TLD);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Our zone: Found %s as shorten result in private zone %s\n",
+ result);
- if (strlen (nsh->result) > strlen (result))
- strcpy (nsh->result, result);
+ if (strlen (nsh->result) > strlen (result))
+ strcpy (nsh->result, result);
+ }
}
else if (GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone,
nsh->shorten_zone) == 0)
* (it shouldn't be, usually FIXME what happens if we
* shorten to our zone to a "" record??)
*/
+ if (0 != strcmp (nsh->shorten_zone_name, ""))
+ {
+ sprintf (result, "%s.%s.%s",
+ rh->name, nsh->private_zone_name, GNUNET_GNS_TLD);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Our zone: Found %s as shorten result in shorten zone\n",
+ result);
- sprintf (result, "%s.%s.%s",
- rh->name, nsh->private_zone_name, GNUNET_GNS_TLD);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Our zone: Found %s as shorten result\n", result);
-
- if (strlen (nsh->result) > strlen (result))
- strcpy (nsh->result, result);
+ if (strlen (nsh->result) > strlen (result))
+ strcpy (nsh->result, result);
+ }
}
do_shorten(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_GNS_shorten_zone (gns_handle, TEST_DOMAIN,
- &our_zone,
- &process_shorten_result,
- TEST_DOMAIN);
+ &priv_zone,
+ &short_zone,
+ &our_zone,
+ &process_shorten_result,
+ TEST_DOMAIN);
}
static void
*
* @param handle handle to the GNS service
* @param name the name to look up
+ * @param private_zone the public zone of the private zone
+ * @param shorten_zone the public zone of the shorten zone
* @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,
+ struct GNUNET_CRYPTO_ShortHashCode *private_zone,
+ struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
GNUNET_GNS_ShortenResultProcessor proc,
void *proc_cls);
*
* @param handle handle to the GNS service
* @param name the name to look up
+ * @param private_zone the public zone of the private zone
+ * @param shorten_zone the public zone of the shorten zone
* @param zone the zone to start the resolution in
* @param proc function to call on result
* @param proc_cls closure for processor
*/
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);
+ const char * name,
+ struct GNUNET_CRYPTO_ShortHashCode *private_zone,
+ struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
+ struct GNUNET_CRYPTO_ShortHashCode *zone,
+ GNUNET_GNS_ShortenResultProcessor proc,
+ void *proc_cls);
/* *************** Standard API: get authority ******************* */