summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2020-05-06 18:42:45 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-05-06 18:42:45 +0200
commit1847e16524eb9fe5171612b43cf1d063d0f25dfc (patch)
tree99e4bce838d7c1588cc0133462055db3e5f72f9d
parent3a110bca6e72f1ad21eab00b0ad64630c0bd2fa2 (diff)
deprecate ill-defined set_nick API
-rw-r--r--src/include/gnunet_namestore_service.h18
-rw-r--r--src/namestore/gnunet-namestore.c33
-rw-r--r--src/namestore/namestore_api.c37
-rw-r--r--src/namestore/test_namestore_api_lookup_nick.c22
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_nick.c40
5 files changed, 67 insertions, 83 deletions
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h
index a7b7c57b1..bf42c8d34 100644
--- a/src/include/gnunet_namestore_service.h
+++ b/src/include/gnunet_namestore_service.h
@@ -154,24 +154,6 @@ typedef void
/**
- * Set the desired nick name for a zone
- *
- * @param h handle to the namestore
- * @param pkey private key of the zone
- * @param nick the nick name to set
- * @param cont continuation to call when done
- * @param cont_cls closure for @a cont
- * @return handle to abort the request
- */
-struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_set_nick (struct GNUNET_NAMESTORE_Handle *h,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const char *nick,
- GNUNET_NAMESTORE_ContinuationWithStatus cont,
- void *cont_cls);
-
-
-/**
* Lookup an item in the namestore.
*
* @param h handle to the namestore
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 3514f4fd9..94fcb8952 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -1038,6 +1038,24 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
GNUNET_free (rd);
return;
}
+ if (NULL != nickstring)
+ {
+ if (0 == strlen (nickstring))
+ {
+ fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring);
+ GNUNET_SCHEDULER_shutdown ();
+ ret = 1;
+ return;
+ }
+ add = 1;
+ typestring = GNUNET_strdup (GNUNET_GNSRECORD_number_to_typename (GNUNET_GNSRECORD_TYPE_NICK));
+ name = GNUNET_strdup (GNUNET_GNS_EMPTY_LABEL_AT);
+ value = GNUNET_strdup (nickstring);
+ is_public = 0;
+ expirationstring = GNUNET_strdup ("never");
+ GNUNET_free (nickstring);
+ nickstring = NULL;
+ }
if (add)
{
@@ -1227,21 +1245,6 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
&add_continuation,
&add_qe_uri);
}
- if (NULL != nickstring)
- {
- if (0 == strlen (nickstring))
- {
- fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring);
- GNUNET_SCHEDULER_shutdown ();
- ret = 1;
- return;
- }
- add_qe_uri = GNUNET_NAMESTORE_set_nick (ns,
- &zone_pkey,
- nickstring,
- &add_continuation,
- &add_qe_uri);
- }
if (monitor)
{
zm = GNUNET_NAMESTORE_zone_monitor_start (cfg,
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index 156c115d2..2a085cf04 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -1064,43 +1064,6 @@ GNUNET_NAMESTORE_records_store (
/**
- * Set the desired nick name for a zone
- *
- * @param h handle to the namestore
- * @param pkey private key of the zone
- * @param nick the nick name to set
- * @param cont continuation to call when done
- * @param cont_cls closure for @a cont
- * @return handle to abort the request
- */
-struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_set_nick (struct GNUNET_NAMESTORE_Handle *h,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
- const char *nick,
- GNUNET_NAMESTORE_ContinuationWithStatus cont,
- void *cont_cls)
-{
- struct GNUNET_GNSRECORD_Data rd;
-
- if (NULL == h->mq)
- return NULL;
- memset (&rd, 0, sizeof(rd));
- rd.data = nick;
- rd.data_size = strlen (nick) + 1;
- rd.record_type = GNUNET_GNSRECORD_TYPE_NICK;
- rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
- rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
- return GNUNET_NAMESTORE_records_store (h,
- pkey,
- GNUNET_GNS_EMPTY_LABEL_AT,
- 1,
- &rd,
- cont,
- cont_cls);
-}
-
-
-/**
* Lookup an item in the namestore.
*
* @param h handle to the namestore
diff --git a/src/namestore/test_namestore_api_lookup_nick.c b/src/namestore/test_namestore_api_lookup_nick.c
index 145a3e885..628e76254 100644
--- a/src/namestore/test_namestore_api_lookup_nick.c
+++ b/src/namestore/test_namestore_api_lookup_nick.c
@@ -23,6 +23,7 @@
*/
#include "platform.h"
#include "gnunet_namestore_service.h"
+#include "gnunet_gns_service.h"
#include "gnunet_testing_lib.h"
#include "gnunet_dnsparser_lib.h"
@@ -280,6 +281,8 @@ run (void *cls,
const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TESTING_Peer *peer)
{
+ struct GNUNET_GNSRECORD_Data rd;
+
endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
&endbadly,
NULL);
@@ -290,11 +293,20 @@ run (void *cls,
nsh = GNUNET_NAMESTORE_connect (cfg);
GNUNET_break (NULL != nsh);
- nsqe = GNUNET_NAMESTORE_set_nick (nsh,
- &privkey,
- TEST_NICK,
- &nick_cont,
- (void *) name);
+ memset (&rd, 0, sizeof(rd));
+ rd.data = TEST_NICK;
+ rd.data_size = strlen (TEST_NICK) + 1;
+ rd.record_type = GNUNET_GNSRECORD_TYPE_NICK;
+ rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+ rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
+ nsqe = GNUNET_NAMESTORE_records_store (nsh,
+ &privkey,
+ GNUNET_GNS_EMPTY_LABEL_AT,
+ 1,
+ &rd,
+ &nick_cont,
+ (void *) name);
+
if (NULL == nsqe)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
diff --git a/src/namestore/test_namestore_api_zone_iteration_nick.c b/src/namestore/test_namestore_api_zone_iteration_nick.c
index b0c4c8211..1ebdfd073 100644
--- a/src/namestore/test_namestore_api_zone_iteration_nick.c
+++ b/src/namestore/test_namestore_api_zone_iteration_nick.c
@@ -23,6 +23,7 @@
*/
#include "platform.h"
#include "gnunet_namestore_service.h"
+#include "gnunet_gns_service.h"
#include "gnunet_testing_lib.h"
#include "namestore.h"
#include "gnunet_dnsparser_lib.h"
@@ -313,10 +314,22 @@ nick_1_cont (void *cls, int32_t success, const char *emsg)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Nick 1 added : %s\n",
(success == GNUNET_OK) ? "SUCCESS" : "FAIL");
+ struct GNUNET_GNSRECORD_Data rd;
+
+ memset (&rd, 0, sizeof(rd));
+ rd.data = ZONE_NICK_2;
+ rd.data_size = strlen (ZONE_NICK_2) + 1;
+ rd.record_type = GNUNET_GNSRECORD_TYPE_NICK;
+ rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+ rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
+ nsqe = GNUNET_NAMESTORE_records_store (nsh,
+ &privkey2,
+ GNUNET_GNS_EMPTY_LABEL_AT,
+ 1,
+ &rd,
+ &nick_2_cont,
+ &privkey2);
- nsqe = GNUNET_NAMESTORE_set_nick (nsh,
- &privkey2, ZONE_NICK_2, &nick_2_cont,
- &privkey2);
if (NULL == nsqe)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -363,14 +376,25 @@ static void
empty_zone_end (void *cls)
{
GNUNET_assert (nsh == cls);
+ struct GNUNET_GNSRECORD_Data rd;
+
zi = NULL;
GNUNET_CRYPTO_ecdsa_key_create (&privkey);
GNUNET_CRYPTO_ecdsa_key_create (&privkey2);
- nsqe = GNUNET_NAMESTORE_set_nick (nsh,
- &privkey,
- ZONE_NICK_1,
- &nick_1_cont,
- NULL);
+
+ memset (&rd, 0, sizeof(rd));
+ rd.data = ZONE_NICK_1;
+ rd.data_size = strlen (ZONE_NICK_1) + 1;
+ rd.record_type = GNUNET_GNSRECORD_TYPE_NICK;
+ rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+ rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
+ nsqe = GNUNET_NAMESTORE_records_store (nsh,
+ &privkey,
+ GNUNET_GNS_EMPTY_LABEL_AT,
+ 1,
+ &rd,
+ &nick_1_cont,
+ NULL);
if (NULL == nsqe)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,