aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man/gnunet-dns2gns.17
-rw-r--r--src/gns/Makefile.am3
-rw-r--r--src/gns/gnunet-dns2gns.c131
3 files changed, 113 insertions, 28 deletions
diff --git a/doc/man/gnunet-dns2gns.1 b/doc/man/gnunet-dns2gns.1
index f60f40e7e..f4aa62802 100644
--- a/doc/man/gnunet-dns2gns.1
+++ b/doc/man/gnunet-dns2gns.1
@@ -15,6 +15,8 @@ Most users will not want to run an DNS to GADS proxy/gateway and thus will not n
15 15
16A DNS\-to\-GNS proxy using gnunet\-dns2gns is available at ".zkey.eu" 16A DNS\-to\-GNS proxy using gnunet\-dns2gns is available at ".zkey.eu"
17 17
18If you do not want to specify a public key and are the owner of the zone that gnunet\-dns2gns will use for GNS lookups, you need to first create a pseudonym (using "gnunet\-identity \-C NAME"), and then assign it to be used for the "dns2gns" service using "gnunet\-identity \-e NAME \-s dns2gns". After that, you can start the dns2gns service (possibly using gnunet\-arm) without specifying a public key using "\-z".
19
18.SH OPTIONS 20.SH OPTIONS
19.B 21.B
20.IP "\-c FILENAME, \-\-config=FILENAME" 22.IP "\-c FILENAME, \-\-config=FILENAME"
@@ -37,10 +39,13 @@ Authoritative DNS suffix to use. This is the name under which the GADS ".zkey"
37.B 39.B
38.IP "\-v, \-\-version" 40.IP "\-v, \-\-version"
39Print GNUnet version number. 41Print GNUnet version number.
42.B
43.IP "\-z PUBLICKEY, \-\-zone=PUBLICKEY"
44Use PUBLICKEY for the zone to resolve GNS names in. The PUBLICKEY must be encoded in the text format which can be obtained using gnunet\-ecc, seen in PKEY records and output by gnunet\-identity. If this option is not specified, the default ego associated by gnunet\-identity for the "dns2gns" subsystem will be used.
40 45
41 46
42.SH BUGS 47.SH BUGS
43Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <bug\-gnunet@gnu.org> 48Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <bug\-gnunet@gnu.org>
44 49
45.SH SEE ALSO 50.SH SEE ALSO
46gnunet\-gns\-fcfs(1), gnunet\-gns(1) 51gnunet\-gns\-fcfs(1), gnunet\-gns(1), gnunet\-identity(1)
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index 7f1ceab21..26d0cd4a2 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -86,12 +86,15 @@ gnunet_dns2gns_SOURCES = \
86gnunet_dns2gns_LDADD = \ 86gnunet_dns2gns_LDADD = \
87 $(top_builddir)/src/gns/libgnunetgns.la \ 87 $(top_builddir)/src/gns/libgnunetgns.la \
88 $(top_builddir)/src/util/libgnunetutil.la \ 88 $(top_builddir)/src/util/libgnunetutil.la \
89 $(top_builddir)/src/identity/libgnunetidentity.la \
89 $(top_builddir)/src/namestore/libgnunetnamestore.la \ 90 $(top_builddir)/src/namestore/libgnunetnamestore.la \
90 $(top_builddir)/src/dns/libgnunetdnsparser.la \ 91 $(top_builddir)/src/dns/libgnunetdnsparser.la \
91 $(top_builddir)/src/dns/libgnunetdnsstub.la \ 92 $(top_builddir)/src/dns/libgnunetdnsstub.la \
92 $(GN_LIBINTL) 93 $(GN_LIBINTL)
93gnunet_dns2gns_DEPENDENCIES = \ 94gnunet_dns2gns_DEPENDENCIES = \
95 $(top_builddir)/src/gns/libgnunetgns.la \
94 $(top_builddir)/src/util/libgnunetutil.la \ 96 $(top_builddir)/src/util/libgnunetutil.la \
97 $(top_builddir)/src/identity/libgnunetidentity.la \
95 $(top_builddir)/src/namestore/libgnunetnamestore.la \ 98 $(top_builddir)/src/namestore/libgnunetnamestore.la \
96 $(top_builddir)/src/dns/libgnunetdnsparser.la \ 99 $(top_builddir)/src/dns/libgnunetdnsparser.la \
97 $(top_builddir)/src/dns/libgnunetdnsstub.la \ 100 $(top_builddir)/src/dns/libgnunetdnsstub.la \
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c
index 509321eba..4b5c66e57 100644
--- a/src/gns/gnunet-dns2gns.c
+++ b/src/gns/gnunet-dns2gns.c
@@ -26,6 +26,7 @@
26#include <gnunet_util_lib.h> 26#include <gnunet_util_lib.h>
27#include <gnunet_dnsparser_lib.h> 27#include <gnunet_dnsparser_lib.h>
28#include <gnunet_gns_service.h> 28#include <gnunet_gns_service.h>
29#include <gnunet_identity_service.h>
29#include <gnunet_dnsstub_lib.h> 30#include <gnunet_dnsstub_lib.h>
30#include "gns.h" 31#include "gns.h"
31 32
@@ -149,6 +150,22 @@ static struct GNUNET_CRYPTO_EccPublicKey my_zone;
149 */ 150 */
150static char *gns_zone_str; 151static char *gns_zone_str;
151 152
153/**
154 * Configuration to use.
155 */
156static const struct GNUNET_CONFIGURATION_Handle *cfg;
157
158/**
159 * Connection to identity service.
160 */
161static struct GNUNET_IDENTITY_Handle *identity;
162
163/**
164 * Request for our ego.
165 */
166static struct GNUNET_IDENTITY_Operation *id_op;
167
168
152 169
153/** 170/**
154 * Task run on shutdown. Cleans up everything. 171 * Task run on shutdown. Cleans up everything.
@@ -557,34 +574,11 @@ read_dns6 (void *cls,
557 574
558 575
559/** 576/**
560 * Main function that will be run. 577 * Start DNS daemon.
561 *
562 * @param cls closure
563 * @param args remaining command-line arguments
564 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
565 * @param cfg configuration
566 */ 578 */
567static void 579static void
568run (void *cls, char *const *args, const char *cfgfile, 580run_dnsd ()
569 const struct GNUNET_CONFIGURATION_Handle *cfg)
570{ 581{
571 if (NULL == dns_ip)
572 {
573 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
574 _("No DNS server specified!\n"));
575 return;
576 }
577 if ( (NULL == gns_zone_str) ||
578 (GNUNET_OK !=
579 GNUNET_CRYPTO_ecc_public_key_from_string (gns_zone_str,
580 strlen (gns_zone_str),
581 &my_zone)) )
582 {
583 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
584 _("No valid GNS zone specified!\n"));
585 return;
586 }
587
588 if (NULL == dns_suffix) 582 if (NULL == dns_suffix)
589 dns_suffix = DNS_SUFFIX; 583 dns_suffix = DNS_SUFFIX;
590 if (NULL == fcfs_suffix) 584 if (NULL == fcfs_suffix)
@@ -665,13 +659,96 @@ run (void *cls, char *const *args, const char *cfgfile,
665 &read_dns6, 659 &read_dns6,
666 listen_socket6); 660 listen_socket6);
667 661
662}
663
664
665/**
666 * Method called to inform about the egos of this peer.
667 *
668 * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get,
669 * this function is only called ONCE, and 'NULL' being passed in
670 * @a ego does indicate an error (i.e. name is taken or no default
671 * value is known). If @a ego is non-NULL and if '*ctx'
672 * is set in those callbacks, the value WILL be passed to a subsequent
673 * call to the identity callback of #GNUNET_IDENTITY_connect (if
674 * that one was not NULL).
675 *
676 * @param cls closure, NULL
677 * @param ego ego handle
678 * @param ctx context for application to store data for this ego
679 * (during the lifetime of this process, initially NULL)
680 * @param name name assigned by the user for this ego,
681 * NULL if the user just deleted the ego and it
682 * must thus no longer be used
683 */
684static void
685identity_cb (void *cls,
686 struct GNUNET_IDENTITY_Ego *ego,
687 void **ctx,
688 const char *name)
689{
690 id_op = NULL;
691 if (NULL == ego)
692 {
693 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
694 _("No ego configured for `dns2gns` subsystem\n"));
695 return;
696 }
697 GNUNET_IDENTITY_ego_get_public_key (ego,
698 &my_zone);
699 run_dnsd ();
700}
701
702
703/**
704 * Main function that will be run.
705 *
706 * @param cls closure
707 * @param args remaining command-line arguments
708 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
709 * @param c configuration
710 */
711static void
712run (void *cls, char *const *args, const char *cfgfile,
713 const struct GNUNET_CONFIGURATION_Handle *c)
714{
715 cfg = c;
716
717 if (NULL == dns_ip)
718 {
719 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
720 _("No DNS server specified!\n"));
721 return;
722 }
668 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 723 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
669 &do_shutdown, NULL); 724 &do_shutdown, NULL);
725 if (NULL == gns_zone_str)
726 {
727 identity = GNUNET_IDENTITY_connect (cfg,
728 NULL, NULL);
729 id_op = GNUNET_IDENTITY_get (identity,
730 "dns2gns",
731 &identity_cb,
732 NULL);
733 return;
734 }
735 if ( (NULL == gns_zone_str) ||
736 (GNUNET_OK !=
737 GNUNET_CRYPTO_ecc_public_key_from_string (gns_zone_str,
738 strlen (gns_zone_str),
739 &my_zone)) )
740 {
741 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
742 _("No valid GNS zone specified!\n"));
743 GNUNET_SCHEDULER_shutdown ();
744 return;
745 }
746 run_dnsd ();
670} 747}
671 748
672 749
673/** 750/**
674 * The main function for the fcfs daemon. 751 * The main function for the dns2gns daemon.
675 * 752 *
676 * @param argc number of arguments from the command line 753 * @param argc number of arguments from the command line
677 * @param argv command line arguments 754 * @param argv command line arguments
@@ -695,7 +772,7 @@ main (int argc,
695 gettext_noop ("UDP port to listen on for inbound DNS requests; default: 53"), 1, 772 gettext_noop ("UDP port to listen on for inbound DNS requests; default: 53"), 1,
696 &GNUNET_GETOPT_set_uint, &listen_port}, 773 &GNUNET_GETOPT_set_uint, &listen_port},
697 {'z', "zone", "PUBLICKEY", 774 {'z', "zone", "PUBLICKEY",
698 gettext_noop ("Public key of the GNS zone to use (required)"), 1, 775 gettext_noop ("Public key of the GNS zone to use (overrides default)"), 1,
699 &GNUNET_GETOPT_set_string, &gns_zone_str}, 776 &GNUNET_GETOPT_set_string, &gns_zone_str},
700 GNUNET_GETOPT_OPTION_END 777 GNUNET_GETOPT_OPTION_END
701 }; 778 };