/**
* How long until a HELLO verification attempt should time out?
+ * Must be rather small, otherwise a partially successful HELLO
+ * validation (some addresses working) might not be available
+ * before a client's request for a connection fails for good.
+ * Besides, if a single request to an address takes a long time,
+ * then the peer is unlikely worthwhile anyway.
*/
-#define HELLO_VERIFICATION_TIMEOUT GNUNET_TIME_UNIT_MINUTES
+#define HELLO_VERIFICATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
/**
* How often do we re-add (cheaper) plugins to our list of plugins
msize = ntohs (msg->size);
if (msize + tsize > size)
break;
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting message of type %u to client.\n",
+ ntohs (msg->type));
+#endif
client->message_queue_head = q->next;
if (q->next == NULL)
client->message_queue_tail = NULL;
struct ValidationList *pos;
struct ValidationList *prev;
struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Absolute first;
struct GNUNET_HELLO_Message *hello;
struct GNUNET_PeerIdentity pid;
struct NeighbourList *n;
/* finally, reschedule cleanup if needed; list is
ordered by timeout, so we need the last element... */
- pos = pending_validations;
- while ((pos != NULL) && (pos->next != NULL))
- pos = pos->next;
- if (NULL != pos)
- GNUNET_SCHEDULER_add_delayed (sched,
- GNUNET_NO,
- GNUNET_SCHEDULER_PRIORITY_IDLE,
- GNUNET_SCHEDULER_NO_TASK,
- GNUNET_TIME_absolute_get_remaining
- (pos->timeout), &cleanup_validation, NULL);
+ if (NULL != pending_validations)
+ {
+ first = pos->timeout;
+ pos = pending_validations;
+ while (pos != NULL)
+ {
+ first = GNUNET_TIME_absolute_min (first, pos->timeout);
+ pos = pos->next;
+ }
+ GNUNET_SCHEDULER_add_delayed (sched,
+ GNUNET_NO,
+ GNUNET_SCHEDULER_PRIORITY_IDLE,
+ GNUNET_SCHEDULER_NO_TASK,
+ GNUNET_TIME_absolute_get_remaining (first),
+ &cleanup_validation, NULL);
+ }
}
uint32_t challenge,
const char *sender_addr)
{
- int all_done;
+ unsigned int not_done;
int matched;
struct ValidationList *pos;
struct ValidationAddress *va;
GNUNET_i2s(peer));
return;
}
- all_done = GNUNET_YES;
+ not_done = 0;
matched = GNUNET_NO;
va = pos->addresses;
while (va != NULL)
{
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Confirmed validity of peer address.\n");
+ "Confirmed validity of address, peer `%4s' has address `%s'.\n",
+ GNUNET_i2s (peer),
+ GNUNET_a2s ((const struct sockaddr*) &va[1],
+ va->addr_len));
#endif
GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
_("Another peer saw us using the address `%s' via `%s'. If this is not plausible, this address should be listed in the configuration as implausible to avoid MiM attacks.\n"),
matched = GNUNET_YES;
}
if (va->ok != GNUNET_YES)
- all_done = GNUNET_NO;
+ not_done++;
va = va->next;
}
if (GNUNET_NO == matched)
("Received `%s' message but have no record of a matching `%s' message. Ignoring.\n"),
"PONG", "PING");
}
- if (GNUNET_YES == all_done)
+ if (0 == not_done)
{
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "All addresses validated, will now construct `%s' for `%4s'.\n",
+ "HELLO",
+ GNUNET_i2s (peer));
+#endif
pos->timeout.value = 0;
GNUNET_SCHEDULER_add_delayed (sched,
GNUNET_NO,
GNUNET_TIME_UNIT_ZERO,
&cleanup_validation, NULL);
}
+ else
+ {
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Still waiting for %u additional `%s' messages before constructing `%s' for `%4s'.\n",
+ not_done,
+ "PONG",
+ "HELLO",
+ GNUNET_i2s (peer));
+#endif
+ }
}
GNUNET_assert (GNUNET_OK ==
GNUNET_HELLO_get_id (chvc->hello,
&apeer));
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Ready to validate addresses from `%s' message for peer `%4s'\n",
+ "HELLO", GNUNET_i2s (&apeer));
+#endif
va = chvc->e->addresses;
while (va != NULL)
{
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Establishing `%s' connection to validate `%s' of `%4s'\n",
+ "Establishing `%s' connection to validate `%s' address `%s' of `%4s'\n",
va->transport_name,
"HELLO",
+ GNUNET_a2s ((const struct sockaddr*) &va[1],
+ va->addr_len),
GNUNET_i2s (&apeer));
#endif
tp = find_transport (va->transport_name);
va->ok = GNUNET_SYSERR;
va = va->next;
}
- if (chvc->e->next == NULL)
- GNUNET_SCHEDULER_add_delayed (sched,
- GNUNET_NO,
- GNUNET_SCHEDULER_PRIORITY_IDLE,
- GNUNET_SCHEDULER_NO_TASK,
- GNUNET_TIME_absolute_get_remaining
- (chvc->e->timeout), &cleanup_validation,
- NULL);
+ GNUNET_SCHEDULER_add_delayed (sched,
+ GNUNET_NO,
+ GNUNET_SCHEDULER_PRIORITY_IDLE,
+ GNUNET_SCHEDULER_NO_TASK,
+ GNUNET_TIME_absolute_get_remaining (chvc->e->timeout),
+ &cleanup_validation, NULL);
GNUNET_free (chvc);
}
#include "plugin_transport.h"
#include "transport.h"
-#define DEBUG_TCP GNUNET_NO
+#define DEBUG_TCP GNUNET_YES
/**
* After how long do we expire an address that we
void *addr;
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
- "Processing PING\n");
+ if (GNUNET_OK ==
+ GNUNET_SERVER_client_get_address (client,
+ (void **) &addr,
+ &addrlen))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+ "Processing `%s' from `%s'\n",
+ "PING",
+ GNUNET_a2s (addr, addrlen));
+ GNUNET_free (addr);
+ }
#endif
msize = ntohs (message->size);
if (msize < sizeof (struct ValidationChallengeMessage))
/**
- * Handle PING-message. If the plugin that gave us the message is
- * able to queue the PONG immediately, we only queue one PONG.
- * Otherwise we send at most TWO PONG messages, one via an unconfirmed
- * transport and one via a confirmed transport. Both addresses are
- * selected randomly among those available.
- *
- * @param plugin plugin that gave us the message
- * @param sender claimed sender of the PING
- * @param plugin_context context that might be used to send response
- * @param message the actual message
- */
-/**
- * We've received a PING from this peer via TCP.
- * Send back our PONG.
+ * Handle PONG-message.
*
- * @param cls closure
- * @param client identification of the client
+ * @param plugin handle for this plugin
+ * @param sender claimed sender of the PONG
* @param message the actual message
*/
static void
struct sockaddr_in6 v6;
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
- "Processing PONG\n");
+ struct sockaddr *claddr;
+
+ if (GNUNET_OK ==
+ GNUNET_SERVER_client_get_address (client,
+ (void**) &claddr,
+ &addrlen))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+ "Processing `%s' from `%s'\n",
+ "PONG",
+ GNUNET_a2s (claddr, addrlen));
+ GNUNET_free (claddr);
+ }
#endif
if (ntohs(message->size) < sizeof(struct ValidationChallengeResponse))
{
if (addr == NULL)
return;
- plugin->env->notify_address (plugin->env->cls,
- "tcp",
- addr, addrlen, GNUNET_TIME_UNIT_FOREVER_REL);
+ process_interfaces (plugin,
+ "<hostname>",
+ GNUNET_YES,
+ addr,
+ addrlen);
}