aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Schwieren <tristan.schwieren@tum.de>2021-11-30 11:08:42 +0100
committerMartin Schanzenbach <schanzen@gnunet.org>2021-12-21 17:17:07 +0100
commit6a762139b8272d8c6f124687f18027151b96f9ef (patch)
treea84b99b3219e73b4d4ebf8cf474cc01fc47a3f54 /src
parent4597a6d7ed691a4e815946494643d3926a9d2ee0 (diff)
downloadgnunet-6a762139b8272d8c6f124687f18027151b96f9ef.tar.gz
gnunet-6a762139b8272d8c6f124687f18027151b96f9ef.zip
- did working remove
Diffstat (limited to 'src')
-rw-r--r--src/did/gnunet-did.c61
1 files changed, 39 insertions, 22 deletions
diff --git a/src/did/gnunet-did.c b/src/did/gnunet-did.c
index 0073384dd..7ed004263 100644
--- a/src/did/gnunet-did.c
+++ b/src/did/gnunet-did.c
@@ -60,14 +60,14 @@ static char *attr_ego;
60 60
61static struct GNUNET_GNS_Handle *gns_handle; 61static struct GNUNET_GNS_Handle *gns_handle;
62static struct GNUNET_NAMESTORE_Handle *namestore_handle; 62static struct GNUNET_NAMESTORE_Handle *namestore_handle;
63static struct GNUNET_CONFIGURATRION_Handle *c; 63static struct GNUNET_CONFIGURATRION_Handle *my_cfg;
64 64
65static void resolve_did_document(); 65static void resolve_did_document();
66static void add_did_document(); 66static void add_did_document();
67static void get_pkey_from_attr_did(); 67static void get_pkey_from_attr_did();
68static void print_did_document(); 68static void print_did_document();
69static void remove_did_document(); 69static void remove_did_document();
70static void remove_did_ego_lookup_callback(); 70static void remove_did_ego_lookup_cb();
71static void remove_did_callback(); 71static void remove_did_callback();
72 72
73// TODO 73// TODO
@@ -89,6 +89,7 @@ run (void *cls,
89{ 89{
90 gns_handle = GNUNET_GNS_connect(c); 90 gns_handle = GNUNET_GNS_connect(c);
91 namestore_handle = GNUNET_NAMESTORE_connect(c); 91 namestore_handle = GNUNET_NAMESTORE_connect(c);
92 my_cfg = c;
92 93
93 // check if GNS_handle could connect 94 // check if GNS_handle could connect
94 if(gns_handle == NULL){ 95 if(gns_handle == NULL){
@@ -115,9 +116,9 @@ run (void *cls,
115 116
116 if (NULL != attr_add) { 117 if (NULL != attr_add) {
117 add_did_document(); 118 add_did_document();
118 } else if (NULL != attr_did && 1 == attr_get){ 119 } else if (1 == attr_get){
119 resolve_did_document(); 120 resolve_did_document();
120 } else if (NULL != attr_ego && 1 == attr_remove) { 121 } else if (1 == attr_remove) {
121 remove_did_document(); 122 remove_did_document();
122 } else { 123 } else {
123 // No Argument found 124 // No Argument found
@@ -147,12 +148,12 @@ main (int argc, char *const argv[])
147 &attr_get), 148 &attr_get),
148 GNUNET_GETOPT_option_string ('d', 149 GNUNET_GETOPT_option_string ('d',
149 "did", 150 "did",
150 "VALUE", 151 "DID",
151 gettext_noop ("The DID to work with"), 152 gettext_noop ("The DID to work with"),
152 &attr_did), 153 &attr_did),
153 GNUNET_GETOPT_option_string ('e', 154 GNUNET_GETOPT_option_string ('e',
154 "ego", 155 "ego",
155 "VALUE", 156 "EGO",
156 gettext_noop ("The EGO to work with"), 157 gettext_noop ("The EGO to work with"),
157 &attr_ego), 158 &attr_ego),
158 GNUNET_GETOPT_OPTION_END 159 GNUNET_GETOPT_OPTION_END
@@ -179,6 +180,10 @@ add_did_document(){
179static void 180static void
180resolve_did_document() 181resolve_did_document()
181{ 182{
183 if (attr_did == NULL){
184 printf("Set DID option to resolve DID\n");
185 }
186
182 struct GNUNET_IDENTITY_PublicKey pkey; 187 struct GNUNET_IDENTITY_PublicKey pkey;
183 get_pkey_from_attr_did(&pkey); 188 get_pkey_from_attr_did(&pkey);
184 189
@@ -225,24 +230,36 @@ print_did_document(
225static void 230static void
226remove_did_document() 231remove_did_document()
227{ 232{
228 printf("remove_did_document: called\n"); 233 if(attr_did == NULL && attr_ego == NULL){
229 // TODO: Use ego->skey to remove did document 234 printf("Remove requieres an ego or did option\n");
230 printf("attr_ego: %s\n", attr_ego); 235 GNUNET_SCHEDULER_add_now(cleanup, NULL);
231 236 ret = 1;
232 GNUNET_IDENTITY_ego_lookup(c, 237 return;
233 attr_ego, 238 } else if(attr_did != NULL && attr_ego != NULL){
234 &remove_did_ego_lookup_callback, 239 printf("Only set one of the EGO or DID options\n");
235 NULL); 240 GNUNET_SCHEDULER_add_now(cleanup, NULL);
236 241 ret = 1;
237 // TODO: Use did->pkey->ego->skey to remove did document 242 return;
238 // struct GNUNET_IDENTITY_PublicKey pkey; 243 } else if (attr_ego != NULL){
239 // get_pkey_from_attr_did(&pkey); 244 GNUNET_IDENTITY_ego_lookup(my_cfg,
240 printf("remove_did_document: done\n"); 245 attr_ego,
246 &remove_did_ego_lookup_cb,
247 NULL);
248 } else if (attr_did != NULL){
249 // TODO: Use did->pkey->ego->skey to remove did document
250 // struct GNUNET_IDENTITY_PublicKey pkey;
251 // get_pkey_from_attr_did(&pkey);
252 printf("Remove by DID not supported\n");
253 GNUNET_SCHEDULER_add_now(cleanup, NULL);
254 ret = 1;
255 return;
256 } else {
257 printf("Something during the remove went wrong. Make sure you set the options correct\n");
258 }
241} 259}
242 260
243static void 261static void
244remove_did_ego_lookup_callback(void *cls, struct GNUNET_IDENTITY_Ego * ego){ 262remove_did_ego_lookup_cb(void *cls, struct GNUNET_IDENTITY_Ego * ego){
245 printf("remove_did_ego_lookup_callback: called\n");
246 const struct GNUNET_IDENTITY_PrivateKey * skey = GNUNET_IDENTITY_ego_get_private_key(ego); 263 const struct GNUNET_IDENTITY_PrivateKey * skey = GNUNET_IDENTITY_ego_get_private_key(ego);
247 const int emp[0]; 264 const int emp[0];
248 struct GNUNET_GNSRECORD_Data rd = { 265 struct GNUNET_GNSRECORD_Data rd = {
@@ -260,11 +277,11 @@ remove_did_ego_lookup_callback(void *cls, struct GNUNET_IDENTITY_Ego * ego){
260 &rd, 277 &rd,
261 &remove_did_callback, 278 &remove_did_callback,
262 NULL); 279 NULL);
263 printf("remove_did_ego_lookup_callback: done\n");
264} 280}
265 281
266static void 282static void
267remove_did_callback(){ 283remove_did_callback(){
284 // Test if record was removed from Namestore
268 printf("DID Document has been removed\n"); 285 printf("DID Document has been removed\n");
269 GNUNET_SCHEDULER_add_now(cleanup, NULL); 286 GNUNET_SCHEDULER_add_now(cleanup, NULL);
270 ret = 0; 287 ret = 0;