save the dns-tunnel
authorPhilipp Tölke <toelke@in.tum.de>
Wed, 27 Jul 2011 07:28:10 +0000 (07:28 +0000)
committerPhilipp Tölke <toelke@in.tum.de>
Wed, 27 Jul 2011 07:28:10 +0000 (07:28 +0000)
src/vpn/gnunet-service-dns.c

index 168446156c8f78a493dc6bb34d6f7d8024541201..01ac890abbc8395b1082f36f9231a2bb3d4d0e7e 100644 (file)
 
 struct GNUNET_MESH_Handle *mesh_handle;
 
+/**
+ * The tunnel to send queries
+ */
+static struct GNUNET_MESH_Tunnel* dns_tunnel;
+
 /**
  * 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.
@@ -261,13 +266,14 @@ send_mesh_query (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   struct tunnel_cls *cls_ = (struct tunnel_cls*)cls;
 
-  cls_->tunnel = GNUNET_MESH_peer_request_connect_by_type(mesh_handle,
-                                           GNUNET_TIME_UNIT_HOURS,
-                                           GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER,
-                                           mesh_connect,
-                                           NULL,
-                                           cls_);
-
+  if (NULL == dns_tunnel)
+    dns_tunnel = GNUNET_MESH_peer_request_connect_by_type(mesh_handle,
+                                                          GNUNET_TIME_UNIT_HOURS,
+                                                          GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER,
+                                                          mesh_connect,
+                                                          NULL,
+                                                          cls_);
+  cls_->tunnel = dns_tunnel;
   remote_pending[cls_->dns.s.id] = cls_;
 }