/**
* How long do we wait for the NAT test to report success?
+ * Should match NAT_SERVER_TIMEOUT in 'nat_test.c'.
*/
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
+#define RESOLUTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
/**
* Which peer should we connect to?
*/
static GNUNET_SCHEDULER_TaskIdentifier end;
+static struct GNUNET_CONTAINER_MultiHashMap *peers;
+
/**
* Selected level of verbosity.
*/
adv_port = bnd_port;
if (NULL == resolver)
resolver =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-resolver",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-resolver",
"gnunet-service-resolver", NULL);
resolver_users++;
GNUNET_RESOLVER_connect (cfg);
traffic_received += ntohs (message->size);
}
+struct ResolutionContext
+{
+ struct GNUNET_HELLO_Address *addrcp;
+
+ int printed;
+};
+
void
process_string (void *cls, const char *address)
{
- struct GNUNET_HELLO_Address *addrcp = cls;
+ struct ResolutionContext *rc = cls;
+ struct GNUNET_HELLO_Address *addrcp = rc->addrcp;
- if ((address != NULL))
+ if (address != NULL)
{
FPRINTF (stdout, _("Peer `%s': %s %s\n"), GNUNET_i2s (&addrcp->peer), addrcp->transport_name, address);
+ rc->printed = GNUNET_YES;
}
else
{
/* done */
- GNUNET_free (addrcp);
+ if (GNUNET_NO == rc->printed)
+ FPRINTF (stdout, _("Peer `%s': %s <unable to resolve address>\n"), GNUNET_i2s (&addrcp->peer), addrcp->transport_name);
+ GNUNET_free (rc->addrcp);
+ GNUNET_free (rc);
}
}
const struct GNUNET_HELLO_Address *address)
{
const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+ struct ResolutionContext *rc;
if (peer == NULL)
{
return;
}
+ rc = GNUNET_malloc(sizeof (struct ResolutionContext));
+ rc->addrcp = GNUNET_HELLO_address_copy(address);
+ rc->printed = GNUNET_NO;
+
+ GNUNET_assert (NULL != rc);
+
/* Resolve address to string */
GNUNET_TRANSPORT_address_to_string (cfg, address, numeric,
- GNUNET_TIME_UNIT_MINUTES, &process_string,
- GNUNET_HELLO_address_copy(address));
+ RESOLUTION_TIMEOUT, &process_string,
+ rc);
}
{
struct GNUNET_TRANSPORT_PeerIterateContext *pic = cls;
- GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pic);
+ GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pic);
+
+ if (NULL != peers)
+ {
+ GNUNET_CONTAINER_multihashmap_destroy (peers);
+ peers = NULL;
+ }
}
}
if (iterate_connections)
{
+ peers = GNUNET_CONTAINER_multihashmap_create (20);
GNUNET_TRANSPORT_peer_get_active_addresses (cfg, NULL, GNUNET_YES,
- GNUNET_TIME_UNIT_MINUTES,
+ TIMEOUT,
&process_address, (void *) cfg);
}
if (monitor_connections)