* Printable address.
*/
char *result;
-
+
/**
* Print context this address record belongs to.
*/
* Identity of the peer.
*/
struct GNUNET_PeerIdentity peer;
-
+
/**
* List of printable addresses.
*/
static int get_self;
/**
- * Option
+ * Option
*/
static int get_uri;
static int get_info;
/**
- * Option
+ * Option
*/
static char *put_uri;
GNUNET_free (pc);
if ( (NULL == pc_head) &&
(NULL == pic) )
- tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
+ tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
}
* Currently prints the GNUNET_PeerIdentity and the transport address.
*
* @param cls the 'struct PrintContext'
- * @param peer identity of the peer
+ * @param peer identity of the peer
* @param hello addresses of the peer
* @param err_msg error message
*/
pic = NULL; /* end of iteration */
if (NULL != err_msg)
{
- FPRINTF (stderr,
+ FPRINTF (stderr,
_("Error in communication with PEERINFO service: %s\n"),
err_msg);
}
GNUNET_i2s_full (peer));
return;
}
- pc = GNUNET_malloc (sizeof (struct PrintContext));
+ pc = GNUNET_new (struct PrintContext);
GNUNET_CONTAINER_DLL_insert (pc_head,
- pc_tail,
+ pc_tail,
pc);
pc->peer = *peer;
pc->friend_only = friend_only;
- GNUNET_HELLO_iterate_addresses (hello,
- GNUNET_NO,
- &count_address,
+ GNUNET_HELLO_iterate_addresses (hello,
+ GNUNET_NO,
+ &count_address,
pc);
if (0 == pc->off)
{
}
pc->address_list_size = pc->off;
pc->address_list = GNUNET_malloc (sizeof (struct AddressRecord) * pc->off);
- GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO,
+ GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO,
&print_address, pc);
}
*/
static void
print_my_uri (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello,
+ const struct GNUNET_HELLO_Message *hello,
const char *err_msg)
{
if (peer == NULL)
pic = NULL;
if (err_msg != NULL)
FPRINTF (stderr,
- _("Error in communication with PEERINFO service: %s\n"),
+ _("Error in communication with PEERINFO service: %s\n"),
err_msg);
tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
return;
/**
- * Parse the PUT URI given at the command line and add it to our peerinfo
+ * Parse the PUT URI given at the command line and add it to our peerinfo
* database.
*
* @param put_uri URI string to parse
{
struct GNUNET_HELLO_Message *hello = NULL;
- int ret = GNUNET_HELLO_parse_uri(put_uri, &my_peer_identity.public_key,
+ int ret = GNUNET_HELLO_parse_uri(put_uri, &my_peer_identity.public_key,
&hello, &GPI_plugins_find);
if (NULL != hello) {
}
}
-
/**
- * Main function that will be run by the scheduler.
+ * Function called with the result of the check if the 'peerinfo'
+ * service is running.
*
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be NULL!)
- * @param c configuration
+ * @param cls closure with our configuration
+ * @param result #GNUNET_YES if transport is running
*/
static void
-run (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *c)
+testservice_task (void *cls, int result)
{
- struct GNUNET_CRYPTO_EccPrivateKey *priv;
+ struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
char *fn;
- cfg = c;
- if ( (NULL != args[0]) &&
- (NULL == put_uri) &&
- (args[0] == strcasestr (args[0], "gnunet://hello/")) )
+ if (GNUNET_YES != result)
{
- put_uri = GNUNET_strdup (args[0]);
- args++;
- }
- if (NULL != args[0])
- {
- FPRINTF (stderr,
- _("Invalid command line argument `%s'\n"),
- args[0]);
+ FPRINTF (stderr, _("Service `%s' is not running, please start GNUnet\n"), "peerinfo");
return;
}
+
if (NULL == (peerinfo = GNUNET_PEERINFO_connect (cfg)))
{
FPRINTF (stderr, "%s", _("Could not access PEERINFO service. Exiting.\n"));
if ( (GNUNET_YES == get_self) || (GNUNET_YES == get_uri) || (NULL != dump_hello) )
{
/* load private key */
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER", "PRIVATE_KEY",
- &fn))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER",
+ "PRIVATE_KEY",
+ &fn))
{
- FPRINTF (stderr, _("Could not find option `%s:%s' in configuration.\n"),
- "GNUNETD", "HOSTKEYFILE");
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "PEER", "PRIVATE_KEY");
return;
}
- if (NULL == (priv = GNUNET_CRYPTO_ecc_key_create_from_file (fn)))
+ if (NULL == (priv = GNUNET_CRYPTO_eddsa_key_create_from_file (fn)))
{
FPRINTF (stderr, _("Loading hostkey from `%s' failed.\n"), fn);
GNUNET_free (fn);
return;
}
GNUNET_free (fn);
- GNUNET_CRYPTO_ecc_key_get_public_for_signature (priv,
- &my_peer_identity.public_key);
+ GNUNET_CRYPTO_eddsa_key_get_public (priv,
+ &my_peer_identity.public_key);
GNUNET_free (priv);
}
tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &shutdown_task,
- NULL);
+ &shutdown_task,
+ NULL);
+}
+
+
+/**
+ * Main function that will be run by the scheduler.
+ *
+ * @param cls closure
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be NULL!)
+ * @param c configuration
+ */
+static void
+run (void *cls, char *const *args, const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *c)
+{
+ cfg = c;
+ if ( (NULL != args[0]) &&
+ (NULL == put_uri) &&
+ (args[0] == strcasestr (args[0], "gnunet://hello/")) )
+ {
+ put_uri = GNUNET_strdup (args[0]);
+ args++;
+ }
+ if (NULL != args[0])
+ {
+ FPRINTF (stderr,
+ _("Invalid command line argument `%s'\n"),
+ args[0]);
+ return;
+ }
+
+ GNUNET_CLIENT_service_test ("peerinfo", cfg, GNUNET_TIME_UNIT_SECONDS,
+ &testservice_task, (void *) cfg);
}
{
get_self = GNUNET_NO;
if (be_quiet)
- printf ("%s\n",
+ printf ("%s\n",
GNUNET_i2s_full (&my_peer_identity));
else
printf (_("I am peer `%s'.\n"),
{'i', "info", NULL,
gettext_noop ("list all known peers"),
0, &GNUNET_GETOPT_set_one, &get_info},
- {'d', "dump-hello", NULL,
- gettext_noop ("dump hello to file"),
- 1, &GNUNET_GETOPT_set_string, &dump_hello},
+ {'d', "dump-hello", NULL,
+ gettext_noop ("dump hello to file"),
+ 1, &GNUNET_GETOPT_set_string, &dump_hello},
{'g', "get-hello", NULL,
gettext_noop ("also output HELLO uri(s)"),
0, &GNUNET_GETOPT_set_one, &get_uri},