diff options
author | Philipp Tölke <toelke@in.tum.de> | 2011-08-02 07:34:36 +0000 |
---|---|---|
committer | Philipp Tölke <toelke@in.tum.de> | 2011-08-02 07:34:36 +0000 |
commit | 8d05776bcb9f306821a4e1ae64550cf9e180591e (patch) | |
tree | 166e549e9ae16abde8485d31fe5a48b9249a66a3 /src/vpn/gnunet-service-dns.c | |
parent | ecc8c4da9b35b704b62ff0dc905dcd0a61f1886a (diff) | |
download | gnunet-8d05776bcb9f306821a4e1ae64550cf9e180591e.tar.gz gnunet-8d05776bcb9f306821a4e1ae64550cf9e180591e.zip |
Revert "really reuse the dns-tunnel"
This reverts commit 5e3c96a064cd8223fa50d14243c285578a7284c6.
Diffstat (limited to 'src/vpn/gnunet-service-dns.c')
-rw-r--r-- | src/vpn/gnunet-service-dns.c | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c index f0bbb5c79..ce27fe6a0 100644 --- a/src/vpn/gnunet-service-dns.c +++ b/src/vpn/gnunet-service-dns.c | |||
@@ -48,8 +48,6 @@ struct GNUNET_MESH_Handle *mesh_handle; | |||
48 | */ | 48 | */ |
49 | static struct GNUNET_MESH_Tunnel* dns_tunnel; | 49 | static struct GNUNET_MESH_Tunnel* dns_tunnel; |
50 | 50 | ||
51 | char dns_tunnel_connected; | ||
52 | |||
53 | /** | 51 | /** |
54 | * The UDP-Socket through which DNS-Resolves will be sent if they are not to be | 52 | * The UDP-Socket through which DNS-Resolves will be sent if they are not to be |
55 | * sent through gnunet. The port of this socket will not be hijacked. | 53 | * sent through gnunet. The port of this socket will not be hijacked. |
@@ -232,7 +230,6 @@ mesh_send_response (void *cls, size_t size, void *buf) | |||
232 | struct GNUNET_MessageHeader *hdr = buf; | 230 | struct GNUNET_MessageHeader *hdr = buf; |
233 | uint32_t *sz = cls; | 231 | uint32_t *sz = cls; |
234 | struct GNUNET_MESH_Tunnel **tunnel = (struct GNUNET_MESH_Tunnel**)(sz+1); | 232 | struct GNUNET_MESH_Tunnel **tunnel = (struct GNUNET_MESH_Tunnel**)(sz+1); |
235 | GNUNET_MESH_tunnel_set_data(*tunnel, NULL); | ||
236 | struct dns_pkt *dns = (struct dns_pkt *) (tunnel + 1); | 233 | struct dns_pkt *dns = (struct dns_pkt *) (tunnel + 1); |
237 | hdr->type = htons (GNUNET_MESSAGE_TYPE_REMOTE_ANSWER_DNS); | 234 | hdr->type = htons (GNUNET_MESSAGE_TYPE_REMOTE_ANSWER_DNS); |
238 | hdr->size = htons (*sz + sizeof (struct GNUNET_MessageHeader)); | 235 | hdr->size = htons (*sz + sizeof (struct GNUNET_MessageHeader)); |
@@ -317,17 +314,12 @@ mesh_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
317 | const struct GNUNET_TRANSPORT_ATS_Information *atsi | 314 | const struct GNUNET_TRANSPORT_ATS_Information *atsi |
318 | __attribute__ ((unused))) | 315 | __attribute__ ((unused))) |
319 | { | 316 | { |
320 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "mesh_connect called with %x, %x\n", cls, peer); | ||
321 | return; | ||
322 | if (NULL == peer) | 317 | if (NULL == peer) |
323 | return; | 318 | return; |
324 | struct tunnel_cls *cls_ = (struct tunnel_cls *) cls; | 319 | struct tunnel_cls *cls_ = (struct tunnel_cls *) cls; |
325 | if ((struct GNUNET_PeerIdentity*)1 != peer) | 320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 321 | "Connected to peer %s, sending query with id %d\n", |
327 | "Connected to peer %s, sending query with id %d\n", | 322 | GNUNET_i2s (peer), ntohs (cls_->dns.s.id)); |
328 | GNUNET_i2s (peer), ntohs (cls_->dns.s.id)); | ||
329 | |||
330 | dns_tunnel_connected = 1; | ||
331 | 323 | ||
332 | if (NULL == GNUNET_MESH_tunnel_get_data (cls_->tunnel)) | 324 | if (NULL == GNUNET_MESH_tunnel_get_data (cls_->tunnel)) |
333 | { | 325 | { |
@@ -359,15 +351,6 @@ mesh_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
359 | } | 351 | } |
360 | } | 352 | } |
361 | 353 | ||
362 | static void | ||
363 | call_mesh_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
364 | { | ||
365 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
366 | return; | ||
367 | |||
368 | mesh_connect (cls, (struct GNUNET_PeerIdentity *) 1, NULL); | ||
369 | } | ||
370 | |||
371 | 354 | ||
372 | static void | 355 | static void |
373 | send_mesh_query (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 356 | send_mesh_query (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -377,18 +360,13 @@ send_mesh_query (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
377 | 360 | ||
378 | struct tunnel_cls *cls_ = (struct tunnel_cls*)cls; | 361 | struct tunnel_cls *cls_ = (struct tunnel_cls*)cls; |
379 | 362 | ||
380 | if (NULL == dns_tunnel || dns_tunnel_connected == 0) | 363 | if (NULL == dns_tunnel) |
381 | { | 364 | dns_tunnel = GNUNET_MESH_peer_request_connect_by_type(mesh_handle, |
382 | dns_tunnel = GNUNET_MESH_peer_request_connect_by_type(mesh_handle, | ||
383 | GNUNET_TIME_UNIT_HOURS, | 365 | GNUNET_TIME_UNIT_HOURS, |
384 | GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER, | 366 | GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER, |
385 | mesh_connect, | 367 | mesh_connect, |
386 | NULL, | 368 | NULL, |
387 | cls_); | 369 | cls_); |
388 | } | ||
389 | else | ||
390 | GNUNET_SCHEDULER_add_now(call_mesh_connect, cls_); | ||
391 | |||
392 | cls_->tunnel = dns_tunnel; | 370 | cls_->tunnel = dns_tunnel; |
393 | remote_pending[cls_->dns.s.id] = cls_; | 371 | remote_pending[cls_->dns.s.id] = cls_; |
394 | } | 372 | } |
@@ -433,8 +411,6 @@ receive_mesh_answer (void *cls __attribute__((unused)), | |||
433 | /* TODo: size check */ | 411 | /* TODo: size check */ |
434 | struct dns_pkt *dns = (struct dns_pkt *) (message + 1); | 412 | struct dns_pkt *dns = (struct dns_pkt *) (message + 1); |
435 | 413 | ||
436 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "received dns-answer via %x, id=%d/%\nd\n", tunnel, dns->s.id, ntohs(dns->s.id)); | ||
437 | |||
438 | /* They sent us a packet we were not waiting for */ | 414 | /* They sent us a packet we were not waiting for */ |
439 | if (remote_pending[dns->s.id] == NULL | 415 | if (remote_pending[dns->s.id] == NULL |
440 | || remote_pending[dns->s.id]->tunnel != tunnel) | 416 | || remote_pending[dns->s.id]->tunnel != tunnel) |