*/
int8_t destroy_later;
+ /**
+ * Handle to subsequent connection after proxy handshake completes,
+ */
+ struct GNUNET_CONNECTION_Handle *proxy_handshake;
+
};
GNUNET_break (GNUNET_NO == connection->dns_active);
GNUNET_break (NULL == connection->sock);
GNUNET_assert (NULL == connection->write_task);
+ GNUNET_assert (NULL == connection->proxy_handshake);
/* signal errors for jobs that used to wait on the connection */
connection->destroy_later = 1;
{
GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ap->sock));
GNUNET_free (ap);
- if ((NULL == connection->ap_head) && (GNUNET_NO == connection->dns_active))
+ if ((NULL == connection->ap_head) &&
+ (GNUNET_NO == connection->dns_active) &&
+ (NULL == connection->proxy_handshake))
connect_fail_continuation (connection);
return;
}
if (NULL == addr)
{
connection->dns_active = NULL;
- if ((NULL == connection->ap_head) && (NULL == connection->sock))
+ if ((NULL == connection->ap_head) &&
+ (NULL == connection->sock) &&
+ (NULL == connection->proxy_handshake))
connect_fail_continuation (connection);
return;
}
int
GNUNET_CONNECTION_check (struct GNUNET_CONNECTION_Handle *connection)
{
- if ((NULL != connection->ap_head) || (NULL != connection->dns_active))
+ if ((NULL != connection->ap_head) ||
+ (NULL != connection->dns_active) ||
+ (NULL != connection->proxy_handshake))
return GNUNET_YES; /* still trying to connect */
if ( (0 != connection->destroy_later) ||
(NULL == connection->sock) )
GNUNET_RESOLVER_request_cancel (connection->dns_active);
connection->dns_active = NULL;
}
+ if (NULL != connection->proxy_handshake)
+ {
+ /* GNUNET_CONNECTION_destroy (connection->proxy_handshake); */
+ connection->proxy_handshake->destroy_later = -1;
+ connection->proxy_handshake = NULL; /* Not leaked ??? */
+ }
while (NULL != (pos = connection->ap_head))
{
GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock));
connection);
return;
}
- if ((NULL == connection->dns_active) && (NULL == connection->ap_head))
+ if ((NULL == connection->dns_active) &&
+ (NULL == connection->ap_head) &&
+ (NULL == connection->proxy_handshake))
{
connection->receiver = NULL;
receiver (receiver_cls, NULL, 0, NULL, 0, ETIMEDOUT);
GNUNET_assert (NULL == connection->nth.timeout_task);
if ((NULL == connection->sock) &&
(NULL == connection->ap_head) &&
- (NULL == connection->dns_active))
+ (NULL == connection->dns_active) &&
+ (NULL == connection->proxy_handshake))
{
if (NULL != connection->write_task)
GNUNET_SCHEDULER_cancel (connection->write_task);
}
}
+
+/**
+ * Create a connection to be proxied using a given connection.
+ *
+ * @param cph connection to proxy server
+ * @return connection to be proxied
+ */
+struct GNUNET_CONNECTION_Handle *
+GNUNET_CONNECTION_create_proxied_from_handshake (struct GNUNET_CONNECTION_Handle *cph)
+{
+ struct GNUNET_CONNECTION_Handle * proxied = GNUNET_CONNECTION_create_from_existing(NULL);
+ proxied->proxy_handshake = cph;
+ return proxied;
+}
+
+
+/**
+ * Activate proxied connection and destroy initial proxy handshake connection.
+ * There must not be any pending requests for reading or writing to the
+ * proxy hadshake connection at this time.
+ *
+ * @param proxied connection connection to proxy server
+ */
+void
+GNUNET_CONNECTION_acivate_proxied (struct GNUNET_CONNECTION_Handle *proxied)
+{
+ struct GNUNET_CONNECTION_Handle *cph = proxied->proxy_handshake;
+ GNUNET_assert (NULL != cph);
+ GNUNET_assert (NULL == proxied->sock);
+ GNUNET_assert (NULL != cph->sock);
+ proxied->sock=cph->sock;
+ cph->sock=NULL;
+ GNUNET_CONNECTION_destroy (cph);
+}
+
+
/* end of connection.c */