diff options
Diffstat (limited to 'src/topology/gnunet-daemon-topology.c')
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 167 |
1 files changed, 96 insertions, 71 deletions
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index b43238923..8b2278897 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -38,11 +38,12 @@ | |||
38 | */ | 38 | */ |
39 | #include "platform.h" | 39 | #include "platform.h" |
40 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
41 | #include "gnunet_hello_uri_lib.h" | ||
41 | #include "gnunet_friends_lib.h" | 42 | #include "gnunet_friends_lib.h" |
42 | #include "gnunet_constants.h" | 43 | #include "gnunet_constants.h" |
43 | #include "gnunet_core_service.h" | 44 | #include "gnunet_core_service.h" |
44 | #include "gnunet_protocols.h" | 45 | #include "gnunet_protocols.h" |
45 | #include "gnunet_peerinfo_service.h" | 46 | #include "gnunet_peerstore_service.h" |
46 | #include "gnunet_statistics_service.h" | 47 | #include "gnunet_statistics_service.h" |
47 | #include "gnunet_transport_application_service.h" | 48 | #include "gnunet_transport_application_service.h" |
48 | #include "gnunet_ats_service.h" | 49 | #include "gnunet_ats_service.h" |
@@ -81,9 +82,9 @@ struct Peer | |||
81 | struct GNUNET_MQ_Handle *mq; | 82 | struct GNUNET_MQ_Handle *mq; |
82 | 83 | ||
83 | /** | 84 | /** |
84 | * Pointer to the HELLO message of this peer; can be NULL. | 85 | * Pointer to the hello uri of this peer; can be NULL. |
85 | */ | 86 | */ |
86 | struct GNUNET_HELLO_Message *hello; | 87 | struct GNUNET_MessageHeader *hello; |
87 | 88 | ||
88 | /** | 89 | /** |
89 | * Bloom filter used to mark which peers already got the HELLO | 90 | * Bloom filter used to mark which peers already got the HELLO |
@@ -125,10 +126,10 @@ struct Peer | |||
125 | 126 | ||
126 | 127 | ||
127 | /** | 128 | /** |
128 | * Our peerinfo notification context. We use notification | 129 | * Our peerstore notification context. We use notification |
129 | * to instantly learn about new peers as they are discovered. | 130 | * to instantly learn about new peers as they are discovered. |
130 | */ | 131 | */ |
131 | static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify; | 132 | static struct GNUNET_PEERSTORE_NotifyContext *peerstore_notify; |
132 | 133 | ||
133 | /** | 134 | /** |
134 | * Our configuration. | 135 | * Our configuration. |
@@ -141,9 +142,9 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
141 | static struct GNUNET_CORE_Handle *handle; | 142 | static struct GNUNET_CORE_Handle *handle; |
142 | 143 | ||
143 | /** | 144 | /** |
144 | * Handle to the PEERINFO service. | 145 | * Handle to the PEERSTORE service. |
145 | */ | 146 | */ |
146 | static struct GNUNET_PEERINFO_Handle *pi; | 147 | static struct GNUNET_PEERSTORE_Handle *ps; |
147 | 148 | ||
148 | /** | 149 | /** |
149 | * Handle to Transport service. | 150 | * Handle to Transport service. |
@@ -156,6 +157,11 @@ struct GNUNET_TRANSPORT_ApplicationHandle *transport; | |||
156 | static struct GNUNET_PeerIdentity my_identity; | 157 | static struct GNUNET_PeerIdentity my_identity; |
157 | 158 | ||
158 | /** | 159 | /** |
160 | * Our private key. | ||
161 | */ | ||
162 | static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key; | ||
163 | |||
164 | /** | ||
159 | * All of our friends, all of our current neighbours and all peers for | 165 | * All of our friends, all of our current neighbours and all peers for |
160 | * which we have HELLOs. So pretty much everyone. Maps peer identities | 166 | * which we have HELLOs. So pretty much everyone. Maps peer identities |
161 | * to `struct Peer *` values. | 167 | * to `struct Peer *` values. |
@@ -318,6 +324,7 @@ attempt_connect (struct Peer *pos) | |||
318 | gettext_noop ("# connect requests issued to ATS"), | 324 | gettext_noop ("# connect requests issued to ATS"), |
319 | 1, | 325 | 1, |
320 | GNUNET_NO); | 326 | GNUNET_NO); |
327 | //TODO Use strength somehow. | ||
321 | pos->ash = GNUNET_TRANSPORT_application_suggest (transport, | 328 | pos->ash = GNUNET_TRANSPORT_application_suggest (transport, |
322 | &pos->pid, | 329 | &pos->pid, |
323 | GNUNET_MQ_PRIO_BEST_EFFORT, | 330 | GNUNET_MQ_PRIO_BEST_EFFORT, |
@@ -336,7 +343,7 @@ attempt_connect (struct Peer *pos) | |||
336 | */ | 343 | */ |
337 | static struct Peer * | 344 | static struct Peer * |
338 | make_peer (const struct GNUNET_PeerIdentity *peer, | 345 | make_peer (const struct GNUNET_PeerIdentity *peer, |
339 | const struct GNUNET_HELLO_Message *hello, | 346 | const struct GNUNET_MessageHeader *hello, |
340 | int is_friend) | 347 | int is_friend) |
341 | { | 348 | { |
342 | struct Peer *ret; | 349 | struct Peer *ret; |
@@ -346,8 +353,8 @@ make_peer (const struct GNUNET_PeerIdentity *peer, | |||
346 | ret->is_friend = is_friend; | 353 | ret->is_friend = is_friend; |
347 | if (NULL != hello) | 354 | if (NULL != hello) |
348 | { | 355 | { |
349 | ret->hello = GNUNET_malloc (GNUNET_HELLO_size (hello)); | 356 | ret->hello = GNUNET_malloc (sizeof (hello)); |
350 | GNUNET_memcpy (ret->hello, hello, GNUNET_HELLO_size (hello)); | 357 | GNUNET_memcpy (ret->hello, hello, sizeof (hello)); |
351 | } | 358 | } |
352 | GNUNET_break (GNUNET_OK == | 359 | GNUNET_break (GNUNET_OK == |
353 | GNUNET_CONTAINER_multipeermap_put ( | 360 | GNUNET_CONTAINER_multipeermap_put ( |
@@ -427,10 +434,16 @@ find_advertisable_hello (void *cls, | |||
427 | struct GNUNET_HashCode hc; | 434 | struct GNUNET_HashCode hc; |
428 | size_t hs; | 435 | size_t hs; |
429 | 436 | ||
437 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
438 | "find_advertisable_hello\n"); | ||
430 | if (pos == fah->peer) | 439 | if (pos == fah->peer) |
431 | return GNUNET_YES; | 440 | return GNUNET_YES; |
441 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
442 | "find_advertisable_hello 2\n"); | ||
432 | if (pos->hello == NULL) | 443 | if (pos->hello == NULL) |
433 | return GNUNET_YES; | 444 | return GNUNET_YES; |
445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
446 | "find_advertisable_hello 3\n"); | ||
434 | rst_time = GNUNET_TIME_absolute_get_remaining (pos->filter_expiration); | 447 | rst_time = GNUNET_TIME_absolute_get_remaining (pos->filter_expiration); |
435 | if (0 == rst_time.rel_value_us) | 448 | if (0 == rst_time.rel_value_us) |
436 | { | 449 | { |
@@ -439,9 +452,11 @@ find_advertisable_hello (void *cls, | |||
439 | setup_filter (pos); | 452 | setup_filter (pos); |
440 | } | 453 | } |
441 | fah->next_adv = GNUNET_TIME_relative_min (rst_time, fah->next_adv); | 454 | fah->next_adv = GNUNET_TIME_relative_min (rst_time, fah->next_adv); |
442 | hs = GNUNET_HELLO_size (pos->hello); | 455 | hs = pos->hello->size; |
443 | if (hs > fah->max_size) | 456 | if (hs > fah->max_size) |
444 | return GNUNET_YES; | 457 | return GNUNET_YES; |
458 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
459 | "find_advertisable_hello 4\n"); | ||
445 | GNUNET_CRYPTO_hash (&fah->peer->pid, | 460 | GNUNET_CRYPTO_hash (&fah->peer->pid, |
446 | sizeof(struct GNUNET_PeerIdentity), | 461 | sizeof(struct GNUNET_PeerIdentity), |
447 | &hc); | 462 | &hc); |
@@ -467,6 +482,8 @@ schedule_next_hello (void *cls) | |||
467 | struct GNUNET_TIME_Relative delay; | 482 | struct GNUNET_TIME_Relative delay; |
468 | struct GNUNET_HashCode hc; | 483 | struct GNUNET_HashCode hc; |
469 | 484 | ||
485 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
486 | "schedule_next_hello\n"); | ||
470 | pl->hello_delay_task = NULL; | 487 | pl->hello_delay_task = NULL; |
471 | GNUNET_assert (NULL != pl->mq); | 488 | GNUNET_assert (NULL != pl->mq); |
472 | /* find applicable HELLOs */ | 489 | /* find applicable HELLOs */ |
@@ -479,15 +496,19 @@ schedule_next_hello (void *cls) | |||
479 | GNUNET_SCHEDULER_add_delayed (fah.next_adv, &schedule_next_hello, pl); | 496 | GNUNET_SCHEDULER_add_delayed (fah.next_adv, &schedule_next_hello, pl); |
480 | if (NULL == fah.result) | 497 | if (NULL == fah.result) |
481 | return; | 498 | return; |
499 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
500 | "schedule_next_hello 2\n"); | ||
482 | delay = GNUNET_TIME_absolute_get_remaining (pl->next_hello_allowed); | 501 | delay = GNUNET_TIME_absolute_get_remaining (pl->next_hello_allowed); |
483 | if (0 != delay.rel_value_us) | 502 | if (0 != delay.rel_value_us) |
484 | return; | 503 | return; |
485 | 504 | ||
486 | want = GNUNET_HELLO_size (fah.result->hello); | 505 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
506 | "schedule_next_hello 3\n"); | ||
507 | want = fah.result->hello->size; | ||
487 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 508 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
488 | "Sending HELLO with %u bytes", | 509 | "Sending HELLO with %u bytes", |
489 | (unsigned int) want); | 510 | (unsigned int) want); |
490 | env = GNUNET_MQ_msg_copy (&fah.result->hello->header); | 511 | env = GNUNET_MQ_msg_copy (fah.result->hello); |
491 | GNUNET_MQ_send (pl->mq, env); | 512 | GNUNET_MQ_send (pl->mq, env); |
492 | 513 | ||
493 | /* avoid sending this one again soon */ | 514 | /* avoid sending this one again soon */ |
@@ -525,6 +546,9 @@ reschedule_hellos (void *cls, | |||
525 | struct Peer *peer = value; | 546 | struct Peer *peer = value; |
526 | struct Peer *skip = cls; | 547 | struct Peer *skip = cls; |
527 | 548 | ||
549 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
550 | "Reschedule for `%s'\n", | ||
551 | GNUNET_i2s (&peer->pid)); | ||
528 | if (skip == peer) | 552 | if (skip == peer) |
529 | return GNUNET_YES; | 553 | return GNUNET_YES; |
530 | if (NULL == peer->mq) | 554 | if (NULL == peer->mq) |
@@ -534,6 +558,8 @@ reschedule_hellos (void *cls, | |||
534 | GNUNET_SCHEDULER_cancel (peer->hello_delay_task); | 558 | GNUNET_SCHEDULER_cancel (peer->hello_delay_task); |
535 | peer->hello_delay_task = NULL; | 559 | peer->hello_delay_task = NULL; |
536 | } | 560 | } |
561 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
562 | "Schedule_next_hello\n"); | ||
537 | peer->hello_delay_task = | 563 | peer->hello_delay_task = |
538 | GNUNET_SCHEDULER_add_now (&schedule_next_hello, peer); | 564 | GNUNET_SCHEDULER_add_now (&schedule_next_hello, peer); |
539 | return GNUNET_YES; | 565 | return GNUNET_YES; |
@@ -678,18 +704,15 @@ disconnect_notify (void *cls, | |||
678 | * | 704 | * |
679 | * @param cls flag that we will set if we see any addresses | 705 | * @param cls flag that we will set if we see any addresses |
680 | * @param address the address of the peer | 706 | * @param address the address of the peer |
681 | * @param expiration when will the given address expire | ||
682 | * @return #GNUNET_SYSERR always, to terminate iteration | 707 | * @return #GNUNET_SYSERR always, to terminate iteration |
683 | */ | 708 | */ |
684 | static int | 709 | static void |
685 | address_iterator (void *cls, | 710 | address_iterator (void *cls, |
686 | const struct GNUNET_HELLO_Address *address, | 711 | const char *uri) |
687 | struct GNUNET_TIME_Absolute expiration) | ||
688 | { | 712 | { |
689 | int *flag = cls; | 713 | int *flag = cls; |
690 | 714 | ||
691 | *flag = GNUNET_YES; | 715 | *flag = GNUNET_YES; |
692 | return GNUNET_SYSERR; | ||
693 | } | 716 | } |
694 | 717 | ||
695 | 718 | ||
@@ -700,55 +723,53 @@ address_iterator (void *cls, | |||
700 | * @param hello the HELLO we got | 723 | * @param hello the HELLO we got |
701 | */ | 724 | */ |
702 | static void | 725 | static void |
703 | consider_for_advertising (const struct GNUNET_HELLO_Message *hello) | 726 | consider_for_advertising (const struct GNUNET_MessageHeader *hello) |
704 | { | 727 | { |
705 | int have_address; | 728 | int have_address; |
706 | struct GNUNET_PeerIdentity pid; | 729 | struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (hello); |
730 | struct GNUNET_PeerIdentity *pid; | ||
707 | struct GNUNET_TIME_Absolute dt; | 731 | struct GNUNET_TIME_Absolute dt; |
708 | struct GNUNET_HELLO_Message *nh; | 732 | struct GNUNET_MQ_Envelope *env; |
733 | const struct GNUNET_MessageHeader *nh; | ||
709 | struct Peer *peer; | 734 | struct Peer *peer; |
710 | uint16_t size; | 735 | uint16_t size; |
711 | 736 | ||
712 | if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid)) | ||
713 | { | ||
714 | GNUNET_break (0); | ||
715 | return; | ||
716 | } | ||
717 | if (0 == GNUNET_memcmp (&pid, &my_identity)) | ||
718 | return; /* that's me! */ | ||
719 | have_address = GNUNET_NO; | 737 | have_address = GNUNET_NO; |
720 | GNUNET_HELLO_iterate_addresses (hello, | 738 | GNUNET_HELLO_builder_iterate (builder, |
721 | GNUNET_NO, | 739 | pid, |
722 | &address_iterator, | 740 | &address_iterator, |
723 | &have_address); | 741 | &have_address); |
724 | if (GNUNET_NO == have_address) | 742 | if (GNUNET_NO == have_address) |
725 | return; /* no point in advertising this one... */ | 743 | return; /* no point in advertising this one... */ |
726 | peer = GNUNET_CONTAINER_multipeermap_get (peers, &pid); | 744 | if (NULL == pid || 0 == GNUNET_memcmp (pid, &my_identity)) |
745 | return; /* that's me! */ | ||
746 | |||
747 | peer = GNUNET_CONTAINER_multipeermap_get (peers, pid); | ||
727 | if (NULL == peer) | 748 | if (NULL == peer) |
728 | { | 749 | { |
729 | peer = make_peer (&pid, hello, GNUNET_NO); | 750 | peer = make_peer (pid, hello, GNUNET_NO); |
730 | } | 751 | } |
731 | else if (NULL != peer->hello) | 752 | |
732 | { | ||
733 | dt = GNUNET_HELLO_equals (peer->hello, hello, GNUNET_TIME_absolute_get ()); | ||
734 | if (dt.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) | ||
735 | return; /* nothing new here */ | ||
736 | } | ||
737 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
738 | "Found HELLO from peer `%s' for advertising\n", | ||
739 | GNUNET_i2s (&pid)); | ||
740 | if (NULL != peer->hello) | 753 | if (NULL != peer->hello) |
741 | { | 754 | { |
742 | nh = GNUNET_HELLO_merge (peer->hello, hello); | 755 | |
756 | env = GNUNET_HELLO_builder_merge_hellos (hello, peer->hello, my_private_key); | ||
757 | nh = GNUNET_MQ_env_get_msg (env); | ||
758 | if (NULL == nh) | ||
759 | return; | ||
743 | GNUNET_free (peer->hello); | 760 | GNUNET_free (peer->hello); |
744 | peer->hello = nh; | 761 | GNUNET_memcpy (peer->hello, nh, sizeof (nh)); |
762 | GNUNET_free (env); | ||
745 | } | 763 | } |
746 | else | 764 | else |
747 | { | 765 | { |
748 | size = GNUNET_HELLO_size (hello); | 766 | size = sizeof (hello); |
749 | peer->hello = GNUNET_malloc (size); | 767 | peer->hello = GNUNET_malloc (size); |
750 | GNUNET_memcpy (peer->hello, hello, size); | 768 | GNUNET_memcpy (peer->hello, hello, size); |
751 | } | 769 | } |
770 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
771 | "Found HELLO from peer `%s' for advertising\n", | ||
772 | GNUNET_i2s (pid)); | ||
752 | if (NULL != peer->filter) | 773 | if (NULL != peer->filter) |
753 | { | 774 | { |
754 | GNUNET_CONTAINER_bloomfilter_free (peer->filter); | 775 | GNUNET_CONTAINER_bloomfilter_free (peer->filter); |
@@ -762,7 +783,7 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello) | |||
762 | 783 | ||
763 | 784 | ||
764 | /** | 785 | /** |
765 | * PEERINFO calls this function to let us know about a possible peer | 786 | * PEERSTORE calls this function to let us know about a possible peer |
766 | * that we might want to connect to. | 787 | * that we might want to connect to. |
767 | * | 788 | * |
768 | * @param cls closure (not used) | 789 | * @param cls closure (not used) |
@@ -773,7 +794,7 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello) | |||
773 | static void | 794 | static void |
774 | process_peer (void *cls, | 795 | process_peer (void *cls, |
775 | const struct GNUNET_PeerIdentity *peer, | 796 | const struct GNUNET_PeerIdentity *peer, |
776 | const struct GNUNET_HELLO_Message *hello, | 797 | const struct GNUNET_MessageHeader *hello, |
777 | const char *err_msg) | 798 | const char *err_msg) |
778 | { | 799 | { |
779 | struct Peer *pos; | 800 | struct Peer *pos; |
@@ -781,11 +802,11 @@ process_peer (void *cls, | |||
781 | if (NULL != err_msg) | 802 | if (NULL != err_msg) |
782 | { | 803 | { |
783 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 804 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
784 | _ ("Error in communication with PEERINFO service: %s\n"), | 805 | _ ("Error in communication with PEERSTORE service: %s\n"), |
785 | err_msg); | 806 | err_msg); |
786 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify); | 807 | GNUNET_PEERSTORE_hello_changed_notify_cancel (peerstore_notify); |
787 | peerinfo_notify = | 808 | peerstore_notify = |
788 | GNUNET_PEERINFO_notify (cfg, GNUNET_NO, &process_peer, NULL); | 809 | GNUNET_PEERSTORE_hello_changed_notify (ps, GNUNET_NO, &process_peer, NULL); |
789 | return; | 810 | return; |
790 | } | 811 | } |
791 | GNUNET_assert (NULL != peer); | 812 | GNUNET_assert (NULL != peer); |
@@ -837,8 +858,8 @@ core_init (void *cls, const struct GNUNET_PeerIdentity *my_id) | |||
837 | } | 858 | } |
838 | my_identity = *my_id; | 859 | my_identity = *my_id; |
839 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I am peer `%s'\n", GNUNET_i2s (my_id)); | 860 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I am peer `%s'\n", GNUNET_i2s (my_id)); |
840 | peerinfo_notify = | 861 | peerstore_notify = |
841 | GNUNET_PEERINFO_notify (cfg, GNUNET_NO, &process_peer, NULL); | 862 | GNUNET_PEERSTORE_hello_changed_notify (ps, GNUNET_NO, &process_peer, NULL); |
842 | } | 863 | } |
843 | 864 | ||
844 | 865 | ||
@@ -916,11 +937,12 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
916 | * #GNUNET_SYSERR if @a message is invalid | 937 | * #GNUNET_SYSERR if @a message is invalid |
917 | */ | 938 | */ |
918 | static int | 939 | static int |
919 | check_hello (void *cls, const struct GNUNET_HELLO_Message *message) | 940 | check_hello (void *cls, const struct GNUNET_MessageHeader *message) |
920 | { | 941 | { |
921 | struct GNUNET_PeerIdentity pid; | 942 | struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (message); |
943 | struct GNUNET_PeerIdentity *pid = GNUNET_HELLO_builder_get_id (builder); | ||
922 | 944 | ||
923 | if (GNUNET_OK != GNUNET_HELLO_get_id (message, &pid)) | 945 | if (NULL == pid) |
924 | { | 946 | { |
925 | GNUNET_break_op (0); | 947 | GNUNET_break_op (0); |
926 | return GNUNET_SYSERR; | 948 | return GNUNET_SYSERR; |
@@ -937,21 +959,21 @@ check_hello (void *cls, const struct GNUNET_HELLO_Message *message) | |||
937 | * @param message the actual HELLO message | 959 | * @param message the actual HELLO message |
938 | */ | 960 | */ |
939 | static void | 961 | static void |
940 | handle_hello (void *cls, const struct GNUNET_HELLO_Message *message) | 962 | handle_hello (void *cls, const struct GNUNET_MessageHeader *message) |
941 | { | 963 | { |
942 | const struct GNUNET_PeerIdentity *other = cls; | 964 | const struct GNUNET_PeerIdentity *other = cls; |
943 | struct Peer *peer; | 965 | struct Peer *peer; |
944 | struct GNUNET_PeerIdentity pid; | 966 | struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (message); |
967 | struct GNUNET_PeerIdentity *pid = GNUNET_HELLO_builder_get_id (builder); | ||
945 | 968 | ||
946 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 969 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
947 | "Received encrypted HELLO from peer `%s'", | 970 | "Received encrypted HELLO from peer `%s'", |
948 | GNUNET_i2s (other)); | 971 | GNUNET_i2s (other)); |
949 | GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_id (message, &pid)); | ||
950 | GNUNET_STATISTICS_update (stats, | 972 | GNUNET_STATISTICS_update (stats, |
951 | gettext_noop ("# HELLO messages received"), | 973 | gettext_noop ("# HELLO messages received"), |
952 | 1, | 974 | 1, |
953 | GNUNET_NO); | 975 | GNUNET_NO); |
954 | peer = GNUNET_CONTAINER_multipeermap_get (peers, &pid); | 976 | peer = GNUNET_CONTAINER_multipeermap_get (peers, pid); |
955 | if (NULL == peer) | 977 | if (NULL == peer) |
956 | { | 978 | { |
957 | if ((GNUNET_YES == friends_only) || (friend_count < minimum_friend_count)) | 979 | if ((GNUNET_YES == friends_only) || (friend_count < minimum_friend_count)) |
@@ -965,7 +987,8 @@ handle_hello (void *cls, const struct GNUNET_HELLO_Message *message) | |||
965 | (friend_count < minimum_friend_count)) | 987 | (friend_count < minimum_friend_count)) |
966 | return; | 988 | return; |
967 | } | 989 | } |
968 | (void) GNUNET_PEERINFO_add_peer (pi, message, NULL, NULL); | 990 | (void) GNUNET_PEERSTORE_hello_add (ps, message, my_private_key, NULL, NULL); |
991 | GNUNET_HELLO_builder_free (builder); | ||
969 | } | 992 | } |
970 | 993 | ||
971 | 994 | ||
@@ -978,10 +1001,10 @@ handle_hello (void *cls, const struct GNUNET_HELLO_Message *message) | |||
978 | static void | 1001 | static void |
979 | cleaning_task (void *cls) | 1002 | cleaning_task (void *cls) |
980 | { | 1003 | { |
981 | if (NULL != peerinfo_notify) | 1004 | if (NULL != peerstore_notify) |
982 | { | 1005 | { |
983 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify); | 1006 | GNUNET_PEERSTORE_hello_changed_notify_cancel (peerstore_notify); |
984 | peerinfo_notify = NULL; | 1007 | peerstore_notify = NULL; |
985 | } | 1008 | } |
986 | if (NULL != handle) | 1009 | if (NULL != handle) |
987 | { | 1010 | { |
@@ -1001,10 +1024,10 @@ cleaning_task (void *cls) | |||
1001 | GNUNET_TRANSPORT_application_done (transport); | 1024 | GNUNET_TRANSPORT_application_done (transport); |
1002 | transport = NULL; | 1025 | transport = NULL; |
1003 | } | 1026 | } |
1004 | if (NULL != pi) | 1027 | if (NULL != ps) |
1005 | { | 1028 | { |
1006 | GNUNET_PEERINFO_disconnect (pi); | 1029 | GNUNET_PEERSTORE_disconnect (ps, GNUNET_YES); |
1007 | pi = NULL; | 1030 | ps = NULL; |
1008 | } | 1031 | } |
1009 | if (NULL != stats) | 1032 | if (NULL != stats) |
1010 | { | 1033 | { |
@@ -1030,13 +1053,15 @@ run (void *cls, | |||
1030 | { | 1053 | { |
1031 | struct GNUNET_MQ_MessageHandler handlers[] = | 1054 | struct GNUNET_MQ_MessageHandler handlers[] = |
1032 | { GNUNET_MQ_hd_var_size (hello, | 1055 | { GNUNET_MQ_hd_var_size (hello, |
1033 | GNUNET_MESSAGE_TYPE_HELLO, | 1056 | GNUNET_MESSAGE_TYPE_HELLO_URI, |
1034 | struct GNUNET_HELLO_Message, | 1057 | struct GNUNET_MessageHeader, |
1035 | NULL), | 1058 | NULL), |
1036 | GNUNET_MQ_handler_end () }; | 1059 | GNUNET_MQ_handler_end () }; |
1037 | unsigned long long opt; | 1060 | unsigned long long opt; |
1038 | 1061 | ||
1039 | cfg = c; | 1062 | cfg = c; |
1063 | my_private_key = | ||
1064 | GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg); | ||
1040 | stats = GNUNET_STATISTICS_create ("topology", cfg); | 1065 | stats = GNUNET_STATISTICS_create ("topology", cfg); |
1041 | 1066 | ||
1042 | minimum_friend_count = 0; | 1067 | minimum_friend_count = 0; |
@@ -1056,7 +1081,7 @@ run (void *cls, | |||
1056 | minimum_friend_count); | 1081 | minimum_friend_count); |
1057 | 1082 | ||
1058 | transport = GNUNET_TRANSPORT_application_init (cfg); | 1083 | transport = GNUNET_TRANSPORT_application_init (cfg); |
1059 | pi = GNUNET_PEERINFO_connect (cfg); | 1084 | ps = GNUNET_PEERSTORE_connect (cfg); |
1060 | handle = GNUNET_CORE_connect (cfg, | 1085 | handle = GNUNET_CORE_connect (cfg, |
1061 | NULL, | 1086 | NULL, |
1062 | &core_init, | 1087 | &core_init, |