projects
/
oweals
/
gnunet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
-revocation
[oweals/gnunet.git]
/
src
/
gns
/
gnunet-service-gns_shorten.c
diff --git
a/src/gns/gnunet-service-gns_shorten.c
b/src/gns/gnunet-service-gns_shorten.c
index b0a1b6fbcd837db58e81537af49563f32947663a..4e7f9a91d9ddd0cf7b354b49c969a2c33411168c 100644
(file)
--- a/
src/gns/gnunet-service-gns_shorten.c
+++ b/
src/gns/gnunet-service-gns_shorten.c
@@
-27,6
+27,7
@@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_dht_service.h"
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_dht_service.h"
+#include "gnunet_gnsrecord_lib.h"
#include "gnunet_namestore_service.h"
#include "gnunet_resolver_service.h"
#include "gnunet_gns_service.h"
#include "gnunet_namestore_service.h"
#include "gnunet_resolver_service.h"
#include "gnunet_gns_service.h"
@@
-65,7
+66,7
@@
struct GetPseuAuthorityHandle
* Private key of the (shorten) zone to store the resulting
* pseudonym in.
*/
* Private key of the (shorten) zone to store the resulting
* pseudonym in.
*/
- struct GNUNET_CRYPTO_Ec
c
PrivateKey shorten_zone_key;
+ struct GNUNET_CRYPTO_Ec
dsa
PrivateKey shorten_zone_key;
/**
* Original label (used if no PSEU record is found).
/**
* Original label (used if no PSEU record is found).
@@
-80,18
+81,23
@@
struct GetPseuAuthorityHandle
/**
* The zone for which we are trying to find the PSEU record.
*/
/**
* The zone for which we are trying to find the PSEU record.
*/
- struct GNUNET_CRYPTO_Ec
c
PublicKey target_zone;
+ struct GNUNET_CRYPTO_Ec
dsa
PublicKey target_zone;
/**
/**
- * Handle for DHT lookups. Should be NULL if no lookups are in progress
+ * Handle for DHT lookups. Should be NULL if no lookups are in progress
*/
struct GNUNET_DHT_GetHandle *get_handle;
/**
*/
struct GNUNET_DHT_GetHandle *get_handle;
/**
- * Handle to namestore request
+ * Handle to namestore request
*/
struct GNUNET_NAMESTORE_QueueEntry *namestore_task;
*/
struct GNUNET_NAMESTORE_QueueEntry *namestore_task;
+ /**
+ * Handle to namecache request
+ */
+ struct GNUNET_NAMECACHE_QueueEntry *namecache_task;
+
/**
* Task to abort DHT lookup operation.
*/
/**
* Task to abort DHT lookup operation.
*/
@@
-115,6
+121,11
@@
static struct GetPseuAuthorityHandle *gph_tail;
*/
static struct GNUNET_NAMESTORE_Handle *namestore_handle;
*/
static struct GNUNET_NAMESTORE_Handle *namestore_handle;
+/**
+ * Our handle to the namecache service
+ */
+static struct GNUNET_NAMECACHE_Handle *namecache_handle;
+
/**
* Resolver handle to the dht
*/
/**
* Resolver handle to the dht
*/
@@
-139,6
+150,11
@@
free_get_pseu_authority_handle (struct GetPseuAuthorityHandle *gph)
GNUNET_NAMESTORE_cancel (gph->namestore_task);
gph->namestore_task = NULL;
}
GNUNET_NAMESTORE_cancel (gph->namestore_task);
gph->namestore_task = NULL;
}
+ if (NULL != gph->namecache_task)
+ {
+ GNUNET_NAMECACHE_cancel (gph->namecache_task);
+ gph->namecache_task = NULL;
+ }
if (GNUNET_SCHEDULER_NO_TASK != gph->timeout_task)
{
GNUNET_SCHEDULER_cancel (gph->timeout_task);
if (GNUNET_SCHEDULER_NO_TASK != gph->timeout_task)
{
GNUNET_SCHEDULER_cancel (gph->timeout_task);
@@
-158,8
+174,8
@@
free_get_pseu_authority_handle (struct GetPseuAuthorityHandle *gph)
* @param emsg unused
*/
static void
* @param emsg unused
*/
static void
-create_pkey_cont (void* cls,
- int32_t success,
+create_pkey_cont (void* cls,
+ int32_t success,
const char *emsg)
{
struct GetPseuAuthorityHandle* gph = cls;
const char *emsg)
{
struct GetPseuAuthorityHandle* gph = cls;
@@
-180,7
+196,7
@@
create_pkey_cont (void* cls,
static void
process_pseu_lookup_ns (void *cls,
unsigned int rd_count,
static void
process_pseu_lookup_ns (void *cls,
unsigned int rd_count,
- const struct GNUNET_
NAMESTORE_Record
Data *rd);
+ const struct GNUNET_
GNSRECORD_
Data *rd);
/**
/**
@@
-192,21
+208,21
@@
process_pseu_lookup_ns (void *cls,
*/
static void
process_pseu_block_ns (void *cls,
*/
static void
process_pseu_block_ns (void *cls,
- const struct GNUNET_
NAMESTORE
_Block *block)
+ const struct GNUNET_
GNSRECORD
_Block *block)
{
struct GetPseuAuthorityHandle *gph = cls;
{
struct GetPseuAuthorityHandle *gph = cls;
- struct GNUNET_CRYPTO_Ec
c
PublicKey pub;
+ struct GNUNET_CRYPTO_Ec
dsa
PublicKey pub;
- gph->name
stor
e_task = NULL;
+ gph->name
cach
e_task = NULL;
if (NULL == block)
{
process_pseu_lookup_ns (gph, 0, NULL);
return;
}
if (NULL == block)
{
process_pseu_lookup_ns (gph, 0, NULL);
return;
}
- GNUNET_CRYPTO_ec
c
_key_get_public (&gph->shorten_zone_key,
+ GNUNET_CRYPTO_ec
dsa
_key_get_public (&gph->shorten_zone_key,
&pub);
&pub);
- if (GNUNET_OK !=
- GNUNET_
NAMESTORE
_block_decrypt (block,
+ if (GNUNET_OK !=
+ GNUNET_
GNSRECORD
_block_decrypt (block,
&pub,
gph->current_label,
&process_pseu_lookup_ns,
&pub,
gph->current_label,
&process_pseu_lookup_ns,
@@
-225,21
+241,21
@@
process_pseu_block_ns (void *cls,
* @param gph the handle to our shorten operation
* @param label the label to lookup
*/
* @param gph the handle to our shorten operation
* @param label the label to lookup
*/
-static void
+static void
perform_pseu_lookup (struct GetPseuAuthorityHandle *gph,
const char *label)
perform_pseu_lookup (struct GetPseuAuthorityHandle *gph,
const char *label)
-{
- struct GNUNET_CRYPTO_Ec
c
PublicKey pub;
+{
+ struct GNUNET_CRYPTO_Ec
dsa
PublicKey pub;
struct GNUNET_HashCode query;
struct GNUNET_HashCode query;
- GNUNET_CRYPTO_ec
c
_key_get_public (&gph->shorten_zone_key,
+ GNUNET_CRYPTO_ec
dsa
_key_get_public (&gph->shorten_zone_key,
&pub);
GNUNET_free_non_null (gph->current_label);
gph->current_label = GNUNET_strdup (label);
&pub);
GNUNET_free_non_null (gph->current_label);
gph->current_label = GNUNET_strdup (label);
- GNUNET_
NAMESTORE
_query_from_public_key (&pub,
+ GNUNET_
GNSRECORD
_query_from_public_key (&pub,
label,
&query);
label,
&query);
- gph->name
store_task = GNUNET_NAMESTORE_lookup_block (namestor
e_handle,
+ gph->name
cache_task = GNUNET_NAMECACHE_lookup_block (namecach
e_handle,
&query,
&process_pseu_block_ns,
gph);
&query,
&process_pseu_block_ns,
gph);
@@
-257,17
+273,17
@@
perform_pseu_lookup (struct GetPseuAuthorityHandle *gph,
static void
process_pseu_lookup_ns (void *cls,
unsigned int rd_count,
static void
process_pseu_lookup_ns (void *cls,
unsigned int rd_count,
- const struct GNUNET_
NAMESTORE_Record
Data *rd)
+ const struct GNUNET_
GNSRECORD_
Data *rd)
{
struct GetPseuAuthorityHandle *gph = cls;
{
struct GetPseuAuthorityHandle *gph = cls;
- struct GNUNET_
NAMESTORE_Record
Data new_pkey;
+ struct GNUNET_
GNSRECORD_
Data new_pkey;
gph->namestore_task = NULL;
if (rd_count > 0)
{
gph->namestore_task = NULL;
if (rd_count > 0)
{
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Name `%s' already taken, cannot shorten.\n",
- gph->current_label);
+ GNUNET_log
(GNUNET_ERROR_TYPE_DEBUG,
+ "Name `%s' already taken, cannot shorten.\n",
+
gph->current_label);
/* if this was not yet the original label, try one more
time, this time not using PSEU but the original label */
if (0 == strcmp (gph->current_label,
/* if this was not yet the original label, try one more
time, this time not using PSEU but the original label */
if (0 == strcmp (gph->current_label,
@@
-283,17
+299,17
@@
process_pseu_lookup_ns (void *cls,
}
/* name is available */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
}
/* name is available */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Shortening `%s' to `%s'\n",
- GNUNET_
NAMESTORE
_z2s (&gph->target_zone),
+ "Shortening `%s' to `%s'\n",
+ GNUNET_
GNSRECORD
_z2s (&gph->target_zone),
gph->current_label);
new_pkey.expiration_time = UINT64_MAX;
gph->current_label);
new_pkey.expiration_time = UINT64_MAX;
- new_pkey.data_size = sizeof (struct GNUNET_CRYPTO_Ec
c
PublicKey);
+ new_pkey.data_size = sizeof (struct GNUNET_CRYPTO_Ec
dsa
PublicKey);
new_pkey.data = &gph->target_zone;
new_pkey.data = &gph->target_zone;
- new_pkey.record_type = GNUNET_
NAMESTORE
_TYPE_PKEY;
- new_pkey.flags = GNUNET_
NAMESTORE
_RF_NONE
- | GNUNET_
NAMESTORE
_RF_PRIVATE
- | GNUNET_
NAMESTORE
_RF_PENDING;
- gph->namestore_task
+ new_pkey.record_type = GNUNET_
GNSRECORD
_TYPE_PKEY;
+ new_pkey.flags = GNUNET_
GNSRECORD
_RF_NONE
+ | GNUNET_
GNSRECORD
_RF_PRIVATE
+ | GNUNET_
GNSRECORD
_RF_PENDING;
+ gph->namestore_task
= GNUNET_NAMESTORE_records_store (namestore_handle,
&gph->shorten_zone_key,
gph->current_label,
= GNUNET_NAMESTORE_records_store (namestore_handle,
&gph->shorten_zone_key,
gph->current_label,
@@
-309,7
+325,7
@@
process_pseu_lookup_ns (void *cls,
* @param pseu the pseu result or NULL
*/
static void
* @param pseu the pseu result or NULL
*/
static void
-process_pseu_result (struct GetPseuAuthorityHandle* gph,
+process_pseu_result (struct GetPseuAuthorityHandle* gph,
const char *pseu)
{
if (NULL == pseu)
const char *pseu)
{
if (NULL == pseu)
@@
-320,7
+336,7
@@
process_pseu_result (struct GetPseuAuthorityHandle* gph,
gph->label);
perform_pseu_lookup (gph, gph->label);
return;
gph->label);
perform_pseu_lookup (gph, gph->label);
return;
- }
+ }
/* check if 'pseu' is taken */
perform_pseu_lookup (gph, pseu);
}
/* check if 'pseu' is taken */
perform_pseu_lookup (gph, pseu);
}
@@
-340,7
+356,8
@@
handle_auth_discovery_timeout (void *cls,
gph->timeout_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
gph->timeout_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "DHT lookup for PSEU query timed out.\n");
+ "DHT lookup for PSEU query in zone `%s' timed out.\n",
+ GNUNET_GNSRECORD_z2s (&gph->target_zone));
GNUNET_DHT_get_stop (gph->get_handle);
gph->get_handle = NULL;
process_pseu_result (gph, NULL);
GNUNET_DHT_get_stop (gph->get_handle);
gph->get_handle = NULL;
process_pseu_result (gph, NULL);
@@
-357,23
+374,30
@@
handle_auth_discovery_timeout (void *cls,
static void
process_auth_records (void *cls,
unsigned int rd_count,
static void
process_auth_records (void *cls,
unsigned int rd_count,
- const struct GNUNET_
NAMESTORE_Record
Data *rd)
+ const struct GNUNET_
GNSRECORD_
Data *rd)
{
struct GetPseuAuthorityHandle *gph = cls;
unsigned int i;
for (i=0; i < rd_count; i++)
{
{
struct GetPseuAuthorityHandle *gph = cls;
unsigned int i;
for (i=0; i < rd_count; i++)
{
- if (GNUNET_
NAMESTORE
_TYPE_PSEU == rd[i].record_type)
+ if (GNUNET_
GNSRECORD
_TYPE_PSEU == rd[i].record_type)
{
{
+ char pseu[rd[i].data_size + 1];
+
/* found pseu */
/* found pseu */
- process_pseu_result (gph,
- (const char *) rd[i].data);
+ memcpy (pseu,
+ rd[i].data,
+ rd[i].data_size);
+ pseu[rd[i].data_size] = '\0';
+ process_pseu_result (gph,
+ pseu);
return;
}
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
return;
}
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "No PSEU record found in DHT reply.\n");
+ "No PSEU record found in DHT reply with %u records.\n",
+ rd_count);
process_pseu_result (gph, NULL);
}
process_pseu_result (gph, NULL);
}
@@
-385,11
+409,11
@@
process_auth_records (void *cls,
* @param exp lifetime
* @param key the key the record was stored under
* @param get_path get path
* @param exp lifetime
* @param key the key the record was stored under
* @param get_path get path
- * @param get_path_length
get
path length
+ * @param get_path_length
@a get_
path length
* @param put_path put path
* @param put_path put path
- * @param put_path_length
put
path length
+ * @param put_path_length
@a put_
path length
* @param type the block type
* @param type the block type
- * @param size
the size of the record
+ * @param size
number of bytes in @a data
* @param data the record data
*/
static void
* @param data the record data
*/
static void
@@
-405,7
+429,7
@@
process_auth_discovery_dht_result (void* cls,
const void *data)
{
struct GetPseuAuthorityHandle *gph = cls;
const void *data)
{
struct GetPseuAuthorityHandle *gph = cls;
- const struct GNUNET_
NAMESTORE
_Block *block;
+ const struct GNUNET_
GNSRECORD
_Block *block;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Got DHT result for PSEU request\n");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Got DHT result for PSEU request\n");
@@
-421,26
+445,26
@@
process_auth_discovery_dht_result (void* cls,
process_pseu_result (gph, NULL);
return;
}
process_pseu_result (gph, NULL);
return;
}
- if (size < sizeof (struct GNUNET_
NAMESTORE
_Block))
+ if (size < sizeof (struct GNUNET_
GNSRECORD
_Block))
{
/* how did this pass DHT block validation!? */
GNUNET_break (0);
process_pseu_result (gph, NULL);
{
/* how did this pass DHT block validation!? */
GNUNET_break (0);
process_pseu_result (gph, NULL);
- return;
+ return;
}
block = data;
if (size !=
}
block = data;
if (size !=
- ntoh
s (block->purpose.size) +
- sizeof (struct GNUNET_CRYPTO_Ec
c
PublicKey) +
- sizeof (struct GNUNET_CRYPTO_Ec
c
Signature))
+ ntoh
l (block->purpose.size) +
+ sizeof (struct GNUNET_CRYPTO_Ec
dsa
PublicKey) +
+ sizeof (struct GNUNET_CRYPTO_Ec
dsa
Signature))
{
/* how did this pass DHT block validation!? */
GNUNET_break (0);
process_pseu_result (gph, NULL);
{
/* how did this pass DHT block validation!? */
GNUNET_break (0);
process_pseu_result (gph, NULL);
- return;
+ return;
}
if (GNUNET_OK !=
}
if (GNUNET_OK !=
- GNUNET_
NAMESTORE
_block_decrypt (block,
+ GNUNET_
GNSRECORD
_block_decrypt (block,
&gph->target_zone,
GNUNET_GNS_TLD_PLUS,
&process_auth_records,
&gph->target_zone,
GNUNET_GNS_TLD_PLUS,
&process_auth_records,
@@
-449,7
+473,7
@@
process_auth_discovery_dht_result (void* cls,
/* other peer encrypted invalid block, complain */
GNUNET_break_op (0);
process_pseu_result (gph, NULL);
/* other peer encrypted invalid block, complain */
GNUNET_break_op (0);
process_pseu_result (gph, NULL);
- return;
+ return;
}
}
}
}
@@
-466,14
+490,14
@@
process_auth_discovery_dht_result (void* cls,
*/
static void
process_zone_to_name_discover (void *cls,
*/
static void
process_zone_to_name_discover (void *cls,
- const struct GNUNET_CRYPTO_Ec
c
PrivateKey *zone_key,
+ const struct GNUNET_CRYPTO_Ec
dsa
PrivateKey *zone_key,
const char *name,
unsigned int rd_len,
const char *name,
unsigned int rd_len,
- const struct GNUNET_
NAMESTORE_Record
Data *rd)
+ const struct GNUNET_
GNSRECORD_
Data *rd)
{
struct GetPseuAuthorityHandle* gph = cls;
struct GNUNET_HashCode lookup_key;
{
struct GetPseuAuthorityHandle* gph = cls;
struct GNUNET_HashCode lookup_key;
-
+
gph->namestore_task = NULL;
if (0 != rd_len)
{
gph->namestore_task = NULL;
if (0 != rd_len)
{
@@
-485,11
+509,16
@@
process_zone_to_name_discover (void *cls,
return;
}
/* record does not yet exist, go into DHT to find PSEU record */
return;
}
/* record does not yet exist, go into DHT to find PSEU record */
- GNUNET_
NAMESTORE
_query_from_public_key (&gph->target_zone,
- GNUNET_GNS_TLD_PLUS,
+ GNUNET_
GNSRECORD
_query_from_public_key (&gph->target_zone,
+ GNUNET_GNS_TLD_PLUS,
&lookup_key);
&lookup_key);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Shortening searches in DHT for PSEU record under `%s' in zone `%s'\n",
+ GNUNET_h2s (&lookup_key),
+ GNUNET_GNSRECORD_z2s (&gph->target_zone));
+
gph->timeout_task = GNUNET_SCHEDULER_add_delayed (DHT_LOOKUP_TIMEOUT,
gph->timeout_task = GNUNET_SCHEDULER_add_delayed (DHT_LOOKUP_TIMEOUT,
- &handle_auth_discovery_timeout,
+ &handle_auth_discovery_timeout,
gph);
gph->get_handle = GNUNET_DHT_get_start (dht_handle,
GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
gph);
gph->get_handle = GNUNET_DHT_get_start (dht_handle,
GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
@@
-513,16
+542,20
@@
process_zone_to_name_discover (void *cls,
*/
void
GNS_shorten_start (const char *original_label,
*/
void
GNS_shorten_start (const char *original_label,
- const struct GNUNET_CRYPTO_Ec
c
PublicKey *pub,
- const struct GNUNET_CRYPTO_Ec
c
PrivateKey *shorten_zone)
+ const struct GNUNET_CRYPTO_Ec
dsa
PublicKey *pub,
+ const struct GNUNET_CRYPTO_Ec
dsa
PrivateKey *shorten_zone)
{
struct GetPseuAuthorityHandle *gph;
{
struct GetPseuAuthorityHandle *gph;
-
+
if (strlen (original_label) > GNUNET_DNSPARSER_MAX_LABEL_LENGTH)
{
GNUNET_break (0);
return;
}
if (strlen (original_label) > GNUNET_DNSPARSER_MAX_LABEL_LENGTH)
{
GNUNET_break (0);
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Starting shortening process for `%s' with old label `%s'\n",
+ GNUNET_GNSRECORD_z2s (pub),
+ original_label);
gph = GNUNET_new (struct GetPseuAuthorityHandle);
gph->shorten_zone_key = *shorten_zone;
gph->target_zone = *pub;
gph = GNUNET_new (struct GetPseuAuthorityHandle);
gph->shorten_zone_key = *shorten_zone;
gph->target_zone = *pub;
@@
-541,13
+574,16
@@
GNS_shorten_start (const char *original_label,
* Initialize the shortening subsystem
*
* @param nh the namestore handle
* Initialize the shortening subsystem
*
* @param nh the namestore handle
+ * @param nc the namecache handle
* @param dht the dht handle
*/
void
GNS_shorten_init (struct GNUNET_NAMESTORE_Handle *nh,
* @param dht the dht handle
*/
void
GNS_shorten_init (struct GNUNET_NAMESTORE_Handle *nh,
+ struct GNUNET_NAMECACHE_Handle *nc,
struct GNUNET_DHT_Handle *dht)
{
namestore_handle = nh;
struct GNUNET_DHT_Handle *dht)
{
namestore_handle = nh;
+ namecache_handle = nc;
dht_handle = dht;
}
dht_handle = dht;
}
@@
-563,6
+599,7
@@
GNS_shorten_done ()
free_get_pseu_authority_handle (gph_head);
dht_handle = NULL;
namestore_handle = NULL;
free_get_pseu_authority_handle (gph_head);
dht_handle = NULL;
namestore_handle = NULL;
+ namecache_handle = NULL;
}
/* end of gnunet-service-gns_shorten.c */
}
/* end of gnunet-service-gns_shorten.c */