diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-10-26 22:13:01 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-10-26 22:13:01 +0000 |
commit | 64d3e46cfb99a711e500fa1f114e7c44bdf10040 (patch) | |
tree | 83093d92761d5c1b8b2fded713adaa19af29274c /src/gns/gnunet-service-gns.c | |
parent | ef6f05f63769263a5201636c4b7f71eaa455cdf3 (diff) | |
download | gnunet-64d3e46cfb99a711e500fa1f114e7c44bdf10040.tar.gz gnunet-64d3e46cfb99a711e500fa1f114e7c44bdf10040.zip |
-bugfixes, code cleanup
Diffstat (limited to 'src/gns/gnunet-service-gns.c')
-rw-r--r-- | src/gns/gnunet-service-gns.c | 387 |
1 files changed, 167 insertions, 220 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 88e1f9d58..dc22efdab 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -72,6 +72,7 @@ struct ClientShortenHandle | |||
72 | * List for all shorten requests | 72 | * List for all shorten requests |
73 | */ | 73 | */ |
74 | struct ClientShortenHandle *next; | 74 | struct ClientShortenHandle *next; |
75 | |||
75 | /** | 76 | /** |
76 | * List for all shorten requests | 77 | * List for all shorten requests |
77 | */ | 78 | */ |
@@ -83,9 +84,29 @@ struct ClientShortenHandle | |||
83 | struct GNUNET_SERVER_Client *client; | 84 | struct GNUNET_SERVER_Client *client; |
84 | 85 | ||
85 | /** | 86 | /** |
87 | * Namestore lookup task | ||
88 | */ | ||
89 | struct GNUNET_NAMESTORE_QueueEntry *namestore_task; | ||
90 | |||
91 | /** | ||
92 | * master zone | ||
93 | */ | ||
94 | struct GNUNET_CRYPTO_ShortHashCode root_zone; | ||
95 | |||
96 | /** | ||
97 | * private zone | ||
98 | */ | ||
99 | struct GNUNET_CRYPTO_ShortHashCode private_zone; | ||
100 | |||
101 | /** | ||
102 | * shorten zone | ||
103 | */ | ||
104 | struct GNUNET_CRYPTO_ShortHashCode shorten_zone; | ||
105 | |||
106 | /** | ||
86 | * The request id | 107 | * The request id |
87 | */ | 108 | */ |
88 | uint64_t request_id; | 109 | uint32_t request_id; |
89 | 110 | ||
90 | /** | 111 | /** |
91 | * request type | 112 | * request type |
@@ -106,26 +127,7 @@ struct ClientShortenHandle | |||
106 | * name of shorten zone (relative to root) | 127 | * name of shorten zone (relative to root) |
107 | */ | 128 | */ |
108 | char shorten_zone_id[MAX_DNS_NAME_LENGTH]; | 129 | char shorten_zone_id[MAX_DNS_NAME_LENGTH]; |
109 | |||
110 | /** | ||
111 | * master zone | ||
112 | */ | ||
113 | struct GNUNET_CRYPTO_ShortHashCode root_zone; | ||
114 | |||
115 | /** | ||
116 | * private zone | ||
117 | */ | ||
118 | struct GNUNET_CRYPTO_ShortHashCode private_zone; | ||
119 | |||
120 | /** | ||
121 | * shorten zone | ||
122 | */ | ||
123 | struct GNUNET_CRYPTO_ShortHashCode shorten_zone; | ||
124 | 130 | ||
125 | /** | ||
126 | * Namestore lookup task | ||
127 | */ | ||
128 | struct GNUNET_NAMESTORE_QueueEntry *namestore_task; | ||
129 | }; | 131 | }; |
130 | 132 | ||
131 | 133 | ||
@@ -135,18 +137,20 @@ struct ClientShortenHandle | |||
135 | struct ClientGetAuthHandle | 137 | struct ClientGetAuthHandle |
136 | { | 138 | { |
137 | /** | 139 | /** |
138 | * Handle to the requesting client */ | 140 | * Handle to the requesting client |
141 | */ | ||
139 | struct GNUNET_SERVER_Client *client; | 142 | struct GNUNET_SERVER_Client *client; |
140 | 143 | ||
141 | /** | 144 | /** |
142 | * request id | 145 | * name to lookup authority |
143 | */ | 146 | */ |
144 | uint64_t request_id; | 147 | char *name; |
145 | 148 | ||
146 | /** | 149 | /** |
147 | * name to lookup authority | 150 | * request id |
148 | */ | 151 | */ |
149 | char *name; | 152 | uint32_t request_id; |
153 | |||
150 | }; | 154 | }; |
151 | 155 | ||
152 | 156 | ||
@@ -162,34 +166,34 @@ struct ClientLookupHandle | |||
162 | struct GNUNET_SERVER_Client *client; | 166 | struct GNUNET_SERVER_Client *client; |
163 | 167 | ||
164 | /** | 168 | /** |
165 | * The zone we look up in | 169 | * optional zone private key used for shorten |
166 | */ | 170 | */ |
167 | struct GNUNET_CRYPTO_ShortHashCode zone; | 171 | struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key; |
168 | 172 | ||
169 | /** | 173 | /** |
170 | * GNUNET_YES if we only want to lookup from local cache | 174 | * the name to look up |
171 | */ | 175 | */ |
172 | int only_cached; | 176 | char *name; |
173 | 177 | ||
174 | /** | 178 | /** |
175 | * request id | 179 | * The zone we look up in |
176 | */ | 180 | */ |
177 | uint64_t request_id; | 181 | struct GNUNET_CRYPTO_ShortHashCode zone; |
178 | 182 | ||
179 | /** | 183 | /** |
180 | * request type | 184 | * request id |
181 | */ | 185 | */ |
182 | enum GNUNET_GNS_RecordType type; | 186 | uint32_t request_id; |
183 | 187 | ||
184 | /** | 188 | /** |
185 | * optional zone private key used for shorten | 189 | * GNUNET_YES if we only want to lookup from local cache |
186 | */ | 190 | */ |
187 | struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key; | 191 | int only_cached; |
188 | 192 | ||
189 | /** | 193 | /** |
190 | * the name to look up | 194 | * request type |
191 | */ | 195 | */ |
192 | char *name; | 196 | enum GNUNET_GNS_RecordType type; |
193 | }; | 197 | }; |
194 | 198 | ||
195 | 199 | ||
@@ -306,19 +310,36 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
306 | while (NULL != (csh_tmp = csh_head)) | 310 | while (NULL != (csh_tmp = csh_head)) |
307 | { | 311 | { |
308 | GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh_tmp); | 312 | GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh_tmp); |
309 | GNUNET_free(csh_tmp); | 313 | GNUNET_free (csh_tmp); |
310 | } | 314 | } |
311 | GNUNET_SERVER_notification_context_destroy (nc); | 315 | GNUNET_SERVER_notification_context_destroy (nc); |
312 | gns_interceptor_stop (); | 316 | gns_interceptor_stop (); |
313 | gns_resolver_cleanup (); | 317 | gns_resolver_cleanup (); |
314 | if (NULL != statistics) | 318 | if (NULL != statistics) |
319 | { | ||
315 | GNUNET_STATISTICS_destroy (statistics, GNUNET_NO); | 320 | GNUNET_STATISTICS_destroy (statistics, GNUNET_NO); |
316 | if (zone_publish_task != GNUNET_SCHEDULER_NO_TASK) | 321 | statistics = NULL; |
322 | } | ||
323 | if (GNUNET_SCHEDULER_NO_TASK != zone_publish_task) | ||
324 | { | ||
317 | GNUNET_SCHEDULER_cancel (zone_publish_task); | 325 | GNUNET_SCHEDULER_cancel (zone_publish_task); |
326 | zone_publish_task = GNUNET_SCHEDULER_NO_TASK; | ||
327 | } | ||
318 | if (NULL != namestore_iter) | 328 | if (NULL != namestore_iter) |
329 | { | ||
319 | GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter); | 330 | GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter); |
320 | GNUNET_NAMESTORE_disconnect(namestore_handle); | 331 | namestore_iter = NULL; |
321 | GNUNET_DHT_disconnect(dht_handle); | 332 | } |
333 | if (NULL != namestore_handle) | ||
334 | { | ||
335 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
336 | namestore_handle = NULL; | ||
337 | } | ||
338 | if (NULL != dht_handle) | ||
339 | { | ||
340 | GNUNET_DHT_disconnect (dht_handle); | ||
341 | dht_handle = NULL; | ||
342 | } | ||
322 | } | 343 | } |
323 | 344 | ||
324 | 345 | ||
@@ -345,7 +366,7 @@ publish_zone_dht_next (void *cls, | |||
345 | */ | 366 | */ |
346 | static void | 367 | static void |
347 | publish_zone_dht_start (void *cls, | 368 | publish_zone_dht_start (void *cls, |
348 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 369 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
349 | 370 | ||
350 | 371 | ||
351 | /** | 372 | /** |
@@ -360,7 +381,7 @@ publish_zone_dht_start (void *cls, | |||
360 | * @param signature the signature for the record data | 381 | * @param signature the signature for the record data |
361 | */ | 382 | */ |
362 | static void | 383 | static void |
363 | put_gns_record(void *cls, | 384 | put_gns_record (void *cls, |
364 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, | 385 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, |
365 | struct GNUNET_TIME_Absolute expiration, | 386 | struct GNUNET_TIME_Absolute expiration, |
366 | const char *name, | 387 | const char *name, |
@@ -389,19 +410,17 @@ put_gns_record(void *cls, | |||
389 | * we can safely set the interval to the value for a single | 410 | * we can safely set the interval to the value for a single |
390 | * record | 411 | * record |
391 | */ | 412 | */ |
392 | put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window, | 413 | put_interval = zone_publish_time_window; |
393 | 1); | ||
394 | |||
395 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
396 | "No records in db.\n"); | 415 | "No records in db.\n"); |
397 | } | 416 | } |
398 | else | 417 | else |
399 | { | 418 | { |
400 | put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window, | 419 | put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window, |
401 | num_public_records); | 420 | num_public_records); |
402 | } | 421 | } |
403 | put_interval = GNUNET_TIME_relative_max (MINIMUM_ZONE_ITERATION_INTERVAL, | 422 | put_interval = GNUNET_TIME_relative_max (MINIMUM_ZONE_ITERATION_INTERVAL, |
404 | put_interval); | 423 | put_interval); |
405 | 424 | ||
406 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 425 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
407 | "Zone iteration finished. Adjusted zone iteration interval to %s\n", | 426 | "Zone iteration finished. Adjusted zone iteration interval to %s\n", |
@@ -484,7 +503,8 @@ put_gns_record(void *cls, | |||
484 | GNUNET_STRINGS_relative_time_to_string (DHT_OPERATION_TIMEOUT, GNUNET_YES)); | 503 | GNUNET_STRINGS_relative_time_to_string (DHT_OPERATION_TIMEOUT, GNUNET_YES)); |
485 | 504 | ||
486 | GNUNET_STATISTICS_update (statistics, | 505 | GNUNET_STATISTICS_update (statistics, |
487 | "Record bytes put into DHT", rd_payload_length, GNUNET_NO); | 506 | "Record bytes put into DHT", |
507 | rd_payload_length, GNUNET_NO); | ||
488 | 508 | ||
489 | (void) GNUNET_DHT_put (dht_handle, &dht_key, | 509 | (void) GNUNET_DHT_put (dht_handle, &dht_key, |
490 | DHT_GNS_REPLICATION_LEVEL, | 510 | DHT_GNS_REPLICATION_LEVEL, |
@@ -505,7 +525,7 @@ put_gns_record(void *cls, | |||
505 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 525 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
506 | "Last record count was lower than current record count. Reducing interval.\n"); | 526 | "Last record count was lower than current record count. Reducing interval.\n"); |
507 | put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window, | 527 | put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window, |
508 | num_public_records); | 528 | num_public_records); |
509 | next_put_interval = GNUNET_TIME_relative_divide (put_interval, | 529 | next_put_interval = GNUNET_TIME_relative_divide (put_interval, |
510 | LATE_ITERATION_SPEEDUP_FACTOR); | 530 | LATE_ITERATION_SPEEDUP_FACTOR); |
511 | } | 531 | } |
@@ -517,8 +537,8 @@ put_gns_record(void *cls, | |||
517 | next_put_interval.rel_value, | 537 | next_put_interval.rel_value, |
518 | GNUNET_NO); | 538 | GNUNET_NO); |
519 | zone_publish_task = GNUNET_SCHEDULER_add_delayed (next_put_interval, | 539 | zone_publish_task = GNUNET_SCHEDULER_add_delayed (next_put_interval, |
520 | &publish_zone_dht_next, | 540 | &publish_zone_dht_next, |
521 | NULL); | 541 | NULL); |
522 | } | 542 | } |
523 | 543 | ||
524 | 544 | ||
@@ -529,11 +549,13 @@ put_gns_record(void *cls, | |||
529 | * @param tc task context | 549 | * @param tc task context |
530 | */ | 550 | */ |
531 | static void | 551 | static void |
532 | publish_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 552 | publish_zone_dht_start (void *cls, |
553 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
533 | { | 554 | { |
534 | zone_publish_task = GNUNET_SCHEDULER_NO_TASK; | 555 | zone_publish_task = GNUNET_SCHEDULER_NO_TASK; |
535 | 556 | ||
536 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Scheduling DHT zone update!\n"); | 557 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
558 | "Scheduling DHT zone update!\n"); | ||
537 | /* start counting again */ | 559 | /* start counting again */ |
538 | num_public_records = 0; | 560 | num_public_records = 0; |
539 | namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle, | 561 | namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle, |
@@ -561,7 +583,8 @@ send_shorten_response (void* cls, const char* name) | |||
561 | struct GNUNET_GNS_ClientShortenResultMessage *rmsg; | 583 | struct GNUNET_GNS_ClientShortenResultMessage *rmsg; |
562 | size_t name_len; | 584 | size_t name_len; |
563 | 585 | ||
564 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message with %s\n", | 586 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
587 | "Sending `%s' message with %s\n", | ||
565 | "SHORTEN_RESULT", name); | 588 | "SHORTEN_RESULT", name); |
566 | if (NULL == name) | 589 | if (NULL == name) |
567 | name_len = 0; | 590 | name_len = 0; |
@@ -616,9 +639,8 @@ process_shorten_in_private_zone_lookup (void *cls, | |||
616 | 639 | ||
617 | csh->namestore_task = NULL; | 640 | csh->namestore_task = NULL; |
618 | if (0 == strcmp (csh->private_zone_id, "")) | 641 | if (0 == strcmp (csh->private_zone_id, "")) |
619 | pzone = NULL; | 642 | pzone = NULL; |
620 | 643 | if (0 == rd_count) | |
621 | if (rd_count == 0) | ||
622 | { | 644 | { |
623 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 645 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
624 | "No shorten zone in private zone!\n"); | 646 | "No shorten zone in private zone!\n"); |
@@ -627,17 +649,14 @@ process_shorten_in_private_zone_lookup (void *cls, | |||
627 | } | 649 | } |
628 | else | 650 | else |
629 | { | 651 | { |
630 | GNUNET_assert (rd_count == 1); | 652 | GNUNET_break (1 == rd_count); |
631 | |||
632 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 653 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
633 | "Shorten zone %s found in private zone %s\n", | 654 | "Shorten zone %s found in private zone %s\n", |
634 | name, csh->private_zone_id); | 655 | name, csh->private_zone_id); |
635 | 656 | ||
636 | sprintf (csh->shorten_zone_id, "%s.%s", name, csh->private_zone_id); | 657 | sprintf (csh->shorten_zone_id, "%s.%s", name, csh->private_zone_id); |
637 | } | 658 | } |
638 | |||
639 | GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh); | 659 | GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh); |
640 | |||
641 | gns_resolver_shorten_name (&csh->root_zone, | 660 | gns_resolver_shorten_name (&csh->root_zone, |
642 | pzone, | 661 | pzone, |
643 | szone, | 662 | szone, |
@@ -663,12 +682,12 @@ process_shorten_in_private_zone_lookup (void *cls, | |||
663 | */ | 682 | */ |
664 | static void | 683 | static void |
665 | process_shorten_in_root_zone_lookup (void *cls, | 684 | process_shorten_in_root_zone_lookup (void *cls, |
666 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, | 685 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, |
667 | struct GNUNET_TIME_Absolute expiration, | 686 | struct GNUNET_TIME_Absolute expiration, |
668 | const char *name, | 687 | const char *name, |
669 | unsigned int rd_count, | 688 | unsigned int rd_count, |
670 | const struct GNUNET_NAMESTORE_RecordData *rd, | 689 | const struct GNUNET_NAMESTORE_RecordData *rd, |
671 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 690 | const struct GNUNET_CRYPTO_RsaSignature *signature) |
672 | { | 691 | { |
673 | struct ClientShortenHandle *csh = cls; | 692 | struct ClientShortenHandle *csh = cls; |
674 | struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone; | 693 | struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone; |
@@ -677,17 +696,14 @@ process_shorten_in_root_zone_lookup (void *cls, | |||
677 | csh->namestore_task = NULL; | 696 | csh->namestore_task = NULL; |
678 | if (0 == strcmp (csh->private_zone_id, "")) | 697 | if (0 == strcmp (csh->private_zone_id, "")) |
679 | pzone = NULL; | 698 | pzone = NULL; |
680 | 699 | if (0 == rd_count) | |
681 | if (rd_count == 0) | ||
682 | { | 700 | { |
683 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 701 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
684 | "No shorten zone in zone and no private zone!\n"); | 702 | "No shorten zone in zone and no private zone!\n"); |
685 | 703 | ||
686 | strcpy (csh->shorten_zone_id, ""); | 704 | strcpy (csh->shorten_zone_id, ""); |
687 | |||
688 | GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh); | 705 | GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh); |
689 | szone = NULL; | 706 | szone = NULL; |
690 | |||
691 | gns_resolver_shorten_name (&csh->root_zone, | 707 | gns_resolver_shorten_name (&csh->root_zone, |
692 | pzone, | 708 | pzone, |
693 | szone, | 709 | szone, |
@@ -697,19 +713,15 @@ process_shorten_in_root_zone_lookup (void *cls, | |||
697 | &send_shorten_response, csh); | 713 | &send_shorten_response, csh); |
698 | return; | 714 | return; |
699 | } | 715 | } |
700 | 716 | GNUNET_break (rd_count == 1); | |
701 | GNUNET_assert (rd_count == 1); | ||
702 | |||
703 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 717 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
704 | "Private zone %s found in root zone\n", name); | 718 | "Private zone %s found in root zone\n", name); |
705 | |||
706 | strcpy (csh->private_zone_id, name); | 719 | strcpy (csh->private_zone_id, name); |
707 | |||
708 | csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, | 720 | csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, |
709 | pzone, | 721 | pzone, |
710 | szone, | 722 | szone, |
711 | &process_shorten_in_private_zone_lookup, | 723 | &process_shorten_in_private_zone_lookup, |
712 | csh); | 724 | csh); |
713 | } | 725 | } |
714 | 726 | ||
715 | 727 | ||
@@ -723,7 +735,6 @@ process_shorten_in_root_zone_lookup (void *cls, | |||
723 | * @param rd_count number of records found | 735 | * @param rd_count number of records found |
724 | * @param rd record data | 736 | * @param rd record data |
725 | * @param signature | 737 | * @param signature |
726 | * | ||
727 | */ | 738 | */ |
728 | static void | 739 | static void |
729 | process_private_in_root_zone_lookup (void *cls, | 740 | process_private_in_root_zone_lookup (void *cls, |
@@ -763,25 +774,6 @@ process_private_in_root_zone_lookup (void *cls, | |||
763 | 774 | ||
764 | 775 | ||
765 | /** | 776 | /** |
766 | * Lookup the zone infos and shorten name | ||
767 | * | ||
768 | * @param csh the shorten handle | ||
769 | * | ||
770 | */ | ||
771 | static void | ||
772 | start_shorten_name (struct ClientShortenHandle *csh) | ||
773 | { | ||
774 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
775 | "Looking for private zone name in root zone\n"); | ||
776 | csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, | ||
777 | &csh->root_zone, | ||
778 | &csh->private_zone, | ||
779 | &process_private_in_root_zone_lookup, | ||
780 | csh); | ||
781 | } | ||
782 | |||
783 | |||
784 | /** | ||
785 | * Handle a shorten message from the api | 777 | * Handle a shorten message from the api |
786 | * | 778 | * |
787 | * @param cls the closure (unused) | 779 | * @param cls the closure (unused) |
@@ -800,7 +792,8 @@ handle_shorten (void *cls, | |||
800 | uint16_t msg_size; | 792 | uint16_t msg_size; |
801 | const struct GNUNET_GNS_ClientShortenMessage *sh_msg; | 793 | const struct GNUNET_GNS_ClientShortenMessage *sh_msg; |
802 | 794 | ||
803 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "SHORTEN"); | 795 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
796 | "Received `%s' message\n", "SHORTEN"); | ||
804 | msg_size = ntohs (message->size); | 797 | msg_size = ntohs (message->size); |
805 | if (msg_size < sizeof (struct GNUNET_GNS_ClientShortenMessage)) | 798 | if (msg_size < sizeof (struct GNUNET_GNS_ClientShortenMessage)) |
806 | { | 799 | { |
@@ -861,7 +854,11 @@ handle_shorten (void *cls, | |||
861 | csh->root_zone = zone_hash; //Default zone | 854 | csh->root_zone = zone_hash; //Default zone |
862 | else | 855 | else |
863 | csh->root_zone = sh_msg->zone; | 856 | csh->root_zone = sh_msg->zone; |
864 | start_shorten_name (csh); | 857 | csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, |
858 | &csh->root_zone, | ||
859 | &csh->private_zone, | ||
860 | &process_private_in_root_zone_lookup, | ||
861 | csh); | ||
865 | GNUNET_STATISTICS_update (statistics, | 862 | GNUNET_STATISTICS_update (statistics, |
866 | "Name shorten attempts", 1, GNUNET_NO); | 863 | "Name shorten attempts", 1, GNUNET_NO); |
867 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 864 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
@@ -872,10 +869,11 @@ handle_shorten (void *cls, | |||
872 | * Send get authority response back to client | 869 | * Send get authority response back to client |
873 | * | 870 | * |
874 | * @param cls the closure containing a client get auth handle | 871 | * @param cls the closure containing a client get auth handle |
875 | * @param name the shortened name result or NULL if cannot be shortened | 872 | * @param name the name of the authority, or NULL on error |
876 | */ | 873 | */ |
877 | static void | 874 | static void |
878 | send_get_auth_response(void *cls, const char* name) | 875 | send_get_auth_response (void *cls, |
876 | const char* name) | ||
879 | { | 877 | { |
880 | struct ClientGetAuthHandle *cah = cls; | 878 | struct ClientGetAuthHandle *cah = cls; |
881 | struct GNUNET_GNS_ClientGetAuthResultMessage *rmsg; | 879 | struct GNUNET_GNS_ClientGetAuthResultMessage *rmsg; |
@@ -890,21 +888,20 @@ send_get_auth_response(void *cls, const char* name) | |||
890 | } | 888 | } |
891 | if (NULL == name) | 889 | if (NULL == name) |
892 | name = ""; | 890 | name = ""; |
893 | rmsg = GNUNET_malloc(sizeof(struct GNUNET_GNS_ClientGetAuthResultMessage) | 891 | rmsg = GNUNET_malloc (sizeof (struct GNUNET_GNS_ClientGetAuthResultMessage) |
894 | + strlen(name) + 1); | 892 | + strlen (name) + 1); |
895 | 893 | ||
896 | rmsg->id = cah->request_id; | 894 | rmsg->id = cah->request_id; |
897 | rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_GET_AUTH_RESULT); | 895 | rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_GET_AUTH_RESULT); |
898 | rmsg->header.size = | 896 | rmsg->header.size = |
899 | htons(sizeof(struct GNUNET_GNS_ClientGetAuthResultMessage) + | 897 | htons(sizeof(struct GNUNET_GNS_ClientGetAuthResultMessage) + |
900 | strlen(name) + 1); | 898 | strlen (name) + 1); |
901 | strcpy ((char*)&rmsg[1], name); | 899 | strcpy ((char*)&rmsg[1], name); |
902 | 900 | ||
903 | GNUNET_SERVER_notification_context_unicast (nc, cah->client, | 901 | GNUNET_SERVER_notification_context_unicast (nc, cah->client, |
904 | &rmsg->header, | 902 | &rmsg->header, |
905 | GNUNET_NO); | 903 | GNUNET_NO); |
906 | GNUNET_SERVER_receive_done (cah->client, GNUNET_OK); | 904 | GNUNET_SERVER_receive_done (cah->client, GNUNET_OK); |
907 | |||
908 | GNUNET_free(rmsg); | 905 | GNUNET_free(rmsg); |
909 | GNUNET_free_non_null(cah->name); | 906 | GNUNET_free_non_null(cah->name); |
910 | GNUNET_free(cah); | 907 | GNUNET_free(cah); |
@@ -930,12 +927,13 @@ handle_get_authority (void *cls, | |||
930 | uint16_t msg_size; | 927 | uint16_t msg_size; |
931 | const struct GNUNET_GNS_ClientGetAuthMessage *sh_msg; | 928 | const struct GNUNET_GNS_ClientGetAuthMessage *sh_msg; |
932 | 929 | ||
933 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "GET_AUTH"); | 930 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
931 | "Received `%s' message\n", "GET_AUTH"); | ||
934 | msg_size = ntohs(message->size); | 932 | msg_size = ntohs(message->size); |
935 | if (msg_size < sizeof (struct GNUNET_GNS_ClientGetAuthMessage)) | 933 | if (msg_size < sizeof (struct GNUNET_GNS_ClientGetAuthMessage)) |
936 | { | 934 | { |
937 | GNUNET_break (0); | 935 | GNUNET_break (0); |
938 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 936 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
939 | return; | 937 | return; |
940 | } | 938 | } |
941 | GNUNET_SERVER_notification_context_add (nc, client); | 939 | GNUNET_SERVER_notification_context_add (nc, client); |
@@ -967,17 +965,17 @@ handle_get_authority (void *cls, | |||
967 | send_get_auth_response(cah, name); | 965 | send_get_auth_response(cah, name); |
968 | return; | 966 | return; |
969 | } | 967 | } |
970 | if (0 != strcmp (name + strlen (name) - strlen(GNUNET_GNS_TLD), | 968 | if (0 != strcmp (name + strlen (name) - strlen (GNUNET_GNS_TLD), |
971 | GNUNET_GNS_TLD)) | 969 | GNUNET_GNS_TLD)) |
972 | { | 970 | { |
973 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 971 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
974 | "GET_AUTH: %s is not our domain. Returning\n", name); | 972 | "GET_AUTH: %s is not our domain. Returning\n", name); |
975 | cah->name = NULL; | 973 | cah->name = NULL; |
976 | send_get_auth_response(cah, name); | 974 | send_get_auth_response (cah, name); |
977 | return; | 975 | return; |
978 | } | 976 | } |
979 | 977 | ||
980 | if (0 == strcmp(name, GNUNET_GNS_TLD)) | 978 | if (0 == strcmp (name, GNUNET_GNS_TLD)) |
981 | { | 979 | { |
982 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 980 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
983 | "GET_AUTH: %s is us. Returning\n", name); | 981 | "GET_AUTH: %s is us. Returning\n", name); |
@@ -988,8 +986,8 @@ handle_get_authority (void *cls, | |||
988 | 986 | ||
989 | cah->name = GNUNET_malloc (strlen (name) | 987 | cah->name = GNUNET_malloc (strlen (name) |
990 | - strlen (GNUNET_GNS_TLD) + 1); | 988 | - strlen (GNUNET_GNS_TLD) + 1); |
991 | memcpy(cah->name, name, | 989 | memcpy (cah->name, name, |
992 | strlen (name) - strlen (GNUNET_GNS_TLD)); | 990 | strlen (name) - strlen (GNUNET_GNS_TLD)); |
993 | 991 | ||
994 | /* Start delegation resolution in our namestore */ | 992 | /* Start delegation resolution in our namestore */ |
995 | gns_resolver_get_authority (zone_hash, zone_hash, name, | 993 | gns_resolver_get_authority (zone_hash, zone_hash, name, |
@@ -999,7 +997,6 @@ handle_get_authority (void *cls, | |||
999 | } | 997 | } |
1000 | 998 | ||
1001 | 999 | ||
1002 | |||
1003 | /** | 1000 | /** |
1004 | * Reply to client with the result from our lookup. | 1001 | * Reply to client with the result from our lookup. |
1005 | * | 1002 | * |
@@ -1008,9 +1005,9 @@ handle_get_authority (void *cls, | |||
1008 | * @param rd the record data | 1005 | * @param rd the record data |
1009 | */ | 1006 | */ |
1010 | static void | 1007 | static void |
1011 | send_lookup_response(void* cls, | 1008 | send_lookup_response (void* cls, |
1012 | uint32_t rd_count, | 1009 | uint32_t rd_count, |
1013 | const struct GNUNET_NAMESTORE_RecordData *rd) | 1010 | const struct GNUNET_NAMESTORE_RecordData *rd) |
1014 | { | 1011 | { |
1015 | struct ClientLookupHandle* clh = cls; | 1012 | struct ClientLookupHandle* clh = cls; |
1016 | struct GNUNET_GNS_ClientLookupResultMessage *rmsg; | 1013 | struct GNUNET_GNS_ClientLookupResultMessage *rmsg; |
@@ -1020,8 +1017,7 @@ send_lookup_response(void* cls, | |||
1020 | "LOOKUP_RESULT", rd_count); | 1017 | "LOOKUP_RESULT", rd_count); |
1021 | 1018 | ||
1022 | len = GNUNET_NAMESTORE_records_get_size (rd_count, rd); | 1019 | len = GNUNET_NAMESTORE_records_get_size (rd_count, rd); |
1023 | rmsg = GNUNET_malloc ( | 1020 | rmsg = GNUNET_malloc (len + sizeof (struct GNUNET_GNS_ClientLookupResultMessage)); |
1024 | len + sizeof (struct GNUNET_GNS_ClientLookupResultMessage)); | ||
1025 | 1021 | ||
1026 | rmsg->id = clh->request_id; | 1022 | rmsg->id = clh->request_id; |
1027 | rmsg->rd_count = htonl(rd_count); | 1023 | rmsg->rd_count = htonl(rd_count); |
@@ -1041,11 +1037,10 @@ send_lookup_response(void* cls, | |||
1041 | 1037 | ||
1042 | if (NULL != clh->shorten_key) | 1038 | if (NULL != clh->shorten_key) |
1043 | GNUNET_CRYPTO_rsa_key_free (clh->shorten_key); | 1039 | GNUNET_CRYPTO_rsa_key_free (clh->shorten_key); |
1044 | GNUNET_free(clh); | 1040 | GNUNET_free (clh); |
1045 | |||
1046 | GNUNET_STATISTICS_update (statistics, | 1041 | GNUNET_STATISTICS_update (statistics, |
1047 | "Completed lookups", 1, GNUNET_NO); | 1042 | "Completed lookups", 1, GNUNET_NO); |
1048 | if (rd != NULL) | 1043 | if (NULL != rd) |
1049 | GNUNET_STATISTICS_update (statistics, | 1044 | GNUNET_STATISTICS_update (statistics, |
1050 | "Records resolved", rd_count, GNUNET_NO); | 1045 | "Records resolved", rd_count, GNUNET_NO); |
1051 | } | 1046 | } |
@@ -1059,9 +1054,9 @@ send_lookup_response(void* cls, | |||
1059 | * @param message the message | 1054 | * @param message the message |
1060 | */ | 1055 | */ |
1061 | static void | 1056 | static void |
1062 | handle_lookup(void *cls, | 1057 | handle_lookup (void *cls, |
1063 | struct GNUNET_SERVER_Client * client, | 1058 | struct GNUNET_SERVER_Client * client, |
1064 | const struct GNUNET_MessageHeader * message) | 1059 | const struct GNUNET_MessageHeader * message) |
1065 | { | 1060 | { |
1066 | size_t namelen; | 1061 | size_t namelen; |
1067 | char name[MAX_DNS_NAME_LENGTH]; | 1062 | char name[MAX_DNS_NAME_LENGTH]; |
@@ -1075,13 +1070,13 @@ handle_lookup(void *cls, | |||
1075 | uint16_t msg_size; | 1070 | uint16_t msg_size; |
1076 | const struct GNUNET_GNS_ClientLookupMessage *sh_msg; | 1071 | const struct GNUNET_GNS_ClientLookupMessage *sh_msg; |
1077 | 1072 | ||
1078 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "LOOKUP"); | 1073 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1079 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "LOOKUP"); | 1074 | "Received `%s' message\n", "LOOKUP"); |
1080 | msg_size = ntohs(message->size); | 1075 | msg_size = ntohs(message->size); |
1081 | if (msg_size < sizeof (struct GNUNET_GNS_ClientLookupMessage)) | 1076 | if (msg_size < sizeof (struct GNUNET_GNS_ClientLookupMessage)) |
1082 | { | 1077 | { |
1083 | GNUNET_break (0); | 1078 | GNUNET_break (0); |
1084 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1079 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1085 | return; | 1080 | return; |
1086 | } | 1081 | } |
1087 | sh_msg = (const struct GNUNET_GNS_ClientLookupMessage *) message; | 1082 | sh_msg = (const struct GNUNET_GNS_ClientLookupMessage *) message; |
@@ -1103,10 +1098,10 @@ handle_lookup(void *cls, | |||
1103 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1098 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1104 | return; | 1099 | return; |
1105 | } | 1100 | } |
1106 | GNUNET_STRINGS_utf8_tolower(utf_in, &nameptr); | 1101 | GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr); |
1107 | } | 1102 | } |
1108 | 1103 | ||
1109 | namelen = strlen(name)+1; | 1104 | namelen = strlen (name) + 1; |
1110 | clh = GNUNET_malloc (sizeof (struct ClientLookupHandle)); | 1105 | clh = GNUNET_malloc (sizeof (struct ClientLookupHandle)); |
1111 | memset (clh, 0, sizeof (struct ClientLookupHandle)); | 1106 | memset (clh, 0, sizeof (struct ClientLookupHandle)); |
1112 | clh->client = client; | 1107 | clh->client = client; |
@@ -1126,7 +1121,7 @@ handle_lookup(void *cls, | |||
1126 | return; | 1121 | return; |
1127 | } | 1122 | } |
1128 | 1123 | ||
1129 | if ((clh->type == GNUNET_GNS_RECORD_A) && | 1124 | if ((GNUNET_GNS_RECORD_A == clh->type) && |
1130 | (GNUNET_OK != v4_enabled)) | 1125 | (GNUNET_OK != v4_enabled)) |
1131 | { | 1126 | { |
1132 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1127 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
@@ -1136,7 +1131,7 @@ handle_lookup(void *cls, | |||
1136 | return; | 1131 | return; |
1137 | } | 1132 | } |
1138 | 1133 | ||
1139 | if ((clh->type == GNUNET_GNS_RECORD_AAAA) && | 1134 | if ((GNUNET_GNS_RECORD_AAAA == clh->type) && |
1140 | (GNUNET_OK != v6_enabled)) | 1135 | (GNUNET_OK != v6_enabled)) |
1141 | { | 1136 | { |
1142 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1167,44 +1162,15 @@ handle_lookup(void *cls, | |||
1167 | only_cached, | 1162 | only_cached, |
1168 | &send_lookup_response, clh); | 1163 | &send_lookup_response, clh); |
1169 | } | 1164 | } |
1170 | |||
1171 | GNUNET_STATISTICS_update (statistics, | 1165 | GNUNET_STATISTICS_update (statistics, |
1172 | "Record lookup attempts", 1, GNUNET_NO); | 1166 | "Record lookup attempts", 1, GNUNET_NO); |
1173 | } | 1167 | } |
1174 | 1168 | ||
1175 | 1169 | ||
1176 | /** | 1170 | /** |
1177 | * Test if the given AF is supported by this system. | ||
1178 | * | ||
1179 | * @param af to test | ||
1180 | * @return GNUNET_OK if the AF is supported | ||
1181 | */ | ||
1182 | static int | ||
1183 | test_af (int af) | ||
1184 | { | ||
1185 | int s; | ||
1186 | |||
1187 | s = socket (af, SOCK_STREAM, 0); | ||
1188 | if (-1 == s) | ||
1189 | { | ||
1190 | if (EAFNOSUPPORT == errno) | ||
1191 | return GNUNET_NO; | ||
1192 | fprintf (stderr, "Failed to create test socket: %s\n", STRERROR (errno)); | ||
1193 | return GNUNET_SYSERR; | ||
1194 | } | ||
1195 | #if WINDOWS | ||
1196 | closesocket (s); | ||
1197 | #else | ||
1198 | close (s); | ||
1199 | #endif | ||
1200 | return GNUNET_OK; | ||
1201 | } | ||
1202 | |||
1203 | |||
1204 | /** | ||
1205 | * Process GNS requests. | 1171 | * Process GNS requests. |
1206 | * | 1172 | * |
1207 | * @param cls closure) | 1173 | * @param cls closure |
1208 | * @param server the initialized server | 1174 | * @param server the initialized server |
1209 | * @param c configuration to use | 1175 | * @param c configuration to use |
1210 | */ | 1176 | */ |
@@ -1212,23 +1178,21 @@ static void | |||
1212 | run (void *cls, struct GNUNET_SERVER_Handle *server, | 1178 | run (void *cls, struct GNUNET_SERVER_Handle *server, |
1213 | const struct GNUNET_CONFIGURATION_Handle *c) | 1179 | const struct GNUNET_CONFIGURATION_Handle *c) |
1214 | { | 1180 | { |
1215 | char* keyfile; | ||
1216 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; | ||
1217 | unsigned long long max_parallel_bg_queries = 0; | ||
1218 | unsigned long long default_lookup_timeout_secs = 0; | ||
1219 | int ignore_pending = GNUNET_NO; | ||
1220 | |||
1221 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 1181 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
1222 | {&handle_shorten, NULL, GNUNET_MESSAGE_TYPE_GNS_SHORTEN, 0}, | 1182 | {&handle_shorten, NULL, GNUNET_MESSAGE_TYPE_GNS_SHORTEN, 0}, |
1223 | {&handle_lookup, NULL, GNUNET_MESSAGE_TYPE_GNS_LOOKUP, 0}, | 1183 | {&handle_lookup, NULL, GNUNET_MESSAGE_TYPE_GNS_LOOKUP, 0}, |
1224 | {&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0} | 1184 | {&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0} |
1225 | }; | 1185 | }; |
1186 | char* keyfile; | ||
1187 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; | ||
1188 | unsigned long long max_parallel_bg_queries = 0; | ||
1189 | int ignore_pending = GNUNET_NO; | ||
1226 | 1190 | ||
1227 | v6_enabled = test_af (AF_INET6); | 1191 | v6_enabled = GNUNET_NETWORK_test_pf (PF_INET6); |
1228 | v4_enabled = test_af (AF_INET); | 1192 | v4_enabled = GNUNET_NETWORK_test_pf (PF_INET); |
1229 | 1193 | ||
1230 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "gns", | 1194 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "gns", |
1231 | "ZONEKEY", &keyfile)) | 1195 | "ZONEKEY", &keyfile)) |
1232 | { | 1196 | { |
1233 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1197 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1234 | "No private key for root zone specified!\n"); | 1198 | "No private key for root zone specified!\n"); |
@@ -1241,7 +1205,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1241 | 1205 | ||
1242 | zone_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | 1206 | zone_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); |
1243 | GNUNET_CRYPTO_rsa_key_get_public (zone_key, &pkey); | 1207 | GNUNET_CRYPTO_rsa_key_get_public (zone_key, &pkey); |
1244 | |||
1245 | GNUNET_CRYPTO_short_hash(&pkey, | 1208 | GNUNET_CRYPTO_short_hash(&pkey, |
1246 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 1209 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
1247 | &zone_hash); | 1210 | &zone_hash); |
@@ -1260,76 +1223,69 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1260 | GNUNET_CONFIGURATION_get_value_yesno (c, "gns", | 1223 | GNUNET_CONFIGURATION_get_value_yesno (c, "gns", |
1261 | "AUTO_IMPORT_PKEY")) | 1224 | "AUTO_IMPORT_PKEY")) |
1262 | { | 1225 | { |
1263 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1226 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1264 | "Automatic PKEY import is enabled.\n"); | 1227 | "Automatic PKEY import is enabled.\n"); |
1265 | auto_import_pkey = GNUNET_YES; | 1228 | auto_import_pkey = GNUNET_YES; |
1266 | |||
1267 | } | 1229 | } |
1268 | |||
1269 | put_interval = INITIAL_PUT_INTERVAL; | 1230 | put_interval = INITIAL_PUT_INTERVAL; |
1270 | |||
1271 | zone_publish_time_window = DEFAULT_ZONE_PUBLISH_TIME_WINDOW; | 1231 | zone_publish_time_window = DEFAULT_ZONE_PUBLISH_TIME_WINDOW; |
1272 | 1232 | ||
1273 | if (GNUNET_OK == | 1233 | if (GNUNET_OK == |
1274 | GNUNET_CONFIGURATION_get_value_time (c, "gns", | 1234 | GNUNET_CONFIGURATION_get_value_time (c, "gns", |
1275 | "ZONE_PUBLISH_TIME_WINDOW", | 1235 | "ZONE_PUBLISH_TIME_WINDOW", |
1276 | &zone_publish_time_window)) | 1236 | &zone_publish_time_window)) |
1277 | { | 1237 | { |
1278 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1238 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1279 | "Time window for zone iteration: %s\n", | 1239 | "Time window for zone iteration: %s\n", |
1280 | GNUNET_STRINGS_relative_time_to_string (zone_publish_time_window, GNUNET_YES)); | 1240 | GNUNET_STRINGS_relative_time_to_string (zone_publish_time_window, GNUNET_YES)); |
1281 | } | 1241 | } |
1282 | |||
1283 | if (GNUNET_OK == | 1242 | if (GNUNET_OK == |
1284 | GNUNET_CONFIGURATION_get_value_number (c, "gns", | 1243 | GNUNET_CONFIGURATION_get_value_number (c, "gns", |
1285 | "MAX_PARALLEL_BACKGROUND_QUERIES", | 1244 | "MAX_PARALLEL_BACKGROUND_QUERIES", |
1286 | &max_parallel_bg_queries)) | 1245 | &max_parallel_bg_queries)) |
1287 | { | 1246 | { |
1288 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1289 | "Number of allowed parallel background queries: %llu\n", | 1248 | "Number of allowed parallel background queries: %llu\n", |
1290 | max_parallel_bg_queries); | 1249 | max_parallel_bg_queries); |
1291 | } | 1250 | } |
1292 | 1251 | ||
1293 | if (GNUNET_YES == | 1252 | if (GNUNET_YES == |
1294 | GNUNET_CONFIGURATION_get_value_yesno (c, "gns", | 1253 | GNUNET_CONFIGURATION_get_value_yesno (c, "gns", |
1295 | "AUTO_IMPORT_CONFIRMATION_REQ")) | 1254 | "AUTO_IMPORT_CONFIRMATION_REQ")) |
1296 | { | 1255 | { |
1297 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1256 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1298 | "Auto import requires user confirmation\n"); | 1257 | "Auto import requires user confirmation\n"); |
1299 | ignore_pending = GNUNET_YES; | 1258 | ignore_pending = GNUNET_YES; |
1300 | } | 1259 | } |
1301 | 1260 | ||
1302 | if (GNUNET_OK == | 1261 | if (GNUNET_OK == |
1303 | GNUNET_CONFIGURATION_get_value_number(c, "gns", | 1262 | GNUNET_CONFIGURATION_get_value_time (c, "gns", |
1304 | "DEFAULT_LOOKUP_TIMEOUT", | 1263 | "DEFAULT_LOOKUP_TIMEOUT", |
1305 | &default_lookup_timeout_secs)) | 1264 | &default_lookup_timeout)) |
1306 | { | 1265 | { |
1307 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1266 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1308 | "Default lookup timeout: %llus\n", default_lookup_timeout_secs); | 1267 | "Default lookup timeout: %s\n", |
1309 | default_lookup_timeout = GNUNET_TIME_relative_multiply( | 1268 | GNUNET_STRINGS_relative_time_to_string (default_lookup_timeout, |
1310 | GNUNET_TIME_UNIT_SECONDS, | 1269 | GNUNET_YES)); |
1311 | default_lookup_timeout_secs); | ||
1312 | } | 1270 | } |
1313 | 1271 | ||
1314 | /** | 1272 | dht_handle = GNUNET_DHT_connect (c, |
1315 | * handle to the dht | 1273 | (unsigned int) max_parallel_bg_queries); |
1316 | */ | ||
1317 | dht_handle = GNUNET_DHT_connect(c, | ||
1318 | //max_parallel_bg_queries); //FIXME get ht_len from cfg | ||
1319 | 1024); | ||
1320 | |||
1321 | if (NULL == dht_handle) | 1274 | if (NULL == dht_handle) |
1322 | { | 1275 | { |
1323 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to DHT!\n"); | 1276 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1277 | _("Could not connect to DHT!\n")); | ||
1278 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
1279 | return; | ||
1324 | } | 1280 | } |
1325 | 1281 | ||
1326 | if (gns_resolver_init(namestore_handle, dht_handle, zone_hash, c, | 1282 | if (GNUNET_SYSERR == |
1327 | max_parallel_bg_queries, | 1283 | gns_resolver_init (namestore_handle, dht_handle, zone_hash, c, |
1328 | ignore_pending) | 1284 | max_parallel_bg_queries, |
1329 | == GNUNET_SYSERR) | 1285 | ignore_pending)) |
1330 | { | 1286 | { |
1331 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1287 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1332 | "Unable to initialize resolver!\n"); | 1288 | _("Unable to initialize resolver!\n")); |
1333 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 1289 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
1334 | return; | 1290 | return; |
1335 | } | 1291 | } |
@@ -1354,18 +1310,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1354 | */ | 1310 | */ |
1355 | first_zone_iteration = GNUNET_YES; | 1311 | first_zone_iteration = GNUNET_YES; |
1356 | zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, NULL); | 1312 | zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, NULL); |
1357 | |||
1358 | GNUNET_SERVER_add_handlers (server, handlers); | 1313 | GNUNET_SERVER_add_handlers (server, handlers); |
1359 | |||
1360 | //FIXME | ||
1361 | //GNUNET_SERVER_disconnect_notify (server, | ||
1362 | // &client_disconnect_notification, | ||
1363 | // NULL); | ||
1364 | |||
1365 | statistics = GNUNET_STATISTICS_create ("gns", c); | 1314 | statistics = GNUNET_STATISTICS_create ("gns", c); |
1366 | |||
1367 | nc = GNUNET_SERVER_notification_context_create (server, 1); | 1315 | nc = GNUNET_SERVER_notification_context_create (server, 1); |
1368 | |||
1369 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 1316 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
1370 | NULL); | 1317 | NULL); |
1371 | } | 1318 | } |