aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-14 20:52:16 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-14 20:52:16 +0000
commita8e5b09df9ce6f090ab4ecfde02fc7ab3b667c13 (patch)
treedd96afbbe0cfb435c94a377d6762100d4a205d05
parentea17e83e666b0104b43d04423cef193f92199c26 (diff)
downloadgnunet-a8e5b09df9ce6f090ab4ecfde02fc7ab3b667c13.tar.gz
gnunet-a8e5b09df9ce6f090ab4ecfde02fc7ab3b667c13.zip
-fixing peerinfo part of #3559
-rw-r--r--configure.ac6
-rwxr-xr-xsrc/dns/install-dns-helper.sh13
-rw-r--r--src/include/gnunet_core_service.h1
-rw-r--r--src/include/gnunet_hello_lib.h5
-rw-r--r--src/include/gnunet_peerinfo_service.h2
-rw-r--r--src/include/gnunet_transport_service.h15
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo.c154
7 files changed, 110 insertions, 86 deletions
diff --git a/configure.ac b/configure.ac
index 9bfbd31c3..1db9b1b76 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1079,12 +1079,12 @@ AC_ARG_WITH(gnutls,
1079 AC_CHECK_LIB([gnutls], [gnutls_priority_set], 1079 AC_CHECK_LIB([gnutls], [gnutls_priority_set],
1080 gnutls=true)) 1080 gnutls=true))
1081 AC_CHECK_HEADERS([gnutls/dane.h], 1081 AC_CHECK_HEADERS([gnutls/dane.h],
1082 AC_CHECK_LIB([gnutls-dane], [dane_verify_crt_raw], 1082 AC_CHECK_LIB([gnutls-dane], [dane_verify_crt_raw],
1083 gnutls_dane=1)) 1083 gnutls_dane=1))
1084 ]) 1084 ])
1085AM_CONDITIONAL(HAVE_GNUTLS, test x$gnutls = xtrue) 1085AM_CONDITIONAL(HAVE_GNUTLS, test x$gnutls = xtrue)
1086AC_DEFINE_UNQUOTED([HAVE_GNUTLS], $gnutls, [We have GnuTLS]) 1086AC_DEFINE_UNQUOTED([HAVE_GNUTLS], $gnutls, [We have GnuTLS])
1087 1087d
1088AM_CONDITIONAL(HAVE_GNUTLS_DANE, test x$gnutls_dane = x1) 1088AM_CONDITIONAL(HAVE_GNUTLS_DANE, test x$gnutls_dane = x1)
1089AC_DEFINE_UNQUOTED([HAVE_GNUTLS_DANE], $gnutls_dane, [We have GnuTLS with DANE support]) 1089AC_DEFINE_UNQUOTED([HAVE_GNUTLS_DANE], $gnutls_dane, [We have GnuTLS with DANE support])
1090 1090
diff --git a/src/dns/install-dns-helper.sh b/src/dns/install-dns-helper.sh
index bf2dd427d..0e7b86b36 100755
--- a/src/dns/install-dns-helper.sh
+++ b/src/dns/install-dns-helper.sh
@@ -1,9 +1,10 @@
1#!/bin/bash 1#!/bin/sh
2# $1 - bindir 2# $1 - bindir
3# $2 - gnunetdns group 3# $2 - gnunetdns group
4# $3 - sudo binary (optional) 4# $3 - sudo binary (optional)
5$3 chown root $1/gnunet-helper-dns || true 5$3 chown root $1/gnunet-helper-dns
6$3 chgrp $2 $1/gnunet-helper-dns || true 6$3 chgrp $2 $1/gnunet-helper-dns
7$3 chmod 4750 $1/gnunet-helper-dns || true 7$3 chmod 4750 $1/gnunet-helper-dns
8$3 chown gnunet:$2 $1/gnunet-service-dns || true 8$3 chown gnunet:$2 $1/gnunet-service-dns
9$3 chmod 2750 $1/gnunet-service-dns || true 9$3 chmod 2750 $1/gnunet-service-dns
10
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h
index c06e3c1f6..f65d94eee 100644
--- a/src/include/gnunet_core_service.h
+++ b/src/include/gnunet_core_service.h
@@ -17,7 +17,6 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @file include/gnunet_core_service.h 21 * @file include/gnunet_core_service.h
23 * @brief core service; this is the main API for encrypted P2P 22 * @brief core service; this is the main API for encrypted P2P
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h
index a8a565695..6962e6945 100644
--- a/src/include/gnunet_hello_lib.h
+++ b/src/include/gnunet_hello_lib.h
@@ -411,6 +411,11 @@ struct GNUNET_MessageHeader *
411GNUNET_HELLO_get_header (struct GNUNET_HELLO_Message *hello); 411GNUNET_HELLO_get_header (struct GNUNET_HELLO_Message *hello);
412 412
413 413
414/**
415 * FIXME.
416 *
417 * @param name
418 */
414typedef struct GNUNET_TRANSPORT_PluginFunctions * 419typedef struct GNUNET_TRANSPORT_PluginFunctions *
415(*GNUNET_HELLO_TransportPluginsFind) (const char *name); 420(*GNUNET_HELLO_TransportPluginsFind) (const char *name);
416 421
diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h
index ff8700861..caa659065 100644
--- a/src/include/gnunet_peerinfo_service.h
+++ b/src/include/gnunet_peerinfo_service.h
@@ -62,7 +62,7 @@ GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
62 * Disconnect from the peerinfo service. Note that all iterators must 62 * Disconnect from the peerinfo service. Note that all iterators must
63 * have completed or have been cancelled by the time this function is 63 * have completed or have been cancelled by the time this function is
64 * called (otherwise, calling this function is a serious error). 64 * called (otherwise, calling this function is a serious error).
65 * Furthermore, if 'GNUNET_PEERINFO_add_peer' operations are still 65 * Furthermore, if #GNUNET_PEERINFO_add_peer() operations are still
66 * pending, they will be cancelled silently on disconnect. 66 * pending, they will be cancelled silently on disconnect.
67 * 67 *
68 * @param h handle to disconnect 68 * @param h handle to disconnect
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index b3ab4d01e..cfa5fdbe0 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -176,7 +176,7 @@ struct GNUNET_TRANSPORT_TryConnectHandle;
176 */ 176 */
177typedef void 177typedef void
178(*GNUNET_TRANSPORT_TryConnectCallback) (void *cls, 178(*GNUNET_TRANSPORT_TryConnectCallback) (void *cls,
179 const int result); 179 int result);
180 180
181 181
182/** 182/**
@@ -296,7 +296,6 @@ void
296GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct GNUNET_TRANSPORT_TransmitHandle *th); 296GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct GNUNET_TRANSPORT_TransmitHandle *th);
297 297
298 298
299
300/** 299/**
301 * Checks if a given peer is connected to us 300 * Checks if a given peer is connected to us
302 * 301 *
@@ -397,6 +396,7 @@ GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh);
397 */ 396 */
398struct GNUNET_TRANSPORT_OfferHelloHandle; 397struct GNUNET_TRANSPORT_OfferHelloHandle;
399 398
399
400/** 400/**
401 * Offer the transport service the HELLO of another peer. Note that 401 * Offer the transport service the HELLO of another peer. Note that
402 * the transport service may just ignore this message if the HELLO is 402 * the transport service may just ignore this message if the HELLO is
@@ -648,7 +648,7 @@ struct GNUNET_TRANSPORT_PeerMonitoringContext;
648 * a final call with NULL for peer and address will follow when done. 648 * a final call with NULL for peer and address will follow when done.
649 * In this case state and timeout do not contain valid values. 649 * In this case state and timeout do not contain valid values.
650 * 650 *
651 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called from 651 * The #GNUNET_TRANSPORT_monitor_peers_cancel() call MUST not be called from
652 * within this function! 652 * within this function!
653 * 653 *
654 * 654 *
@@ -678,8 +678,8 @@ typedef void
678 * to communicate with this peer, the state this peer is currently in and the 678 * to communicate with this peer, the state this peer is currently in and the
679 * the current timeout for this state. 679 * the current timeout for this state.
680 * 680 *
681 * Upon completion, the 'GNUNET_TRANSPORT_PeerIterateCallback' is called one 681 * Upon completion, the #GNUNET_TRANSPORT_PeerIterateCallback is called one
682 * more time with 'NULL'. After this, the operation must no longer be 682 * more time with `NULL`. After this, the operation must no longer be
683 * explicitly canceled. 683 * explicitly canceled.
684 * 684 *
685 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the 685 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the
@@ -771,8 +771,8 @@ enum GNUNET_TRANSPORT_ValidationState
771 * indicate a change to a validation entry. The information included represent 771 * indicate a change to a validation entry. The information included represent
772 * the current state of the validation entry, 772 * the current state of the validation entry,
773 * 773 *
774 * If the monitoring was called with one_shot=GNUNET_YES, a final callback 774 * If the monitoring was called with `one_shot==GNUNET_YES`, a final callback
775 * with peer==NULL and address==NULL is executed. 775 * with `peer==NULL` and `address==NULL` is executed.
776 * 776 *
777 * @param cls closure 777 * @param cls closure
778 * @param peer peer this update is about, 778 * @param peer peer this update is about,
@@ -1007,7 +1007,6 @@ typedef void
1007 const struct GNUNET_TRANSPORT_SessionInfo *info); 1007 const struct GNUNET_TRANSPORT_SessionInfo *info);
1008 1008
1009 1009
1010
1011/** 1010/**
1012 * Install a plugin session state monitor callback. The callback 1011 * Install a plugin session state monitor callback. The callback
1013 * will be notified whenever the session changes. 1012 * will be notified whenever the session changes.
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c
index d826a8050..18e1f8da7 100644
--- a/src/peerinfo-tool/gnunet-peerinfo.c
+++ b/src/peerinfo-tool/gnunet-peerinfo.c
@@ -178,6 +178,16 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
178static GNUNET_SCHEDULER_TaskIdentifier tt; 178static GNUNET_SCHEDULER_TaskIdentifier tt;
179 179
180/** 180/**
181 * Pending #GNUNET_TRANSPORT_get_hello() operation.
182 */
183static struct GNUNET_TRANSPORT_GetHelloHandle *gh;
184
185/**
186 * Connection to transport service.
187 */
188static struct GNUNET_TRANSPORT_Handle *transport;
189
190/**
181 * Current iterator context (if active, otherwise NULL). 191 * Current iterator context (if active, otherwise NULL).
182 */ 192 */
183static struct GNUNET_PEERINFO_IteratorContext *pic; 193static struct GNUNET_PEERINFO_IteratorContext *pic;
@@ -202,6 +212,11 @@ static struct PrintContext *pc_tail;
202 */ 212 */
203static struct GNUNET_PEERINFO_AddContext *ac; 213static struct GNUNET_PEERINFO_AddContext *ac;
204 214
215/**
216 * Hello of this peer (if initialized).
217 */
218static struct GNUNET_HELLO_Message *my_hello;
219
205 220
206/** 221/**
207 * Main state machine that goes over all options and 222 * Main state machine that goes over all options and
@@ -436,44 +451,23 @@ count_addr (void *cls,
436 * @param err_msg error message 451 * @param err_msg error message
437 */ 452 */
438static void 453static void
439dump_my_hello (void *cls, 454dump_my_hello ()
440 const struct GNUNET_PeerIdentity *peer,
441 const struct GNUNET_HELLO_Message *hello,
442 const char *err_msg)
443{ 455{
444 unsigned int size; 456 unsigned int size;
445 unsigned int c_addr; 457 unsigned int c_addr;
446 458
447 if (NULL == peer) 459 size = GNUNET_HELLO_size (my_hello);
448 {
449 pic = NULL;
450 if (NULL != err_msg)
451 FPRINTF (stderr,
452 _("Error in communication with PEERINFO service: %s\n"),
453 err_msg);
454 tt = GNUNET_SCHEDULER_add_now (&state_machine,
455 NULL);
456 return;
457 }
458
459 if (NULL == hello)
460 {
461 FPRINTF (stderr,
462 _("Failure: Did not receive %s\n"),
463 "HELLO");
464 return;
465 }
466
467 size = GNUNET_HELLO_size (hello);
468 if (0 == size) 460 if (0 == size)
469 { 461 {
470 FPRINTF (stderr, 462 FPRINTF (stderr,
471 _("Failure: Received invalid %s\n"), 463 _("Failure: Received invalid %s\n"),
472 "HELLO"); 464 "HELLO");
473 return; 465 return;
474 } 466 }
475 if (GNUNET_SYSERR == 467 if (GNUNET_SYSERR ==
476 GNUNET_DISK_fn_write (dump_hello, hello, size, 468 GNUNET_DISK_fn_write (dump_hello,
469 my_hello,
470 size,
477 GNUNET_DISK_PERM_USER_READ | 471 GNUNET_DISK_PERM_USER_READ |
478 GNUNET_DISK_PERM_USER_WRITE | 472 GNUNET_DISK_PERM_USER_WRITE |
479 GNUNET_DISK_PERM_GROUP_READ | 473 GNUNET_DISK_PERM_GROUP_READ |
@@ -491,7 +485,7 @@ dump_my_hello (void *cls,
491 485
492 } 486 }
493 c_addr = 0; 487 c_addr = 0;
494 GNUNET_HELLO_iterate_addresses (hello, 488 GNUNET_HELLO_iterate_addresses (my_hello,
495 GNUNET_NO, 489 GNUNET_NO,
496 count_addr, 490 count_addr,
497 &c_addr); 491 &c_addr);
@@ -500,7 +494,7 @@ dump_my_hello (void *cls,
500 { 494 {
501 FPRINTF (stderr, 495 FPRINTF (stderr,
502 _("Wrote %s HELLO containing %u addresses with %u bytes to file `%s'\n"), 496 _("Wrote %s HELLO containing %u addresses with %u bytes to file `%s'\n"),
503 (GNUNET_YES == GNUNET_HELLO_is_friend_only(hello)) ? "friend-only": "public", 497 (GNUNET_YES == GNUNET_HELLO_is_friend_only (my_hello)) ? "friend-only": "public",
504 c_addr, 498 c_addr,
505 size, 499 size,
506 dump_hello); 500 dump_hello);
@@ -527,6 +521,8 @@ print_my_uri (void *cls,
527 const struct GNUNET_HELLO_Message *hello, 521 const struct GNUNET_HELLO_Message *hello,
528 const char *err_msg) 522 const char *err_msg)
529{ 523{
524 char *uri;
525
530 if (NULL == peer) 526 if (NULL == peer)
531 { 527 {
532 pic = NULL; 528 pic = NULL;
@@ -540,8 +536,8 @@ print_my_uri (void *cls,
540 536
541 if (NULL == hello) 537 if (NULL == hello)
542 return; 538 return;
543 char *uri = GNUNET_HELLO_compose_uri (hello, 539 uri = GNUNET_HELLO_compose_uri (hello,
544 &GPI_plugins_find); 540 &GPI_plugins_find);
545 if (NULL != uri) 541 if (NULL != uri)
546 { 542 {
547 printf ("%s\n", 543 printf ("%s\n",
@@ -640,6 +636,16 @@ shutdown_task (void *cls,
640 GNUNET_PEERINFO_iterate_cancel (pic); 636 GNUNET_PEERINFO_iterate_cancel (pic);
641 pic = NULL; 637 pic = NULL;
642 } 638 }
639 if (NULL != gh)
640 {
641 GNUNET_TRANSPORT_get_hello_cancel (gh);
642 gh = NULL;
643 }
644 if (NULL != transport)
645 {
646 GNUNET_TRANSPORT_disconnect (transport);
647 transport = NULL;
648 }
643 while (NULL != (pc = pc_head)) 649 while (NULL != (pc = pc_head))
644 { 650 {
645 GNUNET_CONTAINER_DLL_remove (pc_head, 651 GNUNET_CONTAINER_DLL_remove (pc_head,
@@ -664,6 +670,43 @@ shutdown_task (void *cls,
664 GNUNET_PEERINFO_disconnect (peerinfo); 670 GNUNET_PEERINFO_disconnect (peerinfo);
665 peerinfo = NULL; 671 peerinfo = NULL;
666 } 672 }
673 if (NULL != my_hello)
674 {
675 GNUNET_free (my_hello);
676 my_hello = NULL;
677 }
678}
679
680
681/**
682 * Function called with our peer's HELLO message.
683 * Used to obtain our peer's public key.
684 *
685 * @param cls NULL
686 * @param hello the HELLO message
687 */
688static void
689hello_callback (void *cls,
690 const struct GNUNET_MessageHeader *hello)
691{
692 if (NULL == hello)
693 {
694 fprintf (stderr,
695 _("Failed to get my own HELLO from this peer!\n"));
696 GNUNET_SCHEDULER_shutdown ();
697 return;
698 }
699 my_hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (hello);
700 GNUNET_assert (GNUNET_OK ==
701 GNUNET_HELLO_get_id (hello,
702 &my_peer_identity));
703 GNUNET_TRANSPORT_get_hello_cancel (gh);
704 gh = NULL;
705 GNUNET_TRANSPORT_disconnect (transport);
706 transport = NULL;
707 if (NULL != dump_hello)
708 dump_my_hello ();
709 tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
667} 710}
668 711
669 712
@@ -700,33 +743,18 @@ testservice_task (void *cls,
700 (GNUNET_YES == get_uri) || 743 (GNUNET_YES == get_uri) ||
701 (NULL != dump_hello) ) 744 (NULL != dump_hello) )
702 { 745 {
703 /* load private key */ 746 transport = GNUNET_TRANSPORT_connect (cfg,
704 if (GNUNET_OK != 747 NULL,
705 GNUNET_CONFIGURATION_get_value_filename (cfg, 748 NULL,
706 "PEER", 749 NULL, NULL, NULL);
707 "PRIVATE_KEY", 750 gh = GNUNET_TRANSPORT_get_hello (transport,
708 &fn)) 751 &hello_callback,
709 { 752 NULL);
710 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 753 }
711 "PEER", 754 else
712 "PRIVATE_KEY"); 755 {
713 return; 756 tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
714 }
715 if (NULL == (priv = GNUNET_CRYPTO_eddsa_key_create_from_file (fn)))
716 {
717 FPRINTF (stderr,
718 _("Loading hostkey from `%s' failed.\n"),
719 fn);
720 GNUNET_free (fn);
721 return;
722 }
723 GNUNET_free (fn);
724 GNUNET_CRYPTO_eddsa_key_get_public (priv,
725 &my_peer_identity.public_key);
726 GNUNET_free (priv);
727 } 757 }
728
729 tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
730 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 758 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
731 &shutdown_task, 759 &shutdown_task,
732 NULL); 760 NULL);
@@ -827,14 +855,6 @@ state_machine (void *cls,
827 &print_my_uri, NULL); 855 &print_my_uri, NULL);
828 get_uri = GNUNET_NO; 856 get_uri = GNUNET_NO;
829 } 857 }
830 else if (NULL != dump_hello)
831 {
832 pic = GNUNET_PEERINFO_iterate (peerinfo,
833 include_friend_only,
834 &my_peer_identity,
835 TIMEOUT,
836 &dump_my_hello, NULL);
837 }
838 else if (GNUNET_YES == default_operation) 858 else if (GNUNET_YES == default_operation)
839 { 859 {
840 /* default operation list all */ 860 /* default operation list all */
@@ -843,8 +863,8 @@ state_machine (void *cls,
843 tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); 863 tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
844 } 864 }
845 else 865 else
846 { 866 {
847 GNUNET_SCHEDULER_shutdown (); 867 GNUNET_SCHEDULER_shutdown ();
848 } 868 }
849 default_operation = GNUNET_NO; 869 default_operation = GNUNET_NO;
850} 870}