[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 05/25: Direct Namestore Deletion Implemented
From: |
gnunet |
Subject: |
[gnunet] 05/25: Direct Namestore Deletion Implemented |
Date: |
Mon, 13 Jan 2020 13:46:50 +0100 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit d5178cdc05a0d91293d9ee2cef45ab9a1c515bac
Author: Markus Voggenreiter <address@hidden>
AuthorDate: Sat Oct 12 22:26:24 2019 +0200
Direct Namestore Deletion Implemented
---
src/reclaim/plugin_rest_reclaim.c | 183 ++++++++++++++++++++++++++++++++------
1 file changed, 158 insertions(+), 25 deletions(-)
diff --git a/src/reclaim/plugin_rest_reclaim.c
b/src/reclaim/plugin_rest_reclaim.c
index b42394906..bb08e6385 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -297,6 +297,73 @@ struct AttributeStoreHandle
uint32_t r_id;
};
+/**
+ * Handle for attribute deletion request
+ */
+struct AttributeDeleteHandle
+{
+ /**
+ * DLL
+ */
+ struct AttributeDeleteHandle *next;
+
+ /**
+ * DLL
+ */
+ struct AttributeDeleteHandle *prev;
+
+ /**
+ * Client connection
+ */
+ struct IdpClient *client;
+
+ /**
+ * Identity
+ */
+ struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
+
+
+ /**
+ * QueueEntry
+ */
+ struct GNUNET_NAMESTORE_QueueEntry *ns_qe;
+
+ /**
+ * Iterator
+ */
+ struct GNUNET_NAMESTORE_ZoneIterator *ns_it;
+
+ /**
+ * The attribute to delete
+ */
+ struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
+
+ /**
+ * The attestation to store
+ */
+ struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
+
+ /**
+ * Tickets to update
+ */
+ struct TicketRecordsEntry *tickets_to_update_head;
+
+ /**
+ * Tickets to update
+ */
+ struct TicketRecordsEntry *tickets_to_update_tail;
+
+ /**
+ * Attribute label
+ */
+ char *label;
+
+ /**
+ * request id
+ */
+ uint32_t r_id;
+};
+
/**
* Handle to the service.
*/
@@ -502,6 +569,21 @@ finished_cont (void *cls, int32_t success, const char
*emsg)
GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
}
+static void
+delete_finished_cb (void *cls, int32_t success, const char *emsg)
+{
+ struct RequestHandle *handle = cls;
+ struct MHD_Response *resp;
+
+ resp = GNUNET_REST_create_response (emsg);
+ if (GNUNET_OK != success)
+ {
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+ handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
+ GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
+}
/**
* Return attributes for identity
@@ -674,10 +756,6 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle
*con_handle,
ash->exp.rel_value_us = exp_interval->rel_value_us;
ash->attest = attribute;
ash->client = idp;
- /*GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Type:%u\n", type);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ID:%s\n", id_str);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Size:%u\n", data_size);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data:%s\n", data);*/
buf_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (ash->attest);
buf = GNUNET_malloc (buf_size);
// Give the ash a new id if unset
@@ -716,15 +794,87 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle
*con_handle,
return;
}
-/*Placeholder*/
+/*WIP*/
static void
delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
const char *url,
void *cls)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Deleting Attestations not
supported\n");
- GNUNET_SCHEDULER_add_now (&do_error, cls);
- return;
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
+ struct RequestHandle *handle = cls;
+ struct GNUNET_RECLAIM_ATTESTATION_Claim attr;
+ struct EgoEntry *ego_entry;
+ char *identity_id_str;
+ char *identity;
+ char *id;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attestation.\n");
+ if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) >= strlen (
+ handle->url))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+ identity_id_str =
+ strdup (handle->url + strlen (
+ GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + 1);
+ identity = strtok (identity_id_str, "/");
+ id = strtok (NULL, "/");
+ if ((NULL == identity) || (NULL == id))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
+ GNUNET_free (identity_id_str);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+
+ for (ego_entry = handle->ego_head; NULL != ego_entry;
+ ego_entry = ego_entry->next)
+ if (0 == strcmp (identity, ego_entry->identifier))
+ break;
+ handle->resp_object = json_array ();
+ if (NULL == ego_entry)
+ {
+ // Done
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
+ GNUNET_free (identity_id_str);
+ GNUNET_SCHEDULER_add_now (&return_response, handle);
+ return;
+ }
+ priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
+ handle->idp = GNUNET_RECLAIM_connect (cfg);
+ memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim));
+ GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(uint64_t));
+ attr.name = "";
+
+ struct GNUNET_RECLAIM_Handle *h = handle->idp;
+ struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey = priv_key;
+
+ struct AttributeDeleteHandle *adh;
+ struct IdpClient *idp = handle;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
+ struct GNUNET_NAMESTORE_Handle *nsh;
+ nsh = GNUNET_NAMESTORE_connect (cfg);
+ adh = GNUNET_new (struct AttributeDeleteHandle);
+ adh->attest = &attr;
+ adh->r_id = h->r_id_gen++;
+ adh->identity = *pkey;
+ adh->label = GNUNET_STRINGS_data_to_string_alloc (&adh->attest->id,
+ sizeof(uint64_t));
+ /*GNUNET_SERVICE_client_continue (idp->client);*/
+ adh->client = idp;
+ /*GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail,
adh);*/
+ adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
+ &adh->identity,
+ adh->label,
+ 0,
+ NULL,
+ &delete_finished_cb,
+ adh);
+
+
+ GNUNET_free (identity_id_str);
}
/**
@@ -958,23 +1108,6 @@ list_attribute_cont (struct GNUNET_REST_RequestHandle
*con_handle,
}
-static void
-delete_finished_cb (void *cls, int32_t success, const char *emsg)
-{
- struct RequestHandle *handle = cls;
- struct MHD_Response *resp;
-
- resp = GNUNET_REST_create_response (emsg);
- if (GNUNET_OK != success)
- {
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
- GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
-}
-
-
/**
* List attributes for identity request
*
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnunet] branch master updated (c0a6838a1 -> e52520756), gnunet, 2020/01/13
- [gnunet] 03/25: Initial Fixes of plugin, gnunet, 2020/01/13
- [gnunet] 01/25: Adapted Namestore and reclaim REST, gnunet, 2020/01/13
- [gnunet] 02/25: Adapted JSON Conversion and Serialization, gnunet, 2020/01/13
- [gnunet] 04/25: Fixed direct Namestore Access, gnunet, 2020/01/13
- [gnunet] 05/25: Direct Namestore Deletion Implemented,
gnunet <=
- [gnunet] 06/25: Add Attestations via Reclaim Service, gnunet, 2020/01/13
- [gnunet] 07/25: Delete Attestation via Service, gnunet, 2020/01/13
- [gnunet] 08/25: Prepare Listing Attestations, gnunet, 2020/01/13
- [gnunet] 10/25: some comments, gnunet, 2020/01/13
- [gnunet] 09/25: Listing Attestations through service, gnunet, 2020/01/13
- [gnunet] 11/25: Preparation for Reference Type, gnunet, 2020/01/13
- [gnunet] 12/25: Adding Reference Type Implemented, gnunet, 2020/01/13
- [gnunet] 13/25: Deletion of Reference Type, gnunet, 2020/01/13
- [gnunet] 14/25: Fixed Reference Deletion, gnunet, 2020/01/13
- [gnunet] 16/25: Listing of References with Attributes, gnunet, 2020/01/13