diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-13 22:11:19 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-13 22:11:19 +0000 |
commit | 7a570eab7d64de8820c8aff49c60b3e04bebc3be (patch) | |
tree | 25142cf5b9ce76619a8a31a9a1d939b47e15ecb2 /src/gns/gnunet-dns2gns.c | |
parent | 0d06abffbedda6539848044dd3000b752bf15d57 (diff) | |
download | gnunet-7a570eab7d64de8820c8aff49c60b3e04bebc3be.tar.gz gnunet-7a570eab7d64de8820c8aff49c60b3e04bebc3be.zip |
-adapting gnunet-dns2gns to new API
Diffstat (limited to 'src/gns/gnunet-dns2gns.c')
-rw-r--r-- | src/gns/gnunet-dns2gns.c | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c index 8cef98489..55d6cc015 100644 --- a/src/gns/gnunet-dns2gns.c +++ b/src/gns/gnunet-dns2gns.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2012-2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -139,6 +139,16 @@ static char *dns_ip; | |||
139 | */ | 139 | */ |
140 | static unsigned int listen_port = 53; | 140 | static unsigned int listen_port = 53; |
141 | 141 | ||
142 | /** | ||
143 | * Which GNS zone do we translate incoming DNS requests to? | ||
144 | */ | ||
145 | static struct GNUNET_CRYPTO_EccPublicKey my_zone; | ||
146 | |||
147 | /** | ||
148 | * '-z' option with the main zone to use. | ||
149 | */ | ||
150 | static char *gns_zone_str; | ||
151 | |||
142 | 152 | ||
143 | /** | 153 | /** |
144 | * Task run on shutdown. Cleans up everything. | 154 | * Task run on shutdown. Cleans up everything. |
@@ -222,7 +232,7 @@ do_timeout (void *cls, | |||
222 | if (NULL != request->packet) | 232 | if (NULL != request->packet) |
223 | GNUNET_DNSPARSER_free_packet (request->packet); | 233 | GNUNET_DNSPARSER_free_packet (request->packet); |
224 | if (NULL != request->lookup) | 234 | if (NULL != request->lookup) |
225 | GNUNET_GNS_cancel_lookup_request (request->lookup); | 235 | GNUNET_GNS_lookup_cancel (request->lookup); |
226 | if (NULL != request->dns_lookup) | 236 | if (NULL != request->dns_lookup) |
227 | GNUNET_DNSSTUB_resolve_cancel (request->dns_lookup); | 237 | GNUNET_DNSSTUB_resolve_cancel (request->dns_lookup); |
228 | GNUNET_free (request); | 238 | GNUNET_free (request); |
@@ -230,8 +240,7 @@ do_timeout (void *cls, | |||
230 | 240 | ||
231 | 241 | ||
232 | /** | 242 | /** |
233 | * Iterator called on obtained result for a DNS | 243 | * Iterator called on obtained result for a DNS lookup |
234 | * lookup | ||
235 | * | 244 | * |
236 | * @param cls closure | 245 | * @param cls closure |
237 | * @param rs the request socket | 246 | * @param rs the request socket |
@@ -240,9 +249,9 @@ do_timeout (void *cls, | |||
240 | */ | 249 | */ |
241 | static void | 250 | static void |
242 | dns_result_processor (void *cls, | 251 | dns_result_processor (void *cls, |
243 | struct GNUNET_DNSSTUB_RequestSocket *rs, | 252 | struct GNUNET_DNSSTUB_RequestSocket *rs, |
244 | const struct GNUNET_TUN_DnsHeader *dns, | 253 | const struct GNUNET_TUN_DnsHeader *dns, |
245 | size_t r) | 254 | size_t r) |
246 | { | 255 | { |
247 | struct Request *request = cls; | 256 | struct Request *request = cls; |
248 | 257 | ||
@@ -453,9 +462,10 @@ handle_request (struct GNUNET_NETWORK_Handle *lsock, | |||
453 | type = packet->queries[0].type; | 462 | type = packet->queries[0].type; |
454 | request->lookup = GNUNET_GNS_lookup (gns, | 463 | request->lookup = GNUNET_GNS_lookup (gns, |
455 | name, | 464 | name, |
465 | &my_zone, | ||
456 | type, | 466 | type, |
457 | GNUNET_NO, | 467 | GNUNET_NO, |
458 | NULL, | 468 | NULL /* no shorten */, |
459 | &result_processor, | 469 | &result_processor, |
460 | request); | 470 | request); |
461 | } | 471 | } |
@@ -576,7 +586,17 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
576 | if (NULL == dns_ip) | 586 | if (NULL == dns_ip) |
577 | { | 587 | { |
578 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 588 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
579 | "No DNS server specified!\n"); | 589 | _("No DNS server specified!\n")); |
590 | return; | ||
591 | } | ||
592 | if ( (NULL == gns_zone_str) || | ||
593 | (GNUNET_OK != | ||
594 | GNUNET_CRYPTO_ecc_public_key_from_string (gns_zone_str, | ||
595 | strlen (gns_zone_str), | ||
596 | &my_zone)) ) | ||
597 | { | ||
598 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
599 | _("No valid GNS zone specified!\n")); | ||
580 | return; | 600 | return; |
581 | } | 601 | } |
582 | 602 | ||
@@ -587,11 +607,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
587 | if (NULL == (gns = GNUNET_GNS_connect (cfg))) | 607 | if (NULL == (gns = GNUNET_GNS_connect (cfg))) |
588 | return; | 608 | return; |
589 | if (NULL == (dns_stub = GNUNET_DNSSTUB_start (dns_ip))) | 609 | if (NULL == (dns_stub = GNUNET_DNSSTUB_start (dns_ip))) |
590 | { | 610 | { |
591 | GNUNET_GNS_disconnect (gns); | 611 | GNUNET_GNS_disconnect (gns); |
592 | gns = NULL; | 612 | gns = NULL; |
593 | return; | 613 | return; |
594 | } | 614 | } |
595 | listen_socket4 = GNUNET_NETWORK_socket_create (PF_INET, | 615 | listen_socket4 = GNUNET_NETWORK_socket_create (PF_INET, |
596 | SOCK_DGRAM, | 616 | SOCK_DGRAM, |
597 | IPPROTO_UDP); | 617 | IPPROTO_UDP); |
@@ -680,15 +700,18 @@ main (int argc, | |||
680 | {'d', "dns", "IP", | 700 | {'d', "dns", "IP", |
681 | gettext_noop ("IP of recursive DNS resolver to use (required)"), 1, | 701 | gettext_noop ("IP of recursive DNS resolver to use (required)"), 1, |
682 | &GNUNET_GETOPT_set_string, &dns_ip}, | 702 | &GNUNET_GETOPT_set_string, &dns_ip}, |
683 | {'s', "suffix", "SUFFIX", | ||
684 | gettext_noop ("Authoritative DNS suffix to use (optional); default: zkey.eu"), 1, | ||
685 | &GNUNET_GETOPT_set_string, &dns_suffix}, | ||
686 | {'f', "fcfs", "NAME", | 703 | {'f', "fcfs", "NAME", |
687 | gettext_noop ("Authoritative FCFS suffix to use (optional); default: fcfs.zkey.eu"), 1, | 704 | gettext_noop ("Authoritative FCFS suffix to use (optional); default: fcfs.zkey.eu"), 1, |
688 | &GNUNET_GETOPT_set_string, &fcfs_suffix}, | 705 | &GNUNET_GETOPT_set_string, &fcfs_suffix}, |
706 | {'s', "suffix", "SUFFIX", | ||
707 | gettext_noop ("Authoritative DNS suffix to use (optional); default: zkey.eu"), 1, | ||
708 | &GNUNET_GETOPT_set_string, &dns_suffix}, | ||
689 | {'p', "port", "UDPPORT", | 709 | {'p', "port", "UDPPORT", |
690 | gettext_noop ("UDP port to listen on for inbound DNS requests; default: 53"), 1, | 710 | gettext_noop ("UDP port to listen on for inbound DNS requests; default: 53"), 1, |
691 | &GNUNET_GETOPT_set_uint, &listen_port}, | 711 | &GNUNET_GETOPT_set_uint, &listen_port}, |
712 | {'z', "zone", "PUBLICKEY", | ||
713 | gettext_noop ("Public key of the GNS zone to use (required)"), 1, | ||
714 | &GNUNET_GETOPT_set_string, &gns_zone_str}, | ||
692 | GNUNET_GETOPT_OPTION_END | 715 | GNUNET_GETOPT_OPTION_END |
693 | }; | 716 | }; |
694 | int ret; | 717 | int ret; |