[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16309 - gnunet/src/vpn
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16309 - gnunet/src/vpn |
Date: |
Tue, 2 Aug 2011 09:34:33 +0200 |
Author: toelke
Date: 2011-08-02 09:34:33 +0200 (Tue, 02 Aug 2011)
New Revision: 16309
Modified:
gnunet/src/vpn/gnunet-service-dns.c
Log:
really reuse the dns-tunnel
Modified: gnunet/src/vpn/gnunet-service-dns.c
===================================================================
--- gnunet/src/vpn/gnunet-service-dns.c 2011-08-02 07:34:30 UTC (rev 16308)
+++ gnunet/src/vpn/gnunet-service-dns.c 2011-08-02 07:34:33 UTC (rev 16309)
@@ -48,6 +48,8 @@
*/
static struct GNUNET_MESH_Tunnel* dns_tunnel;
+char dns_tunnel_connected;
+
/**
* The UDP-Socket through which DNS-Resolves will be sent if they are not to be
* sent through gnunet. The port of this socket will not be hijacked.
@@ -230,6 +232,7 @@
struct GNUNET_MessageHeader *hdr = buf;
uint32_t *sz = cls;
struct GNUNET_MESH_Tunnel **tunnel = (struct GNUNET_MESH_Tunnel**)(sz+1);
+ GNUNET_MESH_tunnel_set_data(*tunnel, NULL);
struct dns_pkt *dns = (struct dns_pkt *) (tunnel + 1);
hdr->type = htons (GNUNET_MESSAGE_TYPE_REMOTE_ANSWER_DNS);
hdr->size = htons (*sz + sizeof (struct GNUNET_MessageHeader));
@@ -314,13 +317,18 @@
const struct GNUNET_TRANSPORT_ATS_Information *atsi
__attribute__ ((unused)))
{
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "mesh_connect called with %x, %x\n",
cls, peer);
+ return;
if (NULL == peer)
return;
struct tunnel_cls *cls_ = (struct tunnel_cls *) cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connected to peer %s, sending query with id %d\n",
- GNUNET_i2s (peer), ntohs (cls_->dns.s.id));
+ if ((struct GNUNET_PeerIdentity*)1 != peer)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Connected to peer %s, sending query with id %d\n",
+ GNUNET_i2s (peer), ntohs (cls_->dns.s.id));
+ dns_tunnel_connected = 1;
+
if (NULL == GNUNET_MESH_tunnel_get_data (cls_->tunnel))
{
struct GNUNET_MESH_TransmitHandle *th =
@@ -351,7 +359,16 @@
}
}
+static void
+call_mesh_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+ return;
+ mesh_connect (cls, (struct GNUNET_PeerIdentity *) 1, NULL);
+}
+
+
static void
send_mesh_query (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
@@ -360,13 +377,18 @@
struct tunnel_cls *cls_ = (struct tunnel_cls*)cls;
- if (NULL == dns_tunnel)
- dns_tunnel = GNUNET_MESH_peer_request_connect_by_type(mesh_handle,
+ if (NULL == dns_tunnel || dns_tunnel_connected == 0)
+ {
+ dns_tunnel = GNUNET_MESH_peer_request_connect_by_type(mesh_handle,
GNUNET_TIME_UNIT_HOURS,
GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER,
mesh_connect,
NULL,
cls_);
+ }
+ else
+ GNUNET_SCHEDULER_add_now(call_mesh_connect, cls_);
+
cls_->tunnel = dns_tunnel;
remote_pending[cls_->dns.s.id] = cls_;
}
@@ -411,6 +433,8 @@
/* TODo: size check */
struct dns_pkt *dns = (struct dns_pkt *) (message + 1);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "received dns-answer via %x,
id=%d/%\nd\n", tunnel, dns->s.id, ntohs(dns->s.id));
+
/* They sent us a packet we were not waiting for */
if (remote_pending[dns->s.id] == NULL
|| remote_pending[dns->s.id]->tunnel != tunnel)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16309 - gnunet/src/vpn,
gnunet <=