aboutsummaryrefslogtreecommitdiff
path: root/src/gns/gnunet-service-gns_resolver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns/gnunet-service-gns_resolver.c')
-rw-r--r--src/gns/gnunet-service-gns_resolver.c70
1 files changed, 55 insertions, 15 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 9792aff58..4b2641818 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -1232,13 +1232,14 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh,
1232{ 1232{
1233 size_t nlen; 1233 size_t nlen;
1234 char *res; 1234 char *res;
1235 const char *tld;
1235 struct AuthorityChain *ac; 1236 struct AuthorityChain *ac;
1236 int af; 1237 int af;
1238 struct GNUNET_CRYPTO_EcdsaPublicKey zone;
1237 1239
1238 nlen = strlen (cname); 1240 nlen = strlen (cname);
1239 if ((nlen > 2) && 1241 tld = GNS_get_tld (cname);
1240 (0 == strcmp (".+", 1242 if (0 == strcmp ("+", tld))
1241 &cname[nlen - 2])))
1242 { 1243 {
1243 /* CNAME resolution continues relative to current domain */ 1244 /* CNAME resolution continues relative to current domain */
1244 if (0 == rh->name_resolution_pos) 1245 if (0 == rh->name_resolution_pos)
@@ -1272,6 +1273,42 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh,
1272 rh); 1273 rh);
1273 return; 1274 return;
1274 } 1275 }
1276 if (GNUNET_OK == GNUNET_GNSRECORD_zkey_to_pkey (tld, &zone))
1277 {
1278 /* CNAME resolution continues relative to current domain */
1279 if (0 == rh->name_resolution_pos)
1280 {
1281 GNUNET_asprintf (&res,
1282 "%.*s",
1283 strlen (cname) - (strlen (tld) + 1),
1284 cname);
1285 }
1286 else
1287 {
1288 GNUNET_asprintf (&res,
1289 "%.*s.%.*s",
1290 (int) rh->name_resolution_pos,
1291 rh->name,
1292 (int) strlen (cname) - (strlen(tld)+1),
1293 cname);
1294 }
1295 rh->name_resolution_pos = strlen (res);
1296 GNUNET_free (rh->name);
1297 rh->name = res;
1298 ac = GNUNET_new (struct AuthorityChain);
1299 ac->rh = rh;
1300 ac->gns_authority = GNUNET_YES;
1301 ac->authority_info.gns_authority = zone;
1302 ac->label = resolver_lookup_get_next_label (rh);
1303 /* add AC to tail */
1304 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
1305 rh->ac_tail,
1306 ac);
1307 rh->task_id = GNUNET_SCHEDULER_add_now (&recursive_resolution,
1308 rh);
1309 return;
1310 }
1311
1275 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1312 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1276 "Got CNAME `%s' from GNS for `%s'\n", 1313 "Got CNAME `%s' from GNS for `%s'\n",
1277 cname, 1314 cname,
@@ -1766,8 +1803,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1766 continue; 1803 continue;
1767 } 1804 }
1768 tld = GNS_get_tld (ip); 1805 tld = GNS_get_tld (ip);
1769 if (0 != strcmp (tld, 1806 if ((0 != strcmp (tld, "+")) &&
1770 "+")) 1807 (GNUNET_OK != GNUNET_GNSRECORD_zkey_to_pkey (tld, &zone)))
1771 { 1808 {
1772 /* 'ip' is a DNS name */ 1809 /* 'ip' is a DNS name */
1773 gp = GNUNET_new (struct Gns2DnsPending); 1810 gp = GNUNET_new (struct Gns2DnsPending);
@@ -1790,16 +1827,19 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1790 ac->authority_info.dns_authority.gp_tail, 1827 ac->authority_info.dns_authority.gp_tail,
1791 gp); 1828 gp);
1792 gp->rh = GNUNET_new (struct GNS_ResolverHandle); 1829 gp->rh = GNUNET_new (struct GNS_ResolverHandle);
1793 ip = translate_dot_plus (rh, 1830 if (0 == strcmp (tld, "+"))
1794 ip);
1795 tld = GNS_get_tld (ip);
1796 if (GNUNET_OK !=
1797 GNUNET_GNSRECORD_zkey_to_pkey (tld,
1798 &zone))
1799 { 1831 {
1800 GNUNET_break_op (0); 1832 ip = translate_dot_plus (rh,
1801 GNUNET_free (ip); 1833 ip);
1802 continue; 1834 tld = GNS_get_tld (ip);
1835 if (GNUNET_OK !=
1836 GNUNET_GNSRECORD_zkey_to_pkey (tld,
1837 &zone))
1838 {
1839 GNUNET_break_op (0);
1840 GNUNET_free (ip);
1841 continue;
1842 }
1803 } 1843 }
1804 gp->rh->authority_zone = zone; 1844 gp->rh->authority_zone = zone;
1805 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1845 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1845,7 +1885,7 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1845 if (IDNA_SUCCESS != idna_to_ascii_8z (tmp, &ac->label, IDNA_ALLOW_UNASSIGNED)) 1885 if (IDNA_SUCCESS != idna_to_ascii_8z (tmp, &ac->label, IDNA_ALLOW_UNASSIGNED))
1846 { 1886 {
1847 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1887 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1848 _("Name `%s' cannot be converted to IDNA."), tmp); 1888 _ ("Name `%s' cannot be converted to IDNA."), tmp);
1849 return GNUNET_SYSERR; 1889 return GNUNET_SYSERR;
1850 } 1890 }
1851 GNUNET_free (tmp); 1891 GNUNET_free (tmp);