[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 59/70: - DID resolve using DID lib
From: |
gnunet |
Subject: |
[gnunet] 59/70: - DID resolve using DID lib |
Date: |
Wed, 31 Aug 2022 18:00:53 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit ec36e49c337b336ed46b1e7d3f26aafce2be008b
Author: Tristan Schwieren <tristan.schwieren@tum.de>
AuthorDate: Tue Jun 28 15:33:43 2022 +0200
- DID resolve using DID lib
---
src/reclaim/did_core.c | 9 +++--
src/reclaim/gnunet-did.c | 94 ++++++++++--------------------------------------
2 files changed, 25 insertions(+), 78 deletions(-)
diff --git a/src/reclaim/did_core.c b/src/reclaim/did_core.c
index d6ee33f93..5cecc2972 100644
--- a/src/reclaim/did_core.c
+++ b/src/reclaim/did_core.c
@@ -27,6 +27,9 @@
#include "did_core.h"
+// #define DID_DOCUMENT_LABEL GNUNET_GNS_EMPTY_LABEL_AT
+#define DID_DOCUMENT_LABEL "didd"
+
static DID_resolve_callback *resolve_cb;
static DID_action_callback *action_cb;
static void *closure;
@@ -60,7 +63,7 @@ DID_resolve_gns_lookup_cb (
if (rd[0].record_type == GNUNET_DNSPARSER_TYPE_TXT)
{
didd = (char *) rd[0].data;
- resolve_cb (GNUNET_NO, didd, closure);
+ resolve_cb (GNUNET_OK, didd, closure);
}
else
resolve_cb (GNUNET_NO, "DID Document is not a TXT record\n", closure);
@@ -93,7 +96,9 @@ DID_resolve (const char *did,
if (GNUNET_OK != DID_did_to_pkey (did, &pkey))
return GNUNET_NO;
- GNUNET_GNS_lookup (gns_handle, GNUNET_GNS_EMPTY_LABEL_AT, &pkey,
+ GNUNET_GNS_lookup (gns_handle, DID_DOCUMENT_LABEL, &pkey,
GNUNET_DNSPARSER_TYPE_TXT,
GNUNET_GNS_LO_DEFAULT, &DID_resolve_gns_lookup_cb, NULL);
+
+ return GNUNET_OK;
}
\ No newline at end of file
diff --git a/src/reclaim/gnunet-did.c b/src/reclaim/gnunet-did.c
index 2ba12e8eb..3629c22f8 100644
--- a/src/reclaim/gnunet-did.c
+++ b/src/reclaim/gnunet-did.c
@@ -147,7 +147,6 @@ cleanup (void *cls)
GNUNET_SCHEDULER_shutdown ();
}
-
/**
* @brief Callback for ego loockup of get_did_for_ego()
*
@@ -197,73 +196,16 @@ get_did_for_ego ()
}
}
-
-/**
- * @brief Get the public key from did attribute given by the user
- *
- * @param pkey place to write the public key to
- */
-static void
-get_pkey_from_attr_did (struct GNUNET_IDENTITY_PublicKey *pkey)
-{
- /* FIXME-MSC: I suggest introducing a
- * #define MAX_DID_LENGTH <something>
- * here and use it for parsing
- */
- char pkey_str[59];
-
- if ((1 != (sscanf (did, GNUNET_DID_METHOD_PREFIX "%58s", pkey_str))) ||
- (GNUNET_OK != GNUNET_IDENTITY_public_key_from_string (pkey_str, pkey)))
- {
- fprintf (stderr, _ ("Invalid DID `%s'\n"), pkey_str);
- GNUNET_SCHEDULER_add_now (cleanup, NULL);
- ret = 1;
- return;
- }
-}
-
/**
- * @brief GNS lookup callback. Prints the DID Document to standard out.
- * Fails if there is more than one DID record.
+ * @brief Resolve DID callback. Prints the DID Document to standard out.
+ * Prints error message if resolve fails
*
* @param cls closure
* @param rd_count number of records in @a rd
* @param rd the records in the reply
*/
static void
-print_did_document (
- void *cls,
- uint32_t rd_count,
- const struct GNUNET_GNSRECORD_Data *rd)
-{
- /*
- * FIXME-MSC: The user may decide to put other records here.
- * In general I am fine with the constraint here, but not when
- * we move it to "@"
- */
- if (rd_count != 1)
- {
- printf ("An ego should only have one DID Document\n");
- GNUNET_SCHEDULER_add_now (cleanup, NULL);
- ret = 1;
- return;
- }
-
- if (rd[0].record_type == GNUNET_DNSPARSER_TYPE_TXT)
- {
- printf ("%s\n", (char *) rd[0].data);
- }
- else {
- printf ("DID Document is not a TXT record\n");
- }
-
- GNUNET_SCHEDULER_add_now (cleanup, NULL);
- ret = 0;
- return;
-}
-
-static void
-print_did_document2(
+print_did_document(
enum GNUNET_GenericReturnValue status,
char *did_document,
void *cls
@@ -285,23 +227,23 @@ print_did_document2(
static void
resolve_did_document ()
{
- // struct GNUNET_IDENTITY_PublicKey pkey;
-
- // if (did == NULL)
- // {
- // printf ("Set DID option to resolve DID\n");
- // GNUNET_SCHEDULER_add_now (cleanup, NULL);
- // ret = 1;
- // return;
- // }
-
- // get_pkey_from_attr_did (&pkey);
+ struct GNUNET_IDENTITY_PublicKey pkey;
- // GNUNET_GNS_lookup (gns_handle, GNUNET_GNS_EMPTY_LABEL_AT, &pkey,
- // GNUNET_DNSPARSER_TYPE_TXT,
- // GNUNET_GNS_LO_DEFAULT, &print_did_document, NULL);
+ if (did == NULL)
+ {
+ printf ("Set DID option to resolve DID\n");
+ GNUNET_SCHEDULER_add_now (cleanup, NULL);
+ ret = 1;
+ return;
+ }
- DID_resolve(did, gns_handle, print_did_document2, NULL);
+ if (GNUNET_OK != DID_resolve(did, gns_handle, print_did_document, NULL))
+ {
+ printf("An error occured while resoling the DID\n");
+ GNUNET_SCHEDULER_add_now(cleanup, NULL);
+ ret = 0;
+ return;
+ }
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] 55/70: - finished DID helper with tests, (continued)
- [gnunet] 55/70: - finished DID helper with tests, gnunet, 2022/08/31
- [gnunet] 60/70: - started with DID lib create func, gnunet, 2022/08/31
- [gnunet] 54/70: - default did document test without multibase, gnunet, 2022/08/31
- [gnunet] 68/70: - DID lib; simplify closure, gnunet, 2022/08/31
- [gnunet] 30/70: -DID refactor, uncrustify, not working didd create, gnunet, 2022/08/31
- [gnunet] 31/70: - did not working create, gnunet, 2022/08/31
- [gnunet] 46/70: -code review, gnunet, 2022/08/31
- [gnunet] 53/70: - more tests, gnunet, 2022/08/31
- [gnunet] 61/70: - non working DID lib create func, gnunet, 2022/08/31
- [gnunet] 57/70: - changed did_core header, gnunet, 2022/08/31
- [gnunet] 59/70: - DID resolve using DID lib,
gnunet <=
- [gnunet] 67/70: - DID lib; formatting, gnunet, 2022/08/31
- [gnunet] 51/70: - trying to make did_helper a lib, gnunet, 2022/08/31
- [gnunet] 64/70: - didlib; use expire value, gnunet, 2022/08/31
- [gnunet] 69/70: - added gitignores, gnunet, 2022/08/31
- [gnunet] 65/70: -m DID lib; added check for existing DID document, gnunet, 2022/08/31
- [gnunet] 22/70: -did mulitbase key and assert method for VCs, gnunet, 2022/08/31
- [gnunet] 25/70: -forgot the .c..., gnunet, 2022/08/31