More API function tests...
[oweals/gnunet.git] / src / gns / plugin_rest_gns.c
1 /*
2    This file is part of GNUnet.
3    Copyright (C) 2012-2015 GNUnet e.V.
4
5    GNUnet is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published
7    by the Free Software Foundation; either version 3, or (at your
8    option) any later version.
9
10    GNUnet is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with GNUnet; see the file COPYING.  If not, write to the
17    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18    Boston, MA 02110-1301, USA.
19    */
20 /**
21  * @author Martin Schanzenbach
22  * @file gns/plugin_rest_gns.c
23  * @brief GNUnet GNS REST plugin
24  *
25  */
26
27 #include "platform.h"
28 #include "gnunet_rest_plugin.h"
29 #include <gnunet_dnsparser_lib.h>
30 #include <gnunet_identity_service.h>
31 #include <gnunet_gnsrecord_lib.h>
32 #include <gnunet_namestore_service.h>
33 #include <gnunet_gns_service.h>
34 #include <gnunet_rest_lib.h>
35 #include <gnunet_jsonapi_lib.h>
36 #include <gnunet_jsonapi_util.h>
37 #include <jansson.h>
38
39 #define GNUNET_REST_API_NS_GNS "/gns"
40
41 #define GNUNET_REST_JSONAPI_GNS_RECORD_TYPE "record_type"
42
43 #define GNUNET_REST_JSONAPI_GNS_TYPEINFO "gns_name"
44
45 #define GNUNET_REST_JSONAPI_GNS_RECORD "records"
46
47 #define GNUNET_REST_JSONAPI_GNS_EGO "ego"
48
49 #define GNUNET_REST_JSONAPI_GNS_PKEY "pkey"
50
51 #define GNUNET_REST_JSONAPI_GNS_OPTIONS "options"
52
53 /**
54  * @brief struct returned by the initialization function of the plugin
55  */
56 struct Plugin
57 {
58   const struct GNUNET_CONFIGURATION_Handle *cfg;
59 };
60
61 const struct GNUNET_CONFIGURATION_Handle *cfg;
62
63 struct LookupHandle
64 {
65   /**
66    * Handle to GNS service.
67    */
68   struct GNUNET_GNS_Handle *gns;
69
70   /**
71    * Desired timeout for the lookup (default is no timeout).
72    */
73   struct GNUNET_TIME_Relative timeout;
74
75   /**
76    * Handle to lookup request
77    */
78   struct GNUNET_GNS_LookupRequest *lookup_request;
79
80   /**
81    * Handle to rest request
82    */
83   struct GNUNET_REST_RequestHandle *rest_handle;
84
85   /**
86    * Lookup an ego with the identity service.
87    */
88   struct GNUNET_IDENTITY_EgoLookup *el;
89
90   /**
91    * Handle for identity service.
92    */
93   struct GNUNET_IDENTITY_Handle *identity;
94
95   /**
96    * Active operation on identity service.
97    */
98   struct GNUNET_IDENTITY_Operation *id_op;
99
100   /**
101    * ID of a task associated with the resolution process.
102    */
103   struct GNUNET_SCHEDULER_Task * timeout_task;
104
105   /**
106    * The root of the received JSON or NULL
107    */
108   json_t *json_root;
109
110   /**
111    * The plugin result processor
112    */
113   GNUNET_REST_ResultProcessor proc;
114
115   /**
116    * The closure of the result processor
117    */
118   void *proc_cls;
119
120   /**
121    * The name to look up
122    */
123   char *name;
124
125   /**
126    * The ego to use
127    * In string representation from JSON
128    */
129   const char *ego_str;
130
131   /**
132    * The Pkey to use
133    * In string representation from JSON
134    */
135   const char *pkey_str;
136
137   /**
138    * The record type
139    */
140   int type;
141
142   /**
143    * The public key of to use for lookup
144    */
145   struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
146
147   /**
148    * The public key to use for lookup
149    */
150   struct GNUNET_CRYPTO_EcdsaPublicKey pkeym;
151
152   /**
153    * The resolver options
154    */
155   enum GNUNET_GNS_LocalOptions options;
156
157   /**
158    * the shorten key
159    */
160   struct GNUNET_CRYPTO_EcdsaPrivateKey shorten_key;
161
162   /**
163    * HTTP response code
164    */
165   int response_code;
166
167 };
168
169
170 /**
171  * Cleanup lookup handle.
172  *
173  * @param handle Handle to clean up
174  */
175 static void
176 cleanup_handle (struct LookupHandle *handle)
177 {
178   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
179               "Cleaning up\n");
180   if (NULL != handle->json_root)
181     json_decref (handle->json_root);
182
183   if (NULL != handle->name)
184     GNUNET_free (handle->name);
185   if (NULL != handle->el)
186   {
187     GNUNET_IDENTITY_ego_lookup_cancel (handle->el);
188     handle->el = NULL;
189   }
190   if (NULL != handle->id_op)
191   {
192     GNUNET_IDENTITY_cancel (handle->id_op);
193     handle->id_op = NULL;
194   }
195   if (NULL != handle->lookup_request)
196   {
197     GNUNET_GNS_lookup_cancel (handle->lookup_request);
198     handle->lookup_request = NULL;
199   }
200   if (NULL != handle->identity)
201   {
202     GNUNET_IDENTITY_disconnect (handle->identity);
203     handle->identity = NULL;
204   }
205   if (NULL != handle->gns)
206   {
207     GNUNET_GNS_disconnect (handle->gns);
208     handle->gns = NULL;
209   }
210
211   if (NULL != handle->timeout_task)
212   {
213     GNUNET_SCHEDULER_cancel (handle->timeout_task);
214   }
215   GNUNET_free (handle);
216 }
217
218
219 /**
220  * Task run on shutdown.  Cleans up everything.
221  *
222  * @param cls unused
223  * @param tc scheduler context
224  */
225 static void
226 do_error (void *cls)
227 {
228   struct LookupHandle *handle = cls;
229   struct MHD_Response *resp;
230
231   resp = GNUNET_REST_create_response (NULL);
232   handle->proc (handle->proc_cls, resp, handle->response_code);
233   cleanup_handle (handle);
234 }
235
236
237 /**
238  * Create json representation of a GNSRECORD
239  *
240  * @param rd the GNSRECORD_Data
241  */
242 static json_t *
243 gnsrecord_to_json (const struct GNUNET_GNSRECORD_Data *rd)
244 {
245   const char *typename;
246   char *string_val;
247   const char *exp_str;
248   json_t *record_obj;
249
250   typename = GNUNET_GNSRECORD_number_to_typename (rd->record_type);
251   string_val = GNUNET_GNSRECORD_value_to_string (rd->record_type,
252                                                  rd->data,
253                                                  rd->data_size);
254
255   if (NULL == string_val)
256   {
257     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
258                 "Record of type %d malformed, skipping\n",
259                 (int) rd->record_type);
260     return NULL;
261   }
262   record_obj = json_object ();
263   json_object_set_new (record_obj, "type", json_string (typename));
264   json_object_set_new (record_obj, "value", json_string (string_val));
265   GNUNET_free (string_val);
266
267   if (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION & rd->flags)
268   {
269     struct GNUNET_TIME_Relative time_rel;
270     time_rel.rel_value_us = rd->expiration_time;
271     exp_str = GNUNET_STRINGS_relative_time_to_string (time_rel, 1);
272   }
273   else
274   {
275     struct GNUNET_TIME_Absolute time_abs;
276     time_abs.abs_value_us = rd->expiration_time;
277     exp_str = GNUNET_STRINGS_absolute_time_to_string (time_abs);
278   }
279   json_object_set_new (record_obj, "expiration_time", json_string (exp_str));
280
281   json_object_set_new (record_obj, "expired",
282                        json_boolean (GNUNET_YES == GNUNET_GNSRECORD_is_expired (rd)));
283   return record_obj;
284 }
285
286 /**
287  * Function called with the result of a GNS lookup.
288  *
289  * @param cls the 'const char *' name that was resolved
290  * @param rd_count number of records returned
291  * @param rd array of @a rd_count records with the results
292  */
293 static void
294 process_lookup_result (void *cls, uint32_t rd_count,
295                        const struct GNUNET_GNSRECORD_Data *rd)
296 {
297   struct LookupHandle *handle = cls;
298   struct MHD_Response *resp;
299   struct GNUNET_JSONAPI_Document *json_document;
300   struct GNUNET_JSONAPI_Resource *json_resource;
301   uint32_t i;
302   char *result;
303   json_t *result_array;
304   json_t *record_obj;
305
306   result_array = json_array();
307   json_document = GNUNET_JSONAPI_document_new ();
308   json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_GNS_TYPEINFO, handle->name);
309   handle->lookup_request = NULL;
310   for (i=0; i<rd_count; i++)
311   {
312     if ( (rd[i].record_type != handle->type) &&
313          (GNUNET_GNSRECORD_TYPE_ANY != handle->type) )
314       continue;
315     record_obj = gnsrecord_to_json (&(rd[i]));
316     json_array_append (result_array, record_obj);
317     json_decref (record_obj);
318   }
319   GNUNET_JSONAPI_resource_add_attr (json_resource,
320                                          GNUNET_REST_JSONAPI_GNS_RECORD,
321                                          result_array);
322   GNUNET_JSONAPI_document_resource_add (json_document, json_resource);
323   GNUNET_JSONAPI_document_serialize (json_document, &result);
324   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result);
325   json_decref (result_array);
326   GNUNET_JSONAPI_document_delete (json_document);
327   resp = GNUNET_REST_create_response (result);
328   handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
329   GNUNET_free (result);
330   cleanup_handle (handle);
331 }
332
333
334 /**
335  * Perform the actual resolution, starting with the zone
336  * identified by the given public key and the shorten zone.
337  *
338  * @param pkey public key to use for the zone, can be NULL
339  * @param shorten_key private key used for shortening, can be NULL
340  */
341 static void
342 lookup_with_keys (struct LookupHandle *handle, const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key)
343 {
344   if (UINT32_MAX == handle->type)
345   {
346     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
347                 _("Invalid typename specified, assuming `ANY'\n"));
348     handle->type = GNUNET_GNSRECORD_TYPE_ANY;
349   }
350   if (NULL != handle->name)
351   {
352     handle->lookup_request = GNUNET_GNS_lookup (handle->gns,
353                                                 handle->name,
354                                                 &handle->pkey,
355                                                 handle->type,
356                                                 handle->options,
357                                                 shorten_key,
358                                                 &process_lookup_result,
359                                                 handle);
360   }
361   else
362   {
363     GNUNET_SCHEDULER_add_now (&do_error, handle);
364     return;
365   }
366 }
367
368 /**
369  * Method called to with the ego we are to use for shortening
370  * during the lookup.
371  *
372  * @param cls closure contains the public key to use
373  * @param ego ego handle, NULL if not found
374  * @param ctx context for application to store data for this ego
375  *                 (during the lifetime of this process, initially NULL)
376  * @param name name assigned by the user for this ego,
377  *                   NULL if the user just deleted the ego and it
378  *                   must thus no longer be used
379  */
380 static void
381 identity_shorten_cb (void *cls,
382                      struct GNUNET_IDENTITY_Ego *ego,
383                      void **ctx,
384                      const char *name)
385 {
386   struct LookupHandle *handle = cls;
387
388   handle->id_op = NULL;
389   if (NULL == ego)
390     lookup_with_keys (handle, NULL);
391   else
392     lookup_with_keys (handle,
393                       GNUNET_IDENTITY_ego_get_private_key (ego));
394 }
395
396 /**
397  * Perform the actual resolution, starting with the zone
398  * identified by the given public key.
399  *
400  * @param pkey public key to use for the zone
401  */
402 static void
403 lookup_with_public_key (struct LookupHandle *handle)
404 {
405   handle->pkeym = handle->pkey;
406   GNUNET_break (NULL == handle->id_op);
407   handle->id_op = GNUNET_IDENTITY_get (handle->identity,
408                                        "gns-short",
409                                        &identity_shorten_cb,
410                                        handle);
411   if (NULL == handle->id_op)
412   {
413     GNUNET_break (0);
414     lookup_with_keys (handle, NULL);
415   }
416 }
417
418 /**
419  * Method called to with the ego we are to use for the lookup,
420  * when the ego is determined by a name.
421  *
422  * @param cls closure (NULL, unused)
423  * @param ego ego handle, NULL if not found
424  */
425 static void
426 identity_zone_cb (void *cls,
427                   const struct GNUNET_IDENTITY_Ego *ego)
428 {
429   struct LookupHandle *handle = cls;
430
431   handle->el = NULL;
432   if (NULL == ego)
433   {
434     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
435                 _("Ego for not found, cannot perform lookup.\n"));
436     GNUNET_SCHEDULER_add_now (&do_error, handle);
437     return;
438   }
439   else
440   {
441     GNUNET_IDENTITY_ego_get_public_key (ego, &handle->pkey);
442     lookup_with_public_key (handle);
443   }
444   json_decref(handle->json_root);
445 }
446
447 /**
448  * Method called to with the ego we are to use for the lookup,
449  * when the ego is the one for the default master zone.
450  *
451  * @param cls closure (NULL, unused)
452  * @param ego ego handle, NULL if not found
453  * @param ctx context for application to store data for this ego
454  *                 (during the lifetime of this process, initially NULL)
455  * @param name name assigned by the user for this ego,
456  *                   NULL if the user just deleted the ego and it
457  *                   must thus no longer be used
458  */
459 static void
460 identity_master_cb (void *cls,
461                     struct GNUNET_IDENTITY_Ego *ego,
462                     void **ctx,
463                     const char *name)
464 {
465   const char *dot;
466   struct LookupHandle *handle = cls;
467
468   handle->id_op = NULL;
469   if (NULL == ego)
470   {
471     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
472                 _("Ego for `gns-master' not found, cannot perform lookup.  Did you run gnunet-gns-import.sh?\n"));
473     GNUNET_SCHEDULER_add_now (&do_error, handle);
474     return;
475   }
476   GNUNET_IDENTITY_ego_get_public_key (ego, &handle->pkey);
477   /* main name is our own master zone, do no look for that in the DHT */
478   handle->options = GNUNET_GNS_LO_LOCAL_MASTER;
479   /* if the name is of the form 'label.gnu', never go to the DHT */
480   dot = NULL;
481   if (NULL != handle->name)
482     dot = strchr (handle->name, '.');
483   if ( (NULL != dot) &&
484        (0 == strcasecmp (dot, ".gnu")) )
485     handle->options = GNUNET_GNS_LO_NO_DHT;
486   lookup_with_public_key (handle);
487 }
488
489 /**
490  * Parse REST uri for name and record type
491  *
492  * @param url Url to parse
493  * @param handle lookup handle to populate
494  * @return GNUNET_SYSERR on error
495  */
496 static int
497 parse_url (const char *url, struct LookupHandle *handle)
498 {
499   char *name;
500   char tmp_url[strlen(url)+1];
501   char *tok;
502
503   strcpy (tmp_url, url);
504   tok = strtok ((char*)tmp_url, "/");
505   if (NULL == tok)
506     return GNUNET_SYSERR;
507   name = strtok (NULL, "/");
508   if (NULL == name)
509     return GNUNET_SYSERR;
510   GNUNET_asprintf (&handle->name,
511                    "%s",
512                    name);
513   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
514               "Got name: %s\n", handle->name);
515   return GNUNET_OK;
516 }
517
518 static void
519 get_gns_cont (struct GNUNET_REST_RequestHandle *conndata_handle,
520               const char* url,
521               void *cls)
522 {
523   struct LookupHandle *handle = cls;
524   struct GNUNET_HashCode key;
525
526   //parse name and type from url
527   if (GNUNET_OK != parse_url (url, handle))
528   {
529     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error parsing url...\n");
530     GNUNET_SCHEDULER_add_now (&do_error, handle);
531     return;
532   }
533   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
534               "Connecting...\n");
535   handle->gns = GNUNET_GNS_connect (cfg);
536   handle->identity = GNUNET_IDENTITY_connect (cfg, NULL, NULL);
537   handle->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->timeout,
538                                                        &do_error, handle);
539   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
540               "Connected\n");
541   if (NULL == handle->gns)
542   {
543     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
544                 "Connecting to GNS failed\n");
545     GNUNET_SCHEDULER_add_now (&do_error, handle);
546     return;
547   }
548   GNUNET_CRYPTO_hash (GNUNET_REST_JSONAPI_GNS_OPTIONS,
549                       strlen (GNUNET_REST_JSONAPI_GNS_OPTIONS),
550                       &key);
551   handle->options = GNUNET_GNS_LO_DEFAULT;
552   if ( GNUNET_YES ==
553        GNUNET_CONTAINER_multihashmap_contains (conndata_handle->url_param_map,
554                                                &key) )
555   {
556     handle->options = GNUNET_GNS_LO_DEFAULT;//TODO(char*) GNUNET_CONTAINER_multihashmap_get (conndata_handle->url_param_map,
557     //&key);
558   }
559   GNUNET_CRYPTO_hash (GNUNET_REST_JSONAPI_GNS_RECORD_TYPE,
560                       strlen (GNUNET_REST_JSONAPI_GNS_RECORD_TYPE),
561                       &key);
562   if ( GNUNET_YES ==
563        GNUNET_CONTAINER_multihashmap_contains (conndata_handle->url_param_map,
564                                                &key) )
565   {
566     handle->type = GNUNET_GNSRECORD_typename_to_number
567       (GNUNET_CONTAINER_multihashmap_get (conndata_handle->url_param_map,
568                                           &key));
569   }
570   else
571     handle->type = GNUNET_GNSRECORD_TYPE_ANY;
572
573   GNUNET_CRYPTO_hash (GNUNET_REST_JSONAPI_GNS_PKEY,
574                       strlen (GNUNET_REST_JSONAPI_GNS_PKEY),
575                       &key);
576   if ( GNUNET_YES ==
577        GNUNET_CONTAINER_multihashmap_contains (conndata_handle->url_param_map,
578                                                &key) )
579   {
580     handle->pkey_str = GNUNET_CONTAINER_multihashmap_get (conndata_handle->url_param_map,
581                                                           &key);
582     if (GNUNET_OK !=
583         GNUNET_CRYPTO_ecdsa_public_key_from_string (handle->pkey_str,
584                                                     strlen(handle->pkey_str),
585                                                     &(handle->pkey)))
586     {
587       GNUNET_SCHEDULER_add_now (&do_error, handle);
588       return;
589     }
590     lookup_with_public_key (handle);
591     return;
592   }
593   GNUNET_CRYPTO_hash (GNUNET_REST_JSONAPI_GNS_EGO,
594                       strlen (GNUNET_REST_JSONAPI_GNS_EGO),
595                       &key);
596   if ( GNUNET_YES ==
597        GNUNET_CONTAINER_multihashmap_contains (conndata_handle->url_param_map,
598                                                &key) )
599   {
600     handle->ego_str = GNUNET_CONTAINER_multihashmap_get (conndata_handle->url_param_map,
601                                                          &key);
602     handle->el = GNUNET_IDENTITY_ego_lookup (cfg,
603                                              handle->ego_str,
604                                              &identity_zone_cb,
605                                              handle);
606     return;
607   }
608   if ( (NULL != handle->name) &&
609        (strlen (handle->name) > 4) &&
610        (0 == strcmp (".zkey",
611                      &handle->name[strlen (handle->name) - 4])) )
612   {
613     GNUNET_CRYPTO_ecdsa_key_get_public
614       (GNUNET_CRYPTO_ecdsa_key_get_anonymous (),
615        &(handle->pkey));
616     lookup_with_public_key (handle);
617   }
618   else
619   {
620     GNUNET_break (NULL == handle->id_op);
621     handle->id_op = GNUNET_IDENTITY_get (handle->identity,
622                                          "gns-master",
623                                          &identity_master_cb,
624                                          handle);
625     GNUNET_assert (NULL != handle->id_op);
626   }
627 }
628
629 /**
630  * Handle rest request
631  *
632  * @param handle the lookup handle
633  */
634 static void
635 options_cont (struct GNUNET_REST_RequestHandle *con_handle,
636               const char* url,
637               void *cls)
638 {
639   struct MHD_Response *resp;
640   struct LookupHandle *handle = cls;
641
642   //For GNS, independent of path return all options
643   resp = GNUNET_REST_create_response (NULL);
644   MHD_add_response_header (resp,
645                            "Access-Control-Allow-Methods",
646                            MHD_HTTP_METHOD_GET);
647   handle->proc (handle->proc_cls,
648                 resp,
649                 MHD_HTTP_OK);
650   cleanup_handle (handle);
651 }
652
653
654 /**
655  * Function processing the REST call
656  *
657  * @param method HTTP method
658  * @param url URL of the HTTP request
659  * @param data body of the HTTP request (optional)
660  * @param data_size length of the body
661  * @param proc callback function for the result
662  * @param proc_cls closure for callback function
663  * @return GNUNET_OK if request accepted
664  */
665 static void
666 rest_gns_process_request(struct GNUNET_REST_RequestHandle *conndata_handle,
667                          GNUNET_REST_ResultProcessor proc,
668                          void *proc_cls)
669 {
670   struct LookupHandle *handle = GNUNET_new (struct LookupHandle);
671   struct GNUNET_REST_RequestHandlerError err;
672
673   handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
674   handle->proc_cls = proc_cls;
675   handle->proc = proc;
676   handle->rest_handle = conndata_handle;
677
678   static const struct GNUNET_REST_RequestHandler handlers[] = {
679     {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_GNS, &get_gns_cont},
680     {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_GNS, &options_cont},
681     GNUNET_REST_HANDLER_END
682   };
683
684   if (GNUNET_NO == GNUNET_JSONAPI_handle_request (conndata_handle,
685                                                   handlers,
686                                                   &err,
687                                                   handle))
688   {
689     handle->response_code = err.error_code;
690     GNUNET_SCHEDULER_add_now (&do_error, handle);
691   }
692 }
693
694
695 /**
696  * Entry point for the plugin.
697  *
698  * @param cls the "struct GNUNET_NAMESTORE_PluginEnvironment*"
699  * @return NULL on error, otherwise the plugin context
700  */
701 void *
702 libgnunet_plugin_rest_gns_init (void *cls)
703 {
704   static struct Plugin plugin;
705   cfg = cls;
706   struct GNUNET_REST_Plugin *api;
707
708   if (NULL != plugin.cfg)
709     return NULL;                /* can only initialize once! */
710   memset (&plugin, 0, sizeof (struct Plugin));
711   plugin.cfg = cfg;
712   api = GNUNET_new (struct GNUNET_REST_Plugin);
713   api->cls = &plugin;
714   api->name = GNUNET_REST_API_NS_GNS;
715   api->process_request = &rest_gns_process_request;
716   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
717               _("GNS REST API initialized\n"));
718   return api;
719 }
720
721
722 /**
723  * Exit point from the plugin.
724  *
725  * @param cls the plugin context (as returned by "init")
726  * @return always NULL
727  */
728 void *
729 libgnunet_plugin_rest_gns_done (void *cls)
730 {
731   struct GNUNET_REST_Plugin *api = cls;
732   struct Plugin *plugin = api->cls;
733
734   plugin->cfg = NULL;
735   GNUNET_free (api);
736   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
737               "GNS REST plugin is finished\n");
738   return NULL;
739 }
740
741 /* end of plugin_rest_gns.c */