diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-19 19:27:05 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-19 19:27:05 +0000 |
commit | 27853eac2269aada4c833d86f7212e2a9ae9a62e (patch) | |
tree | 2c03c77c16ef959e46a3781b2f279e07d06bbad3 /src | |
parent | 4930e27d8a945a501f644d048d9b30d48e066450 (diff) | |
download | gnunet-27853eac2269aada4c833d86f7212e2a9ae9a62e.tar.gz gnunet-27853eac2269aada4c833d86f7212e2a9ae9a62e.zip |
-allow registering one name per zone key in fcfsd
Diffstat (limited to 'src')
-rw-r--r-- | src/gns/gnunet-gns-fcfsd.c | 80 |
1 files changed, 66 insertions, 14 deletions
diff --git a/src/gns/gnunet-gns-fcfsd.c b/src/gns/gnunet-gns-fcfsd.c index 0d400011d..8d6a58302 100644 --- a/src/gns/gnunet-gns-fcfsd.c +++ b/src/gns/gnunet-gns-fcfsd.c | |||
@@ -342,7 +342,66 @@ put_continuation (void *cls, | |||
342 | 342 | ||
343 | 343 | ||
344 | /** | 344 | /** |
345 | * Process a record that was stored in the namestore. | 345 | * Test if a name mapping was found, if so, refuse. If not, initiate storing of the record. |
346 | * | ||
347 | * @param cls closure | ||
348 | * @param zone_key public key of the zone | ||
349 | * @param expire when does the corresponding block in the DHT expire (until | ||
350 | * when should we never do a DHT lookup for the same name again)?; | ||
351 | * GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type in the namestore, | ||
352 | * or the expiration time of the block in the namestore (even if there are zero | ||
353 | * records matching the desired record type) | ||
354 | * @param name name that is being mapped (at most 255 characters long) | ||
355 | * @param rd_count number of entries in 'rd' array | ||
356 | * @param rd array of records with data to store | ||
357 | * @param signature signature of the record block, NULL if signature is unavailable (i.e. | ||
358 | * because the user queried for a particular record type only) | ||
359 | */ | ||
360 | static void | ||
361 | zone_to_name_cb (void *cls, | ||
362 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | ||
363 | struct GNUNET_TIME_Absolute expire, | ||
364 | const char *name, | ||
365 | unsigned int rd_count, | ||
366 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
367 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
368 | { | ||
369 | struct Request *request = cls; | ||
370 | struct GNUNET_NAMESTORE_RecordData r; | ||
371 | struct GNUNET_CRYPTO_ShortHashCode pub; | ||
372 | |||
373 | request->qe = NULL; | ||
374 | if (NULL != name) | ||
375 | { | ||
376 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
377 | _("Found existing name `%s' for the given key\n"), | ||
378 | name); | ||
379 | request->phase = RP_FAIL; | ||
380 | run_httpd_now (); | ||
381 | return; | ||
382 | } | ||
383 | GNUNET_assert (GNUNET_OK == | ||
384 | GNUNET_CRYPTO_short_hash_from_string2 (request->public_key, | ||
385 | strlen (request->public_key), | ||
386 | &pub)); | ||
387 | r.data = &pub; | ||
388 | r.data_size = sizeof (pub); | ||
389 | r.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
390 | r.record_type = GNUNET_NAMESTORE_TYPE_PKEY; | ||
391 | r.flags = GNUNET_NAMESTORE_RF_AUTHORITY; | ||
392 | request->qe = GNUNET_NAMESTORE_record_create (ns, | ||
393 | fcfs_zone_pkey, | ||
394 | request->domain_name, | ||
395 | &r, | ||
396 | &put_continuation, | ||
397 | request); | ||
398 | } | ||
399 | |||
400 | |||
401 | /** | ||
402 | * Process a record that was stored in the namestore. Used to check if | ||
403 | * the requested name already exists in the namestore. If not, | ||
404 | * proceed to check if the requested key already exists. | ||
346 | * | 405 | * |
347 | * @param cls closure | 406 | * @param cls closure |
348 | * @param zone_key public key of the zone | 407 | * @param zone_key public key of the zone |
@@ -367,14 +426,13 @@ lookup_result_processor (void *cls, | |||
367 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 426 | const struct GNUNET_CRYPTO_RsaSignature *signature) |
368 | { | 427 | { |
369 | struct Request *request = cls; | 428 | struct Request *request = cls; |
370 | struct GNUNET_NAMESTORE_RecordData r; | ||
371 | struct GNUNET_CRYPTO_ShortHashCode pub; | 429 | struct GNUNET_CRYPTO_ShortHashCode pub; |
372 | 430 | ||
431 | request->qe = NULL; | ||
373 | GNUNET_assert (GNUNET_OK == | 432 | GNUNET_assert (GNUNET_OK == |
374 | GNUNET_CRYPTO_short_hash_from_string2 (request->public_key, | 433 | GNUNET_CRYPTO_short_hash_from_string2 (request->public_key, |
375 | strlen (request->public_key), | 434 | strlen (request->public_key), |
376 | &pub)); | 435 | &pub)); |
377 | request->qe = NULL; | ||
378 | if (0 != rd_count) | 436 | if (0 != rd_count) |
379 | { | 437 | { |
380 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 438 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -385,17 +443,11 @@ lookup_result_processor (void *cls, | |||
385 | run_httpd_now (); | 443 | run_httpd_now (); |
386 | return; | 444 | return; |
387 | } | 445 | } |
388 | r.data = &pub; | 446 | request->qe = GNUNET_NAMESTORE_zone_to_name (ns, |
389 | r.data_size = sizeof (pub); | 447 | &fcfsd_zone, |
390 | r.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; | 448 | &pub, |
391 | r.record_type = GNUNET_NAMESTORE_TYPE_PKEY; | 449 | &zone_to_name_cb, |
392 | r.flags = GNUNET_NAMESTORE_RF_AUTHORITY; | 450 | request); |
393 | request->qe = GNUNET_NAMESTORE_record_create (ns, | ||
394 | fcfs_zone_pkey, | ||
395 | request->domain_name, | ||
396 | &r, | ||
397 | &put_continuation, | ||
398 | request); | ||
399 | } | 451 | } |
400 | 452 | ||
401 | 453 | ||