2 This file is part of GNUnet.
3 (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
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.
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.
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.
23 * @file gns/gnunet-service-gns.c
24 * @brief GNUnet GNS service
25 * @author Martin Schanzenbach
28 #include "gnunet_util_lib.h"
29 #include "gnunet_transport_service.h"
30 #include "gnunet_dns_service.h"
31 #include "gnunet_dnsparser_lib.h"
32 #include "gnunet_dht_service.h"
33 #include "gnunet_namestore_service.h"
34 #include "gnunet_gns_service.h"
35 #include "block_gns.h"
37 #include "gnunet-service-gns_resolver.h"
38 #include "gnunet-service-gns_interceptor.h"
40 /* FIXME move to proper header in include */
41 #define GNUNET_MESSAGE_TYPE_GNS_LOOKUP 23
42 #define GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT 24
43 #define GNUNET_MESSAGE_TYPE_GNS_SHORTEN 25
44 #define GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT 26
45 #define GNUNET_MESSAGE_TYPE_GNS_GET_AUTH 27
46 #define GNUNET_MESSAGE_TYPE_GNS_GET_AUTH_RESULT 28
50 * Handle to a shorten operation from api
52 struct ClientShortenHandle
54 /* the requesting client that */
55 struct GNUNET_SERVER_Client *client;
61 enum GNUNET_GNS_RecordType type;
70 * Handle to a get auhtority operation from api
72 struct ClientGetAuthHandle
74 /* the requesting client that */
75 struct GNUNET_SERVER_Client *client;
80 /* name to lookup authority */
87 * Handle to a lookup operation from api
89 struct ClientLookupHandle
91 /* the requesting client that */
92 struct GNUNET_SERVER_Client *client;
98 enum GNUNET_GNS_RecordType type;
100 /* the name to look up */
101 char* name; //Needed?
105 * Our handle to the DHT
107 static struct GNUNET_DHT_Handle *dht_handle;
110 * Our zone's private key
112 struct GNUNET_CRYPTO_RsaPrivateKey *zone_key;
115 * Our handle to the namestore service
116 * FIXME maybe need a second handle for iteration
118 struct GNUNET_NAMESTORE_Handle *namestore_handle;
121 * Handle to iterate over our authoritative zone in namestore
123 struct GNUNET_NAMESTORE_ZoneIterator *namestore_iter;
126 * The configuration the GNS service is running with
128 const struct GNUNET_CONFIGURATION_Handle *GNS_cfg;
131 * Our notification context.
133 static struct GNUNET_SERVER_NotificationContext *nc;
138 struct GNUNET_CRYPTO_ShortHashCode zone_hash;
141 * Useful for zone update for DHT put
143 static int num_public_records = 3600;
145 /* dht update interval FIXME define? */
146 static struct GNUNET_TIME_Relative dht_update_interval;
148 /* zone update task */
149 GNUNET_SCHEDULER_TaskIdentifier zone_update_taskid = GNUNET_SCHEDULER_NO_TASK;
151 /* automatic pkey import for name shortening */
152 static int auto_import_pkey;
155 static struct GNUNET_TIME_Relative default_lookup_timeout;
158 * Task run during shutdown.
164 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
167 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
169 /* Kill zone task for it may make the scheduler hang */
170 if (zone_update_taskid)
171 GNUNET_SCHEDULER_cancel(zone_update_taskid);
173 GNUNET_SERVER_notification_context_destroy (nc);
175 gns_interceptor_stop();
176 gns_resolver_cleanup();
178 GNUNET_NAMESTORE_disconnect(namestore_handle, 1);
179 GNUNET_DHT_disconnect(dht_handle);
184 * Method called periodicattluy that triggers
185 * iteration over root zone
188 * @param tc task context
191 update_zone_dht_next(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
193 GNUNET_NAMESTORE_zone_iterator_next(namestore_iter);
197 * Continuation for DHT put
200 * @param tc task context
203 record_dht_put(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
205 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "put request transmitted\n");
210 update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
213 * Function used to put all records successively into the DHT.
215 * @param cls the closure (NULL)
216 * @param key the public key of the authority (ours)
217 * @param expiration lifetime of the namestore entry
218 * @param name the name of the records
219 * @param rd_count the number of records in data
220 * @param rd the record data
221 * @param signature the signature for the record data
224 put_gns_record(void *cls,
225 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key,
226 struct GNUNET_TIME_Absolute expiration,
228 unsigned int rd_count,
229 const struct GNUNET_NAMESTORE_RecordData *rd,
230 const struct GNUNET_CRYPTO_RsaSignature *signature)
233 struct GNSNameRecordBlock *nrb;
234 struct GNUNET_CRYPTO_ShortHashCode name_hash;
235 GNUNET_HashCode xor_hash;
236 GNUNET_HashCode name_hash_double;
237 GNUNET_HashCode zone_hash_double;
238 struct GNUNET_CRYPTO_HashAsciiEncoded xor_hash_string;
239 uint32_t rd_payload_length;
240 char* nrb_data = NULL;
246 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
247 "Zone iteration finished. Rescheduling put in %ds\n",
248 GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL);
249 zone_update_taskid = GNUNET_SCHEDULER_add_delayed (
250 GNUNET_TIME_relative_multiply(
251 GNUNET_TIME_UNIT_SECONDS,
252 GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL
254 &update_zone_dht_start,
259 namelen = strlen(name) + 1;
261 if (signature == NULL)
263 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
264 "No signature for %s record data provided! Skipping...\n",
266 zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_next,
272 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
273 "Putting records for %s into the DHT\n", name);
275 rd_payload_length = GNUNET_NAMESTORE_records_get_size (rd_count, rd);
277 nrb = GNUNET_malloc(rd_payload_length + namelen
278 + sizeof(struct GNSNameRecordBlock));
280 nrb->signature = *signature;
282 nrb->public_key = *key;
284 nrb->rd_count = htonl(rd_count);
286 memcpy(&nrb[1], name, namelen);
288 nrb_data = (char*)&nrb[1];
291 rd_payload_length += sizeof(struct GNSNameRecordBlock) + namelen;
293 if (-1 == GNUNET_NAMESTORE_records_serialize (rd_count,
298 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
299 "Record serialization failed! Skipping...\n");
301 zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_next,
308 * calculate DHT key: H(name) xor H(pubkey)
310 GNUNET_CRYPTO_short_hash(name, strlen(name), &name_hash);
311 GNUNET_CRYPTO_short_hash_double (&name_hash, &name_hash_double);
312 GNUNET_CRYPTO_short_hash_double (&zone_hash, &zone_hash_double);
313 GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash);
314 GNUNET_CRYPTO_hash_to_enc (&xor_hash, &xor_hash_string);
316 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
317 "putting records for %s under key: %s with size %d\n",
318 name, (char*)&xor_hash_string, rd_payload_length);
320 GNUNET_DHT_put (dht_handle, &xor_hash,
321 DHT_GNS_REPLICATION_LEVEL,
323 GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
327 DHT_OPERATION_TIMEOUT,
329 NULL); //cls for cont
331 num_public_records++;
334 * Reschedule periodic put
336 zone_update_taskid = GNUNET_SCHEDULER_add_delayed (dht_update_interval,
337 &update_zone_dht_next,
345 * Periodically iterate over our zone and store everything in dht
348 * @param tc task context
351 update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
353 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Scheduling DHT zone update!\n");
354 if (0 == num_public_records)
356 dht_update_interval = GNUNET_TIME_relative_multiply(
357 GNUNET_TIME_UNIT_SECONDS,
358 GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL);
359 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
360 "No records in db. Adjusted DHT update interval to %ds\n",
361 GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL);
366 dht_update_interval = GNUNET_TIME_relative_multiply(
367 GNUNET_TIME_UNIT_SECONDS,
368 (3600/num_public_records));
369 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
370 "Adjusted DHT update interval to %ds!\n",
371 (3600/num_public_records));
374 /* start counting again */
375 num_public_records = 0;
376 namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle,
378 GNUNET_NAMESTORE_RF_AUTHORITY,
379 GNUNET_NAMESTORE_RF_PRIVATE,
385 /* END DHT ZONE PROPAGATION */
388 * Send shorten response back to client
390 * @param name the shortened name result or NULL if cannot be shortened
391 * @param csh the handle to the shorten request
394 send_shorten_response(void* cls, const char* name)
396 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message with %s\n",
397 "SHORTEN_RESULT", name);
398 struct GNUNET_GNS_ClientShortenResultMessage *rmsg;
399 struct ClientShortenHandle *csh = (struct ClientShortenHandle *)cls;
406 rmsg = GNUNET_malloc(sizeof(struct GNUNET_GNS_ClientShortenResultMessage)
409 rmsg->id = csh->unique_id;
410 rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT);
412 htons(sizeof(struct GNUNET_GNS_ClientShortenResultMessage) +
415 strcpy((char*)&rmsg[1], name);
417 GNUNET_SERVER_notification_context_unicast (nc, csh->client,
418 (const struct GNUNET_MessageHeader *) rmsg,
420 GNUNET_SERVER_receive_done (csh->client, GNUNET_OK);
423 GNUNET_free_non_null(csh->name);
429 * Handle a shorten message from the api
431 * @param cls the closure
432 * @param client the client
433 * @param message the message
435 static void handle_shorten(void *cls,
436 struct GNUNET_SERVER_Client * client,
437 const struct GNUNET_MessageHeader * message)
439 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "SHORTEN");
442 struct ClientShortenHandle *csh;
445 if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientShortenMessage))
448 GNUNET_SERVER_receive_done (client, GNUNET_OK);
452 GNUNET_SERVER_notification_context_add (nc, client);
454 struct GNUNET_GNS_ClientShortenMessage *sh_msg =
455 (struct GNUNET_GNS_ClientShortenMessage *) message;
457 msg_size = ntohs(message->size);
459 if (msg_size > GNUNET_SERVER_MAX_MESSAGE_SIZE)
462 GNUNET_SERVER_receive_done (client, GNUNET_OK);
466 csh = GNUNET_malloc(sizeof(struct ClientShortenHandle));
467 csh->client = client;
468 csh->unique_id = sh_msg->id;
470 name = (char*)&sh_msg[1];
472 if (strlen (name) < strlen(GNUNET_GNS_TLD)) {
474 send_shorten_response(csh, name);
478 if (strcmp(name+strlen(name)-strlen(GNUNET_GNS_TLD),
479 GNUNET_GNS_TLD) != 0)
481 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
482 "%s is not our domain. Returning\n", name);
484 send_shorten_response(csh, name);
488 csh->name = GNUNET_malloc(strlen(name)
489 - strlen(GNUNET_GNS_TLD) + 1);
491 strlen(name)-strlen(GNUNET_GNS_TLD) + 1);
492 memcpy(csh->name, name,
493 strlen(name)-strlen(GNUNET_GNS_TLD));
495 /* Start shortening */
496 gns_resolver_shorten_name(zone_hash, name, &send_shorten_response, csh);
501 * Send get authority response back to client
503 * @param name the shortened name result or NULL if cannot be shortened
504 * @param cah the handle to the get authority request
507 send_get_auth_response(void *cls, const char* name)
509 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message with %s\n",
510 "GET_AUTH_RESULT", name);
511 struct GNUNET_GNS_ClientGetAuthResultMessage *rmsg;
512 struct ClientGetAuthHandle *cah = (struct ClientGetAuthHandle *)cls;
519 rmsg = GNUNET_malloc(sizeof(struct GNUNET_GNS_ClientGetAuthResultMessage)
522 rmsg->id = cah->unique_id;
523 rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_GET_AUTH_RESULT);
525 htons(sizeof(struct GNUNET_GNS_ClientGetAuthResultMessage) +
528 strcpy((char*)&rmsg[1], name);
530 GNUNET_SERVER_notification_context_unicast (nc, cah->client,
531 (const struct GNUNET_MessageHeader *) rmsg,
533 GNUNET_SERVER_receive_done (cah->client, GNUNET_OK);
535 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up handles...\n");
538 GNUNET_free_non_null(cah->name);
541 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "done.\n");
547 * Handle a get authority message from the api
549 * @param cls the closure
550 * @param client the client
551 * @param message the message
553 static void handle_get_authority(void *cls,
554 struct GNUNET_SERVER_Client * client,
555 const struct GNUNET_MessageHeader * message)
557 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "GET_AUTH");
560 struct ClientGetAuthHandle *cah;
563 if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientGetAuthMessage))
566 GNUNET_SERVER_receive_done (client, GNUNET_OK);
570 GNUNET_SERVER_notification_context_add (nc, client);
572 struct GNUNET_GNS_ClientGetAuthMessage *sh_msg =
573 (struct GNUNET_GNS_ClientGetAuthMessage *) message;
575 msg_size = ntohs(message->size);
577 if (msg_size > GNUNET_SERVER_MAX_MESSAGE_SIZE)
580 GNUNET_SERVER_receive_done (client, GNUNET_OK);
584 name = (char*)&sh_msg[1];
586 cah = GNUNET_malloc(sizeof(struct ClientGetAuthHandle));
587 cah->client = client;
588 cah->unique_id = sh_msg->id;
590 if (strlen(name) < strlen(GNUNET_GNS_TLD))
592 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
593 "%s is too short. Returning\n", name);
595 send_get_auth_response(cah, name);
599 if (strcmp(name+strlen(name)-strlen(GNUNET_GNS_TLD),
600 GNUNET_GNS_TLD) != 0)
602 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
603 "%s is not our domain. Returning\n", name);
605 send_get_auth_response(cah, name);
609 if (strcmp(name, GNUNET_GNS_TLD) == 0)
611 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
612 "%s is us. Returning\n", name);
614 send_get_auth_response(cah, name);
618 cah->name = GNUNET_malloc(strlen(name)
619 - strlen(GNUNET_GNS_TLD) + 1);
621 strlen(name)-strlen(GNUNET_GNS_TLD) + 1);
622 memcpy(cah->name, name,
623 strlen(name)-strlen(GNUNET_GNS_TLD));
625 /* Start delegation resolution in our namestore */
626 gns_resolver_get_authority(zone_hash, name, &send_get_auth_response, cah);
631 * Reply to client with the result from our lookup.
633 * @param cls the closure (our client lookup handle)
634 * @param rh the request handle of the lookup
635 * @param rd_count the number of records
636 * @param rd the record data
639 send_lookup_response(void* cls,
641 const struct GNUNET_NAMESTORE_RecordData *rd)
643 struct ClientLookupHandle* clh = (struct ClientLookupHandle*)cls;
644 struct GNUNET_GNS_ClientLookupResultMessage *rmsg;
647 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message with %d results\n",
648 "LOOKUP_RESULT", rd_count);
650 len = GNUNET_NAMESTORE_records_get_size (rd_count, rd);
651 rmsg = GNUNET_malloc(len+sizeof(struct GNUNET_GNS_ClientLookupResultMessage));
653 rmsg->id = clh->unique_id;
654 rmsg->rd_count = htonl(rd_count);
655 rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT);
657 htons(len+sizeof(struct GNUNET_GNS_ClientLookupResultMessage));
659 GNUNET_NAMESTORE_records_serialize (rd_count, rd, len, (char*)&rmsg[1]);
661 GNUNET_SERVER_notification_context_unicast (nc, clh->client,
662 (const struct GNUNET_MessageHeader *) rmsg,
664 GNUNET_SERVER_receive_done (clh->client, GNUNET_OK);
667 GNUNET_free(clh->name);
674 * Handle lookup requests from client
676 * @param cls the closure
677 * @param client the client
678 * @param message the message
681 handle_lookup(void *cls,
682 struct GNUNET_SERVER_Client * client,
683 const struct GNUNET_MessageHeader * message)
685 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "LOOKUP");
690 struct ClientLookupHandle *clh;
692 if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientLookupMessage))
695 GNUNET_SERVER_receive_done (client, GNUNET_OK);
699 GNUNET_SERVER_notification_context_add (nc, client);
701 struct GNUNET_GNS_ClientLookupMessage *sh_msg =
702 (struct GNUNET_GNS_ClientLookupMessage *) message;
704 msg_size = ntohs(message->size);
706 if (msg_size > GNUNET_SERVER_MAX_MESSAGE_SIZE)
709 GNUNET_SERVER_receive_done (client, GNUNET_OK);
713 name = (char*)&sh_msg[1];
714 namelen = strlen(name)+1;
715 clh = GNUNET_malloc(sizeof(struct ClientLookupHandle));
716 clh->client = client;
717 clh->name = GNUNET_malloc(namelen);
718 strcpy(clh->name, name);
719 clh->unique_id = sh_msg->id;
720 clh->type = ntohl(sh_msg->type);
722 if (GNUNET_YES == auto_import_pkey)
724 gns_resolver_lookup_record(zone_hash, clh->type, name,
726 default_lookup_timeout,
727 &send_lookup_response, clh);
731 gns_resolver_lookup_record(zone_hash, clh->type, name,
733 default_lookup_timeout,
734 &send_lookup_response, clh);
741 * Process GNS requests.
743 * @param cls closure)
744 * @param server the initialized server
745 * @param c configuration to use
748 run (void *cls, struct GNUNET_SERVER_Handle *server,
749 const struct GNUNET_CONFIGURATION_Handle *c)
752 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Initializing GNS\n");
755 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
756 unsigned long long max_parallel_bg_queries = 0;
757 unsigned long long default_lookup_timeout_secs = 0;
759 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
760 {&handle_shorten, NULL, GNUNET_MESSAGE_TYPE_GNS_SHORTEN, 0},
761 {&handle_lookup, NULL, GNUNET_MESSAGE_TYPE_GNS_LOOKUP, 0},
762 {&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0}
765 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "gns",
766 "ZONEKEY", &keyfile))
768 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
769 "No private key for root zone specified!\n");
770 GNUNET_SCHEDULER_shutdown(0);
774 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
775 "Using keyfile %s for root zone.\n", keyfile);
777 zone_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
778 GNUNET_CRYPTO_rsa_key_get_public (zone_key, &pkey);
780 GNUNET_CRYPTO_short_hash(&pkey,
781 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
783 GNUNET_free(keyfile);
786 * handle to our local namestore
788 namestore_handle = GNUNET_NAMESTORE_connect(c);
790 if (NULL == namestore_handle)
792 //FIXME do error handling;
793 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
794 "Failed to connect to the namestore!\n");
795 GNUNET_SCHEDULER_shutdown(0);
802 dht_handle = GNUNET_DHT_connect(c, 1); //FIXME get ht_len from cfg
804 if (NULL == dht_handle)
806 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not connect to DHT!\n");
810 GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
813 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
814 "Automatic PKEY import is enabled.\n");
815 auto_import_pkey = GNUNET_YES;
820 GNUNET_CONFIGURATION_get_value_number(c, "gns",
821 "MAX_PARALLEL_BACKGROUND_QUERIES",
822 &max_parallel_bg_queries))
824 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
825 "Number of allowed parallel background queries: %d\n",
826 max_parallel_bg_queries);
830 GNUNET_CONFIGURATION_get_value_number(c, "gns",
831 "DEFAULT_LOOKUP_TIMEOUT",
832 &default_lookup_timeout_secs))
834 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
835 "Default lookup timeout: %ds\n", default_lookup_timeout_secs);
836 default_lookup_timeout = GNUNET_TIME_relative_multiply(
837 GNUNET_TIME_UNIT_SECONDS,
838 default_lookup_timeout_secs);
841 if (gns_resolver_init(namestore_handle, dht_handle, zone_hash,
842 max_parallel_bg_queries)
845 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
846 "Unable to initialize resolver!\n");
847 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
852 GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
855 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
856 "DNS hijacking enabled... connecting to service.\n");
858 if (gns_interceptor_init(zone_hash, zone_key, c) == GNUNET_SYSERR)
860 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
861 "Failed to enable the dns interceptor!\n");
865 //put_some_records(); //FIXME for testing
868 * Schedule periodic put
870 * We have roughly an hour for all records;
872 dht_update_interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,
874 zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_start, NULL);
876 GNUNET_SERVER_add_handlers (server, handlers);
879 //GNUNET_SERVER_disconnect_notify (server,
880 // &client_disconnect_notification,
883 nc = GNUNET_SERVER_notification_context_create (server, 1);
885 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
891 * The main function for the GNS service.
893 * @param argc number of arguments from the command line
894 * @param argv command line arguments
895 * @return 0 ok, 1 on error
898 main (int argc, char *const *argv)
904 GNUNET_SERVICE_run (argc, argv, "gns", GNUNET_SERVICE_OPTION_NONE, &run,
909 /* end of gnunet-service-gns.c */