diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-10-22 19:09:12 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-10-22 19:09:12 +0200 |
commit | ea1d3fd9f54879992fb997a1e94cfd6830085c4b (patch) | |
tree | 7a3fb2ad932a6ab0df3ae6bc5d5fea30575f5171 /src/namestore | |
parent | acc69a8e5c921e5bbb03260383936487ec9ce0ca (diff) | |
download | gnunet-ea1d3fd9f54879992fb997a1e94cfd6830085c4b.tar.gz gnunet-ea1d3fd9f54879992fb997a1e94cfd6830085c4b.zip |
-more gnsrecord API
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-namestore-fcfsd.c | 22 | ||||
-rw-r--r-- | src/namestore/gnunet-namestore.c | 10 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_flat.c | 7 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_postgres.c | 13 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_sqlite.c | 12 |
5 files changed, 41 insertions, 23 deletions
diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c index 844f4a990..22d108067 100644 --- a/src/namestore/gnunet-namestore-fcfsd.c +++ b/src/namestore/gnunet-namestore-fcfsd.c | |||
@@ -349,7 +349,8 @@ iterate_cb (void *cls, | |||
349 | return; | 349 | return; |
350 | } | 350 | } |
351 | 351 | ||
352 | if (GNUNET_GNSRECORD_TYPE_PKEY != rd->record_type) | 352 | if ((GNUNET_GNSRECORD_TYPE_PKEY != rd->record_type) && |
353 | (GNUNET_GNSRECORD_TYPE_EDKEY != rd->record_type)) | ||
353 | { | 354 | { |
354 | GNUNET_NAMESTORE_zone_iterator_next (zr->list_it, | 355 | GNUNET_NAMESTORE_zone_iterator_next (zr->list_it, |
355 | 1); | 356 | 1); |
@@ -621,6 +622,7 @@ zone_to_name_cb (void *cls, | |||
621 | { | 622 | { |
622 | struct Request *request = cls; | 623 | struct Request *request = cls; |
623 | struct GNUNET_GNSRECORD_Data r; | 624 | struct GNUNET_GNSRECORD_Data r; |
625 | char *rdata; | ||
624 | 626 | ||
625 | (void) rd; | 627 | (void) rd; |
626 | (void) zone_key; | 628 | (void) zone_key; |
@@ -635,10 +637,21 @@ zone_to_name_cb (void *cls, | |||
635 | run_httpd_now (); | 637 | run_httpd_now (); |
636 | return; | 638 | return; |
637 | } | 639 | } |
638 | r.data = &request->pub; | 640 | if (GNUNET_OK != GNUNET_GNSRECORD_data_from_identity (&request->pub, |
639 | r.data_size = sizeof(request->pub); | 641 | &rdata, |
642 | &r.data_size, | ||
643 | &r.record_type)) | ||
644 | { | ||
645 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
646 | _ ("Error creating record data.\n")); | ||
647 | request->phase = RP_FAIL; | ||
648 | MHD_resume_connection (request->con); | ||
649 | run_httpd_now (); | ||
650 | return; | ||
651 | } | ||
652 | |||
653 | r.data = rdata; | ||
640 | r.expiration_time = UINT64_MAX; | 654 | r.expiration_time = UINT64_MAX; |
641 | r.record_type = GNUNET_GNSRECORD_TYPE_PKEY; | ||
642 | r.flags = GNUNET_GNSRECORD_RF_NONE; | 655 | r.flags = GNUNET_GNSRECORD_RF_NONE; |
643 | request->qe = GNUNET_NAMESTORE_records_store (ns, | 656 | request->qe = GNUNET_NAMESTORE_records_store (ns, |
644 | &fcfs_zone_pkey, | 657 | &fcfs_zone_pkey, |
@@ -646,6 +659,7 @@ zone_to_name_cb (void *cls, | |||
646 | 1, &r, | 659 | 1, &r, |
647 | &put_continuation, | 660 | &put_continuation, |
648 | request); | 661 | request); |
662 | GNUNET_free (rdata); | ||
649 | } | 663 | } |
650 | 664 | ||
651 | 665 | ||
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 345d76910..92d2cf627 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -661,11 +661,11 @@ get_existing_record (void *cls, | |||
661 | return; | 661 | return; |
662 | 662 | ||
663 | case GNUNET_GNSRECORD_TYPE_PKEY: | 663 | case GNUNET_GNSRECORD_TYPE_PKEY: |
664 | case GNUNET_GNSRECORD_TYPE_EDKEY: | ||
664 | fprintf ( | 665 | fprintf ( |
665 | stderr, | 666 | stderr, |
666 | _ ( | 667 | _ ( |
667 | "A %s record exists already under `%s', no other records can be added.\n"), | 668 | "A zone key record exists already under `%s', no other records can be added.\n"), |
668 | "PKEY", | ||
669 | rec_name); | 669 | rec_name); |
670 | ret = 1; | 670 | ret = 1; |
671 | test_finished (); | 671 | test_finished (); |
@@ -703,13 +703,13 @@ get_existing_record (void *cls, | |||
703 | break; | 703 | break; |
704 | 704 | ||
705 | case GNUNET_GNSRECORD_TYPE_PKEY: | 705 | case GNUNET_GNSRECORD_TYPE_PKEY: |
706 | case GNUNET_GNSRECORD_TYPE_EDKEY: | ||
706 | if (0 != rd_count) | 707 | if (0 != rd_count) |
707 | { | 708 | { |
708 | fprintf (stderr, | 709 | fprintf (stderr, |
709 | _ ( | 710 | _ ( |
710 | "Records already exist under `%s', cannot add `%s' record.\n"), | 711 | "Records already exist under `%s', cannot add record.\n"), |
711 | rec_name, | 712 | rec_name); |
712 | "PKEY"); | ||
713 | ret = 1; | 713 | ret = 1; |
714 | test_finished (); | 714 | test_finished (); |
715 | return; | 715 | return; |
diff --git a/src/namestore/plugin_namestore_flat.c b/src/namestore/plugin_namestore_flat.c index 1a071fd80..9ccc90cfd 100644 --- a/src/namestore/plugin_namestore_flat.c +++ b/src/namestore/plugin_namestore_flat.c | |||
@@ -698,11 +698,14 @@ zone_to_name (void *cls, | |||
698 | 698 | ||
699 | for (unsigned int i = 0; i < entry->record_count; i++) | 699 | for (unsigned int i = 0; i < entry->record_count; i++) |
700 | { | 700 | { |
701 | if (GNUNET_GNSRECORD_TYPE_PKEY != entry->record_data[i].record_type) | 701 | if (GNUNET_NO == |
702 | GNUNET_GNSRECORD_is_zonekey_type (entry->record_data[i].record_type)) | ||
703 | continue; | ||
704 | if (ztn->value_zone->type != entry->record_data[i].record_type) | ||
702 | continue; | 705 | continue; |
703 | if (0 == memcmp (ztn->value_zone, | 706 | if (0 == memcmp (ztn->value_zone, |
704 | entry->record_data[i].data, | 707 | entry->record_data[i].data, |
705 | sizeof(struct GNUNET_IDENTITY_PublicKey))) | 708 | entry->record_data[i].data_size)) |
706 | { | 709 | { |
707 | ztn->iter (ztn->iter_cls, | 710 | ztn->iter (ztn->iter_cls, |
708 | i + 1, /* zero is illegal! */ | 711 | i + 1, /* zero is illegal! */ |
diff --git a/src/namestore/plugin_namestore_postgres.c b/src/namestore/plugin_namestore_postgres.c index 358fd35d6..bdbaf96b3 100644 --- a/src/namestore/plugin_namestore_postgres.c +++ b/src/namestore/plugin_namestore_postgres.c | |||
@@ -195,13 +195,14 @@ namestore_postgres_store_records (void *cls, | |||
195 | 0, | 195 | 0, |
196 | sizeof(pkey)); | 196 | sizeof(pkey)); |
197 | for (unsigned int i = 0; i < rd_count; i++) | 197 | for (unsigned int i = 0; i < rd_count; i++) |
198 | if (GNUNET_GNSRECORD_TYPE_PKEY == rd[i].record_type) | 198 | if (GNUNET_YES == |
199 | GNUNET_GNSRECORD_is_zonekey_type (rd[i].record_type)) | ||
199 | { | 200 | { |
200 | GNUNET_break (sizeof(struct GNUNET_IDENTITY_PublicKey) == | 201 | GNUNET_break (GNUNET_OK == |
201 | rd[i].data_size); | 202 | GNUNET_GNSRECORD_identity_from_data (rd[i].data, |
202 | GNUNET_memcpy (&pkey, | 203 | rd[i].data_size, |
203 | rd[i].data, | 204 | rd[i].record_type, |
204 | rd[i].data_size); | 205 | &pkey)); |
205 | break; | 206 | break; |
206 | } | 207 | } |
207 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 208 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c index 4a4ce3d8d..7cb9b7ed0 100644 --- a/src/namestore/plugin_namestore_sqlite.c +++ b/src/namestore/plugin_namestore_sqlite.c | |||
@@ -329,13 +329,13 @@ namestore_sqlite_store_records (void *cls, | |||
329 | 0, | 329 | 0, |
330 | sizeof(pkey)); | 330 | sizeof(pkey)); |
331 | for (unsigned int i = 0; i < rd_count; i++) | 331 | for (unsigned int i = 0; i < rd_count; i++) |
332 | if (GNUNET_GNSRECORD_TYPE_PKEY == rd[i].record_type) | 332 | if (GNUNET_YES == GNUNET_GNSRECORD_is_zonekey_type (rd[i].record_type)) |
333 | { | 333 | { |
334 | GNUNET_break (sizeof(struct GNUNET_IDENTITY_PublicKey) == | 334 | GNUNET_break (GNUNET_YES == |
335 | rd[i].data_size); | 335 | GNUNET_GNSRECORD_identity_from_data (rd[i].data, |
336 | GNUNET_memcpy (&pkey, | 336 | rd[i].data_size, |
337 | rd[i].data, | 337 | rd[i].record_type, |
338 | rd[i].data_size); | 338 | &pkey)); |
339 | break; | 339 | break; |
340 | } | 340 | } |
341 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 341 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |