-more work on new GNS implementation
[oweals/gnunet.git] / src / gns / gnunet-service-gns.c
1 /*
2      This file is part of GNUnet.
3      (C) 2011-2013 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20 /**
21  * @file gns/gnunet-service-gns.c
22  * @brief GNUnet GNS service
23  * @author Martin Schanzenbach
24  * @author Christian Grothoff
25  *
26  * TODO:
27  * - conversion of private to public records does NOT check if the
28  *   records are actually public 
29  * - need to watch for client disconnects and abort operations on
30  *   disconnect
31  */
32 #include "platform.h"
33 #include "gnunet_util_lib.h"
34 #include "gnunet_transport_service.h"
35 #include "gnunet_dns_service.h"
36 #include "gnunet_dnsparser_lib.h"
37 #include "gnunet_dht_service.h"
38 #include "gnunet_namestore_service.h"
39 #include "gnunet_gns_service.h"
40 #include "gnunet_statistics_service.h"
41 #include "gns.h"
42 #include "gns_common.h"
43 #include "gnunet-service-gns_resolver.h"
44 #include "gnunet-service-gns_interceptor.h"
45 #include "gnunet_protocols.h"
46
47 /**
48  * The initial interval in milliseconds btween puts in
49  * a zone iteration
50  */
51 #define INITIAL_PUT_INTERVAL GNUNET_TIME_UNIT_MILLISECONDS
52
53 /**
54  * The upper bound for the zone iteration interval in milliseconds
55  */
56 #define MINIMUM_ZONE_ITERATION_INTERVAL GNUNET_TIME_UNIT_SECONDS
57
58 /**
59  * The default put interval for the zone iteration. In case
60  * no option is found
61  */
62 #define DEFAULT_ZONE_PUBLISH_TIME_WINDOW GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
63
64 /**
65  * The factor the current zone iteration interval is divided by for each
66  * additional new record
67  */
68 #define LATE_ITERATION_SPEEDUP_FACTOR 2
69
70 /**
71  * How long until a DHT PUT attempt should time out?
72  */
73 #define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
74
75 /**
76  * What replication level do we use for DHT PUT operations?
77  */
78 #define DHT_GNS_REPLICATION_LEVEL 5
79
80
81 /**
82  * Handle to a lookup operation from api
83  */
84 struct ClientLookupHandle
85 {
86
87   /**
88    * We keep these in a DLL.
89    */
90   struct ClientLookupHandle *next;
91
92   /**
93    * We keep these in a DLL.
94    */
95   struct ClientLookupHandle *prev;
96
97   /**
98    * Handle to the requesting client
99    */
100   struct GNUNET_SERVER_Client *client;
101
102   /**
103    * Active handle for the lookup.
104    */
105   struct GNS_ResolverHandle *lookup;
106
107   /**
108    * request id 
109    */
110   uint32_t request_id;
111
112 };
113
114
115 /**
116  * Our handle to the DHT
117  */
118 static struct GNUNET_DHT_Handle *dht_handle;
119
120 /**
121  * Active DHT put operation (or NULL)
122  */
123 static struct GNUNET_DHT_PutHandle *active_put;
124
125 /**
126  * Our handle to the namestore service
127  */
128 static struct GNUNET_NAMESTORE_Handle *namestore_handle;
129
130 /**
131  * Handle to iterate over our authoritative zone in namestore
132  */
133 static struct GNUNET_NAMESTORE_ZoneIterator *namestore_iter;
134
135 /**
136  * Our notification context.
137  */
138 static struct GNUNET_SERVER_NotificationContext *nc;
139
140 /**
141  * Head of the DLL.
142  */
143 static struct ClientLookupHandle *clh_head;
144
145 /**
146  * Tail of the DLL.
147  */
148 static struct ClientLookupHandle *clh_tail;
149
150 /**
151  * Useful for zone update for DHT put
152  */
153 static unsigned long long num_public_records;
154
155 /**
156  * Last seen record count
157  */
158 static unsigned long long last_num_public_records;
159
160 /**
161  * Zone iteration PUT interval.
162  */
163 static struct GNUNET_TIME_Relative put_interval;
164
165 /**
166  * Time window for zone iteration
167  */
168 static struct GNUNET_TIME_Relative zone_publish_time_window;
169
170 /**
171  * zone publish task
172  */
173 static GNUNET_SCHEDULER_TaskIdentifier zone_publish_task;
174
175 /**
176  * #GNUNET_YES if zone has never been published before
177  */
178 static int first_zone_iteration;
179
180 /**
181  * The lookup timeout
182  */
183 static struct GNUNET_TIME_Relative default_lookup_timeout;
184
185 /**
186  * #GNUNET_YES if ipv6 is supported
187  */
188 static int v6_enabled;
189
190 /**
191  * #GNUNET_YES if ipv4 is supported
192  */
193 static int v4_enabled;
194
195 /**
196  * Handle to the statistics service
197  */
198 static struct GNUNET_STATISTICS_Handle *statistics;
199
200
201 /**
202  * Task run during shutdown.
203  *
204  * @param cls unused
205  * @param tc unused
206  */
207 static void
208 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
209 {
210   struct ClientLookupHandle *clh;
211
212   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
213               "Shutting down!\n");
214   GNUNET_SERVER_notification_context_destroy (nc);  
215   while (NULL != (clh = clh_head))
216   {
217     GNS_resolver_lookup_cancel (clh->lookup);
218     GNUNET_CONTAINER_DLL_remove (clh_head, clh_tail, clh);
219     GNUNET_free (clh);
220   }
221
222   GNS_interceptor_done ();
223   GNS_resolver_done ();
224   if (NULL != statistics)
225   {
226     GNUNET_STATISTICS_destroy (statistics, GNUNET_NO);
227     statistics = NULL;
228   }
229   if (GNUNET_SCHEDULER_NO_TASK != zone_publish_task)
230   {
231     GNUNET_SCHEDULER_cancel (zone_publish_task);
232     zone_publish_task = GNUNET_SCHEDULER_NO_TASK;
233   }
234   if (NULL != namestore_iter)
235   {
236     GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter);
237     namestore_iter = NULL;
238   }
239   if (NULL != namestore_handle)
240   {
241     GNUNET_NAMESTORE_disconnect (namestore_handle);
242     namestore_handle = NULL;
243   }
244   if (NULL != active_put)
245   {
246     GNUNET_DHT_put_cancel (active_put);
247     active_put = NULL;
248   }
249   if (NULL != dht_handle)
250   {
251     GNUNET_DHT_disconnect (dht_handle);
252     dht_handle = NULL;
253   }
254 }
255
256
257 /**
258  * Method called periodically that triggers iteration over authoritative records
259  *
260  * @param cls closure
261  * @param tc task context
262  */
263 static void
264 publish_zone_dht_next (void *cls,
265                        const struct GNUNET_SCHEDULER_TaskContext *tc)
266 {
267   zone_publish_task = GNUNET_SCHEDULER_NO_TASK;
268   GNUNET_NAMESTORE_zone_iterator_next (namestore_iter);
269 }
270
271
272 /**
273  * Periodically iterate over our zone and store everything in dht
274  *
275  * @param cls NULL
276  * @param tc task context
277  */
278 static void
279 publish_zone_dht_start (void *cls, 
280                         const struct GNUNET_SCHEDULER_TaskContext *tc);
281
282
283 /**
284  * Continuation called from DHT once the PUT operation is done.
285  *
286  * @param cls closure, NULL
287  * @param success #GNUNET_OK on success
288  */
289 static void
290 dht_put_continuation (void *cls,
291                       int success)
292 {
293   struct GNUNET_TIME_Relative next_put_interval; 
294
295   num_public_records++;  
296   if ( (num_public_records > last_num_public_records) &&
297        (GNUNET_NO == first_zone_iteration) )
298   {
299     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
300                 "Last record count was lower than current record count.  Reducing interval.\n");
301     put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window,
302                                                 num_public_records);
303     next_put_interval = GNUNET_TIME_relative_divide (put_interval,
304                                                      LATE_ITERATION_SPEEDUP_FACTOR);
305   }
306   else
307     next_put_interval = put_interval;
308
309   GNUNET_STATISTICS_set (statistics,
310                          "Current zone iteration interval (ms)",
311                          next_put_interval.rel_value_us / 1000LL,
312                          GNUNET_NO); 
313   zone_publish_task = GNUNET_SCHEDULER_add_delayed (next_put_interval,
314                                                     &publish_zone_dht_next,
315                                                     NULL);
316 }
317
318
319 /**
320  * Function used to put all records successively into the DHT.
321  *
322  * @param cls the closure (NULL)
323  * @param key the private key of the authority (ours)
324  * @param name the name of the records, NULL once the iteration is done
325  * @param rd_count the number of records in @a rd
326  * @param rd the record data
327  */
328 static void
329 put_gns_record (void *cls,
330                 const struct GNUNET_CRYPTO_EccPrivateKey *key,
331                 const char *name,
332                 unsigned int rd_count,
333                 const struct GNUNET_NAMESTORE_RecordData *rd)
334 {  
335   struct GNUNET_NAMESTORE_Block *block;
336   struct GNUNET_HashCode query;
337   struct GNUNET_TIME_Absolute expire; 
338   size_t block_size;
339
340   if (NULL == name)
341   {
342     /* we're done with one iteration, calculate when to do the next one */
343     namestore_iter = NULL;
344     last_num_public_records = num_public_records;
345     first_zone_iteration = GNUNET_NO;
346     if (0 == num_public_records)
347     {
348       /**
349        * If no records are known (startup) or none present
350        * we can safely set the interval to the value for a single
351        * record
352        */
353       put_interval = zone_publish_time_window;
354       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
355                   "No records in namestore database.\n");
356     }
357     else
358     {
359       put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window,
360                                                   num_public_records);
361     }
362     put_interval = GNUNET_TIME_relative_max (MINIMUM_ZONE_ITERATION_INTERVAL,
363                                              put_interval);
364
365     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
366                 "Zone iteration finished. Adjusted zone iteration interval to %s\n",
367                 GNUNET_STRINGS_relative_time_to_string (put_interval, GNUNET_YES));
368     GNUNET_STATISTICS_set (statistics,
369                            "Current zone iteration interval (in ms)",
370                            put_interval.rel_value_us / 1000LL,
371                            GNUNET_NO);
372     GNUNET_STATISTICS_update (statistics,
373                               "Number of zone iterations", 
374                               1, 
375                               GNUNET_NO);
376     GNUNET_STATISTICS_set (statistics,
377                            "Number of public records in DHT",
378                            last_num_public_records,
379                            GNUNET_NO);
380     if (0 == num_public_records)
381       zone_publish_task = GNUNET_SCHEDULER_add_delayed (put_interval,
382                                                         &publish_zone_dht_start,
383                                                         NULL);
384     else
385       zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, 
386                                                     NULL);
387     return;
388   }
389
390   /* FIXME: filter out records that are not public! */
391
392   /* We got a set of records to publish */
393   if (0 == rd_count)
394   {
395     zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_next,
396                                                    NULL);
397     return;
398   }
399   expire = GNUNET_NAMESTORE_record_get_expiration_time (rd_count,
400                                                         rd);
401   block = GNUNET_NAMESTORE_block_create (key,
402                                          expire,
403                                          name,
404                                          rd,
405                                          rd_count);
406   block_size = ntohl (block->purpose.size) 
407     + sizeof (struct GNUNET_CRYPTO_EccSignature) 
408     + sizeof (struct GNUNET_CRYPTO_EccPublicKey);
409   GNUNET_NAMESTORE_query_from_private_key (key,
410                                            name,
411                                            &query);
412
413   active_put = GNUNET_DHT_put (dht_handle, &query,
414                                DHT_GNS_REPLICATION_LEVEL,
415                                GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
416                                GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
417                                block_size,
418                                block,
419                                expire,
420                                DHT_OPERATION_TIMEOUT,
421                                &dht_put_continuation,
422                                NULL); 
423   if (NULL == active_put)
424   {
425     GNUNET_break (0);
426     dht_put_continuation (NULL, GNUNET_NO);
427   }
428   GNUNET_free (block);
429 }
430
431
432 /**
433  * Periodically iterate over our zone and store everything in dht
434  *
435  * @param cls NULL
436  * @param tc task context
437  */
438 static void
439 publish_zone_dht_start (void *cls, 
440                         const struct GNUNET_SCHEDULER_TaskContext *tc)
441 {
442   zone_publish_task = GNUNET_SCHEDULER_NO_TASK;
443
444   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
445               "Scheduling DHT zone update!\n");  
446   /* start counting again */
447   num_public_records = 0;
448   namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle,
449                                                           NULL, /* All zones */
450                                                           &put_gns_record,
451                                                           NULL);
452 }
453
454
455 /* END DHT ZONE PROPAGATION */
456
457
458 /**
459  * Reply to client with the result from our lookup.
460  *
461  * @param cls the closure (our client lookup handle)
462  * @param rd_count the number of records
463  * @param rd the record data
464  */
465 static void
466 send_lookup_response (void* cls,
467                       uint32_t rd_count,
468                       const struct GNUNET_NAMESTORE_RecordData *rd)
469 {
470   struct ClientLookupHandle *clh = cls;
471   struct GNUNET_GNS_ClientLookupResultMessage *rmsg;
472   size_t len;
473   
474   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
475               "Sending `%s' message with %d results\n",
476               "LOOKUP_RESULT", 
477               rd_count);
478   
479   len = GNUNET_NAMESTORE_records_get_size (rd_count, rd);
480   rmsg = GNUNET_malloc (len + sizeof (struct GNUNET_GNS_ClientLookupResultMessage)); 
481   rmsg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT);
482   rmsg->header.size = htons (len + sizeof(struct GNUNET_GNS_ClientLookupResultMessage));
483   rmsg->id = clh->request_id;
484   rmsg->rd_count = htonl (rd_count); 
485   GNUNET_NAMESTORE_records_serialize (rd_count, rd, len, 
486                                       (char*) &rmsg[1]);
487   GNUNET_SERVER_notification_context_unicast (nc, 
488                                               clh->client,
489                                               &rmsg->header,
490                                               GNUNET_NO);
491   GNUNET_free (rmsg);
492   GNUNET_SERVER_receive_done (clh->client, 
493                               GNUNET_OK); 
494   GNUNET_CONTAINER_DLL_remove (clh_head, clh_tail, clh);
495   GNUNET_free (clh);
496   GNUNET_STATISTICS_update (statistics,
497                             "Completed lookups", 1, 
498                             GNUNET_NO);
499   GNUNET_STATISTICS_update (statistics,
500                             "Records resolved", 
501                             rd_count, 
502                             GNUNET_NO);
503 }
504
505
506 /**
507  * Handle lookup requests from client
508  *
509  * @param cls the closure
510  * @param client the client
511  * @param message the message
512  */
513 static void
514 handle_lookup (void *cls,
515                struct GNUNET_SERVER_Client *client,
516                const struct GNUNET_MessageHeader *message)
517 {
518   char name[GNUNET_DNSPARSER_MAX_NAME_LENGTH + 1];
519   struct ClientLookupHandle *clh;
520   char *nameptr = name;
521   const char *utf_in;
522   const struct GNUNET_CRYPTO_EccPrivateKey *key;
523   uint16_t msg_size;
524   const struct GNUNET_GNS_ClientLookupMessage *sh_msg;
525   
526   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
527               "Received `%s' message\n", 
528               "LOOKUP");
529   msg_size = ntohs (message->size);
530   if (msg_size < sizeof (struct GNUNET_GNS_ClientLookupMessage))
531   {
532     GNUNET_break (0);
533     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
534     return;
535   }
536   sh_msg = (const struct GNUNET_GNS_ClientLookupMessage *) message;
537   GNUNET_SERVER_notification_context_add (nc, client);
538   if (GNUNET_YES == ntohl (sh_msg->have_key))
539     key = &sh_msg->shorten_key;
540   else
541     key = NULL;
542   utf_in = (const char *) &sh_msg[1];
543   if ( ('\0' != utf_in[msg_size - sizeof (struct GNUNET_GNS_ClientLookupMessage) - 1]) ||
544        (strlen (utf_in) > GNUNET_DNSPARSER_MAX_NAME_LENGTH) )
545   {
546     GNUNET_break (0);
547     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
548     return;
549   }
550   GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr);
551   
552   clh = GNUNET_new (struct ClientLookupHandle);
553   GNUNET_CONTAINER_DLL_insert (clh_head, clh_tail, clh);
554   clh->client = client;
555   clh->request_id = sh_msg->id;
556   if ( (GNUNET_DNSPARSER_TYPE_A == ntohl (sh_msg->type)) &&
557        (GNUNET_OK != v4_enabled) )
558   {
559     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
560                 "LOOKUP: Query for A record but AF_INET not supported!");
561     send_lookup_response (clh, 0, NULL);
562     return;
563   }  
564   if ( (GNUNET_DNSPARSER_TYPE_AAAA == ntohl (sh_msg->type)) &&
565        (GNUNET_OK != v6_enabled) )
566   {
567     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
568                 "LOOKUP: Query for AAAA record but AF_INET6 not supported!");
569     send_lookup_response (clh, 0, NULL);
570     return;
571   }
572   clh->lookup = GNS_resolver_lookup (&sh_msg->zone, 
573                                      ntohl (sh_msg->type),
574                                      name,
575                                      key,
576                                      ntohl (sh_msg->only_cached),
577                                      &send_lookup_response, clh);
578   GNUNET_STATISTICS_update (statistics,
579                             "Lookup attempts", 
580                             1, GNUNET_NO);
581 }
582
583
584 /**
585  * Process GNS requests.
586  *
587  * @param cls closure
588  * @param server the initialized server
589  * @param c configuration to use
590  */
591 static void
592 run (void *cls, struct GNUNET_SERVER_Handle *server,
593      const struct GNUNET_CONFIGURATION_Handle *c)
594 {
595   static const struct GNUNET_SERVER_MessageHandler handlers[] = {
596     { &handle_lookup, NULL, GNUNET_MESSAGE_TYPE_GNS_LOOKUP, 0},
597     {NULL, NULL, 0, 0}
598   };
599   struct GNUNET_CRYPTO_EccPublicKey dns_root;
600   unsigned long long max_parallel_bg_queries = 0;
601   char *dns_root_name;
602
603   v6_enabled = GNUNET_NETWORK_test_pf (PF_INET6);
604   v4_enabled = GNUNET_NETWORK_test_pf (PF_INET);
605
606   namestore_handle = GNUNET_NAMESTORE_connect (c);
607   if (NULL == namestore_handle)
608   {
609     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
610                 _("Failed to connect to the namestore!\n"));
611     GNUNET_SCHEDULER_shutdown ();
612     return;
613   }
614   
615   put_interval = INITIAL_PUT_INTERVAL;
616   zone_publish_time_window = DEFAULT_ZONE_PUBLISH_TIME_WINDOW;
617
618   if (GNUNET_OK ==
619       GNUNET_CONFIGURATION_get_value_time (c, "gns",
620                                            "ZONE_PUBLISH_TIME_WINDOW",
621                                            &zone_publish_time_window))
622   {
623     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
624                 "Time window for zone iteration: %s\n",
625                 GNUNET_STRINGS_relative_time_to_string (zone_publish_time_window, GNUNET_YES));
626   }
627   if (GNUNET_OK ==
628       GNUNET_CONFIGURATION_get_value_number (c, "gns",
629                                             "MAX_PARALLEL_BACKGROUND_QUERIES",
630                                             &max_parallel_bg_queries))
631   {
632     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
633                 "Number of allowed parallel background queries: %llu\n",
634                 max_parallel_bg_queries);
635   }
636
637   if (GNUNET_OK ==
638       GNUNET_CONFIGURATION_get_value_time (c, "gns",
639                                            "DEFAULT_LOOKUP_TIMEOUT",
640                                            &default_lookup_timeout))
641   {
642     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
643                 "Default lookup timeout: %s\n",
644                 GNUNET_STRINGS_relative_time_to_string (default_lookup_timeout,
645                                                         GNUNET_YES));
646   }
647   
648   dht_handle = GNUNET_DHT_connect (c,
649                                    (unsigned int) max_parallel_bg_queries);
650   if (NULL == dht_handle)
651   {
652     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
653                 _("Could not connect to DHT!\n"));
654     GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
655     return;
656   }
657   
658   if (GNUNET_OK ==
659       GNUNET_CONFIGURATION_get_value_string (c, "gns", "DNS_ROOT",
660                                              &dns_root_name))
661   {
662     if (GNUNET_OK !=
663         GNUNET_CRYPTO_ecc_public_key_from_string (dns_root_name,
664                                                   strlen (dns_root_name),
665                                                   &dns_root))
666     {
667       GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
668                                  "gns", "DNS_ROOT", 
669                                  _("valid public key required"));
670       GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
671       GNUNET_free (dns_root_name);
672       return;
673     }
674     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
675                 "DNS hijacking with root `%s' enabled. Connecting to DNS service.\n",
676                 dns_root_name);
677     GNUNET_free (dns_root_name);    
678     if (GNUNET_SYSERR ==
679         GNS_interceptor_init (&dns_root, c))
680     {
681       GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
682       return;
683     }
684   }
685   /* FIXME: install client disconnect handle to clean up pending
686      lookups on client disconnect! */
687   GNS_resolver_init (namestore_handle, dht_handle, 
688                      c,
689                      max_parallel_bg_queries);
690   
691   /* Schedule periodic put for our records. */  
692   first_zone_iteration = GNUNET_YES;
693   GNUNET_SERVER_add_handlers (server, handlers);
694   statistics = GNUNET_STATISTICS_create ("gns", c);
695   nc = GNUNET_SERVER_notification_context_create (server, 1);
696   zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, 
697                                                 NULL);
698   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 
699                                 &shutdown_task, NULL);
700 }
701
702
703 /**
704  * The main function for the GNS service.
705  *
706  * @param argc number of arguments from the command line
707  * @param argv command line arguments
708  * @return 0 ok, 1 on error
709  */
710 int
711 main (int argc, char *const *argv)
712 {
713   int ret;
714
715   ret =
716       (GNUNET_OK ==
717        GNUNET_SERVICE_run (argc, argv, "gns", GNUNET_SERVICE_OPTION_NONE, &run,
718                            NULL)) ? 0 : 1;
719   return ret;
720 }
721
722 /* end of gnunet-service-gns.c */