diff options
Diffstat (limited to 'src/dns/gnunet-service-dns.c')
-rw-r--r-- | src/dns/gnunet-service-dns.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c index 9feaa8413..39ce7f6e5 100644 --- a/src/dns/gnunet-service-dns.c +++ b/src/dns/gnunet-service-dns.c | |||
@@ -508,13 +508,11 @@ send_request_to_client (struct RequestRecord *rr, | |||
508 | * succeeded. | 508 | * succeeded. |
509 | * | 509 | * |
510 | * @param cls NULL | 510 | * @param cls NULL |
511 | * @param rs the socket that received the response | ||
512 | * @param dns the response itself | 511 | * @param dns the response itself |
513 | * @param r number of bytes in dns | 512 | * @param r number of bytes in dns |
514 | */ | 513 | */ |
515 | static void | 514 | static void |
516 | process_dns_result (void *cls, | 515 | process_dns_result (void *cls, |
517 | struct GNUNET_DNSSTUB_RequestSocket *rs, | ||
518 | const struct GNUNET_TUN_DnsHeader *dns, | 516 | const struct GNUNET_TUN_DnsHeader *dns, |
519 | size_t r); | 517 | size_t r); |
520 | 518 | ||
@@ -530,7 +528,6 @@ next_phase (struct RequestRecord *rr) | |||
530 | { | 528 | { |
531 | struct ClientRecord *cr; | 529 | struct ClientRecord *cr; |
532 | int nz; | 530 | int nz; |
533 | socklen_t salen; | ||
534 | 531 | ||
535 | if (rr->phase == RP_DROP) | 532 | if (rr->phase == RP_DROP) |
536 | { | 533 | { |
@@ -582,22 +579,27 @@ next_phase (struct RequestRecord *rr) | |||
582 | next_phase (rr); | 579 | next_phase (rr); |
583 | return; | 580 | return; |
584 | case RP_QUERY: | 581 | case RP_QUERY: |
582 | #if 0 | ||
583 | /* TODO: optionally, use this to forward DNS requests to the | ||
584 | *original* DNS server instead of the one we have configured... | ||
585 | (but then we need to create a fresh dnsstub for each request | ||
586 | *and* manage the timeout) */ | ||
585 | switch (rr->dst_addr.ss_family) | 587 | switch (rr->dst_addr.ss_family) |
586 | { | 588 | { |
587 | case AF_INET: | 589 | case AF_INET: |
588 | salen = sizeof (struct sockaddr_in); | 590 | salen = sizeof (struct sockaddr_in); |
591 | sa = (const struct sockaddr *) &rr->dst_addr; | ||
589 | break; | 592 | break; |
590 | case AF_INET6: | 593 | case AF_INET6: |
591 | salen = sizeof (struct sockaddr_in6); | 594 | salen = sizeof (struct sockaddr_in6); |
595 | sa = (const struct sockaddr *) &rr->dst_addr; | ||
592 | break; | 596 | break; |
593 | default: | 597 | default: |
594 | GNUNET_assert (0); | 598 | GNUNET_assert (0); |
595 | } | 599 | } |
596 | 600 | #endif | |
597 | rr->phase = RP_INTERNET_DNS; | 601 | rr->phase = RP_INTERNET_DNS; |
598 | rr->rs = GNUNET_DNSSTUB_resolve (dnsstub, | 602 | rr->rs = GNUNET_DNSSTUB_resolve (dnsstub, |
599 | (struct sockaddr*) &rr->dst_addr, | ||
600 | salen, | ||
601 | rr->payload, | 603 | rr->payload, |
602 | rr->payload_length, | 604 | rr->payload_length, |
603 | &process_dns_result, | 605 | &process_dns_result, |
@@ -714,13 +716,11 @@ client_disconnect_cb (void *cls, | |||
714 | * succeeded. | 716 | * succeeded. |
715 | * | 717 | * |
716 | * @param cls NULL | 718 | * @param cls NULL |
717 | * @param rs the socket that received the response | ||
718 | * @param dns the response itself | 719 | * @param dns the response itself |
719 | * @param r number of bytes in dns | 720 | * @param r number of bytes in dns |
720 | */ | 721 | */ |
721 | static void | 722 | static void |
722 | process_dns_result (void *cls, | 723 | process_dns_result (void *cls, |
723 | struct GNUNET_DNSSTUB_RequestSocket *rs, | ||
724 | const struct GNUNET_TUN_DnsHeader *dns, | 724 | const struct GNUNET_TUN_DnsHeader *dns, |
725 | size_t r) | 725 | size_t r) |
726 | { | 726 | { |
@@ -733,8 +733,7 @@ process_dns_result (void *cls, | |||
733 | return; /* ignore */ | 733 | return; /* ignore */ |
734 | 734 | ||
735 | rr = &requests[dns->id]; | 735 | rr = &requests[dns->id]; |
736 | if ( (rr->phase != RP_INTERNET_DNS) || | 736 | if (rr->phase != RP_INTERNET_DNS) |
737 | (rr->rs != rs) ) | ||
738 | { | 737 | { |
739 | /* unexpected / bogus reply */ | 738 | /* unexpected / bogus reply */ |
740 | GNUNET_STATISTICS_update (stats, | 739 | GNUNET_STATISTICS_update (stats, |
@@ -1055,8 +1054,6 @@ run (void *cls, | |||
1055 | char *ipv4mask; | 1054 | char *ipv4mask; |
1056 | char *ipv6addr; | 1055 | char *ipv6addr; |
1057 | char *ipv6prefix; | 1056 | char *ipv6prefix; |
1058 | struct in_addr dns_exit4; | ||
1059 | struct in6_addr dns_exit6; | ||
1060 | char *dns_exit; | 1057 | char *dns_exit; |
1061 | char *binary; | 1058 | char *binary; |
1062 | int nortsetup; | 1059 | int nortsetup; |
@@ -1065,24 +1062,26 @@ run (void *cls, | |||
1065 | stats = GNUNET_STATISTICS_create ("dns", cfg); | 1062 | stats = GNUNET_STATISTICS_create ("dns", cfg); |
1066 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, | 1063 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, |
1067 | cls); | 1064 | cls); |
1065 | dnsstub = GNUNET_DNSSTUB_start (128); | ||
1066 | /* TODO: support multiple DNS_EXIT servers being configured */ | ||
1067 | /* TODO: see above TODO on using DNS server from original packet. | ||
1068 | Not sure which is best... */ | ||
1068 | dns_exit = NULL; | 1069 | dns_exit = NULL; |
1069 | if ( ( (GNUNET_OK != | 1070 | if ( (GNUNET_OK != |
1070 | GNUNET_CONFIGURATION_get_value_string (cfg, | 1071 | GNUNET_CONFIGURATION_get_value_string (cfg, |
1071 | "dns", | 1072 | "dns", |
1072 | "DNS_EXIT", | 1073 | "DNS_EXIT", |
1073 | &dns_exit)) || | 1074 | &dns_exit)) || |
1074 | ( (1 != inet_pton (AF_INET, dns_exit, &dns_exit4)) && | 1075 | (GNUNET_OK != |
1075 | (1 != inet_pton (AF_INET6, dns_exit, &dns_exit6)) ) ) ) | 1076 | GNUNET_DNSSTUB_add_dns_ip (dnsstub, |
1077 | dns_exit)) ) | ||
1076 | { | 1078 | { |
1077 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | 1079 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, |
1078 | "dns", | 1080 | "dns", |
1079 | "DNS_EXIT", | 1081 | "DNS_EXIT", |
1080 | _("need a valid IPv4 or IPv6 address\n")); | 1082 | _("need a valid IPv4 or IPv6 address\n")); |
1081 | GNUNET_free_non_null (dns_exit); | 1083 | GNUNET_free_non_null (dns_exit); |
1082 | dns_exit = NULL; | ||
1083 | } | 1084 | } |
1084 | dnsstub = GNUNET_DNSSTUB_start (dns_exit); | ||
1085 | GNUNET_free_non_null (dns_exit); | ||
1086 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-dns"); | 1085 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-dns"); |
1087 | if (GNUNET_YES != | 1086 | if (GNUNET_YES != |
1088 | GNUNET_OS_check_helper_binary (binary, | 1087 | GNUNET_OS_check_helper_binary (binary, |