aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gns/Makefile.am11
-rw-r--r--src/gns/gnunet-gns.c66
-rw-r--r--src/gns/nss/nss_gns_query.c3
3 files changed, 73 insertions, 7 deletions
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index 846507b6f..bb319ce6e 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -10,7 +10,17 @@ SUBDIRS = . $(NSS_SUBDIR)
10pkgdata_DATA = \ 10pkgdata_DATA = \
11 gnunet-gns-proxy-ca.template 11 gnunet-gns-proxy-ca.template
12 12
13if HAVE_LIBIDN
14 LIBIDN= -lidn
15else
16 LIBIDN=
17endif
13 18
19if HAVE_LIBIDN2
20 LIBIDN2= -lidn2
21else
22 LIBIDN2=
23endif
14 24
15EXTRA_DIST = \ 25EXTRA_DIST = \
16 test_gns_defaults.conf \ 26 test_gns_defaults.conf \
@@ -139,6 +149,7 @@ gnunet_gns_LDADD = \
139 libgnunetgns.la \ 149 libgnunetgns.la \
140 $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ 150 $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
141 $(top_builddir)/src/util/libgnunetutil.la \ 151 $(top_builddir)/src/util/libgnunetutil.la \
152 $(LIBIDN) $(LIBIDN2) \
142 $(GN_LIBINTL) 153 $(GN_LIBINTL)
143 154
144gnunet_gns_benchmark_SOURCES = \ 155gnunet_gns_benchmark_SOURCES = \
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index c3ba0a1f8..fe51013ed 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -23,12 +23,26 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#if HAVE_LIBIDN2
27#if HAVE_IDN2_H
28#include <idn2.h>
29#elif HAVE_IDN2_IDN2_H
30#include <idn2/idn2.h>
31#endif
32#elif HAVE_LIBIDN
33#if HAVE_IDNA_H
34#include <idna.h>
35#elif HAVE_IDN_IDNA_H
36#include <idn/idna.h>
37#endif
38#endif
26#include <gnunet_util_lib.h> 39#include <gnunet_util_lib.h>
27#include <gnunet_dnsparser_lib.h> 40#include <gnunet_dnsparser_lib.h>
28#include <gnunet_gnsrecord_lib.h> 41#include <gnunet_gnsrecord_lib.h>
29#include <gnunet_namestore_service.h> 42#include <gnunet_namestore_service.h>
30#include <gnunet_gns_service.h> 43#include <gnunet_gns_service.h>
31 44
45
32/** 46/**
33 * Configuration we are using. 47 * Configuration we are using.
34 */ 48 */
@@ -45,6 +59,16 @@ static struct GNUNET_GNS_Handle *gns;
45static char *lookup_name; 59static char *lookup_name;
46 60
47/** 61/**
62 * DNS IDNA name to lookup. (set if -d option is set)
63 */
64char *idna_name;
65
66/**
67 * DNS compatibility (name is given as DNS name, possible IDNA).
68 */
69static int dns_compat;
70
71/**
48 * record type to look up (-t option) 72 * record type to look up (-t option)
49 */ 73 */
50static char *lookup_type; 74static char *lookup_type;
@@ -108,6 +132,11 @@ do_shutdown (void *cls)
108 GNUNET_GNS_disconnect (gns); 132 GNUNET_GNS_disconnect (gns);
109 gns = NULL; 133 gns = NULL;
110 } 134 }
135 if (NULL != idna_name)
136 {
137 GNUNET_free (idna_name);
138 idna_name = NULL;
139 }
111} 140}
112 141
113 142
@@ -200,6 +229,7 @@ run (void *cls,
200 (void) cls; 229 (void) cls;
201 (void) args; 230 (void) args;
202 (void) cfgfile; 231 (void) cfgfile;
232 Idna_rc rc;
203 233
204 cfg = c; 234 cfg = c;
205 to_task = NULL; 235 to_task = NULL;
@@ -209,13 +239,32 @@ run (void *cls,
209 if (NULL != (colon = strchr (lookup_name, ':'))) 239 if (NULL != (colon = strchr (lookup_name, ':')))
210 *colon = '\0'; 240 *colon = '\0';
211 } 241 }
212 if (GNUNET_OK != GNUNET_DNSPARSER_check_name (lookup_name)) 242 /**
243 * If DNS compatibility is requested, we first verify that the
244 * lookup_name is in a DNS format. If yes, we convert it to UTF-8.
245 */
246 if (GNUNET_YES == dns_compat)
213 { 247 {
214 fprintf (stderr, 248 if (GNUNET_OK != GNUNET_DNSPARSER_check_name (lookup_name))
215 _ ("`%s' is not a valid domain name\n"), 249 {
216 lookup_name); 250 fprintf (stderr,
217 global_ret = 3; 251 _ ("`%s' is not a valid DNS domain name\n"),
218 return; 252 lookup_name);
253 global_ret = 3;
254 return;
255 }
256 if (IDNA_SUCCESS !=
257 (rc = idna_to_unicode_8z8z (lookup_name, &idna_name,
258 IDNA_ALLOW_UNASSIGNED)))
259 {
260 fprintf (stderr,
261 _ ("Failed to convert DNS IDNA name `%s' to UTF-8: %s\n"),
262 lookup_name,
263 idna_strerror (rc));
264 global_ret = 3;
265 return;
266 }
267 lookup_name = idna_name;
219 } 268 }
220 if (GNUNET_YES != 269 if (GNUNET_YES !=
221 GNUNET_CLIENT_test (cfg, 270 GNUNET_CLIENT_test (cfg,
@@ -299,6 +348,11 @@ main (int argc, char *const *argv)
299 "raw", 348 "raw",
300 gettext_noop ("No unneeded output"), 349 gettext_noop ("No unneeded output"),
301 &raw), 350 &raw),
351 GNUNET_GETOPT_option_flag ('d',
352 "dns",
353 gettext_noop (
354 "DNS Compatibility: Name is passed in IDNA instead of UTF-8"),
355 &dns_compat),
302 GNUNET_GETOPT_OPTION_END }; 356 GNUNET_GETOPT_OPTION_END };
303 int ret; 357 int ret;
304 358
diff --git a/src/gns/nss/nss_gns_query.c b/src/gns/nss/nss_gns_query.c
index 9ebdcb31f..c79ae61f7 100644
--- a/src/gns/nss/nss_gns_query.c
+++ b/src/gns/nss/nss_gns_query.c
@@ -71,7 +71,8 @@ gns_resolve_name (int af, const char *name, struct userdata *u)
71 if (0 == pid) 71 if (0 == pid)
72 { 72 {
73 char *argv[] = { "gnunet-gns", 73 char *argv[] = { "gnunet-gns",
74 "-r", 74 "-r", //Raw output for easier parsing
75 "-d", //DNS compatibility (allow IDNA names, no UTF-8)
75 "-t", 76 "-t",
76 (AF_INET6 == af) ? "AAAA" : "A", 77 (AF_INET6 == af) ? "AAAA" : "A",
77 "-u", 78 "-u",