diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-05-13 15:41:59 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-05-13 15:41:59 +0000 |
commit | cd0227d96dda179b959cdf752f7b2f72223b649c (patch) | |
tree | ab695b7b6c17ae74977f5b231c76287956e5676b /src/gns | |
parent | ec7e59f758092d07b3f8f3d5153ba5c84cd5edeb (diff) | |
download | gnunet-cd0227d96dda179b959cdf752f7b2f72223b649c.tar.gz gnunet-cd0227d96dda179b959cdf752f7b2f72223b649c.zip |
add logic to handle SRV/DANE names (#3003 and 2526) in GNS resolver
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index d1e958961..67f1902cd 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -23,12 +23,6 @@ | |||
23 | * @brief GNU Name System resolver logic | 23 | * @brief GNU Name System resolver logic |
24 | * @author Martin Schanzenbach | 24 | * @author Martin Schanzenbach |
25 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
26 | * | ||
27 | * TODO: | ||
28 | * - GNS: handle special SRV names --- no delegation, direct lookup; | ||
29 | * can likely be done in 'resolver_lookup_get_next_label'. (#3003) | ||
30 | * - revocation checks (use REVOCATION service!), (#3004) | ||
31 | * - DNAME support (#3005) | ||
32 | */ | 26 | */ |
33 | #include "platform.h" | 27 | #include "platform.h" |
34 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
@@ -601,7 +595,17 @@ memrchr (const void *s, | |||
601 | 595 | ||
602 | /** | 596 | /** |
603 | * Get the next, rightmost label from the name that we are trying to resolve, | 597 | * Get the next, rightmost label from the name that we are trying to resolve, |
604 | * and update the resolution position accordingly. | 598 | * and update the resolution position accordingly. Labels usually consist |
599 | * of up to 63 characters without a period ("."); however, we use a special | ||
600 | * convention to support SRV and TLSA records where the domain name | ||
601 | * includes an encoding for a service and protocol in the name. The | ||
602 | * syntax (see RFC 2782) here is "_Service._Proto.Name" and in this | ||
603 | * special case we include the "_Service._Proto" in the rightmost label. | ||
604 | * Thus, for "_443._tcp.foo.bar" we first return the label "bar" and then | ||
605 | * the label "_443._tcp.foo". The special case is detected by the | ||
606 | * presence of labels beginning with an underscore. Whenever a label | ||
607 | * begins with an underscore, it is combined with the label to its right | ||
608 | * (and the "." is preserved). | ||
605 | * | 609 | * |
606 | * @param rh handle to the resolution operation to get the next label from | 610 | * @param rh handle to the resolution operation to get the next label from |
607 | * @return NULL if there are no more labels | 611 | * @return NULL if there are no more labels |
@@ -615,7 +619,9 @@ resolver_lookup_get_next_label (struct GNS_ResolverHandle *rh) | |||
615 | 619 | ||
616 | if (0 == rh->name_resolution_pos) | 620 | if (0 == rh->name_resolution_pos) |
617 | return NULL; | 621 | return NULL; |
618 | dot = memrchr (rh->name, (int) '.', rh->name_resolution_pos); | 622 | dot = memrchr (rh->name, |
623 | (int) '.', | ||
624 | rh->name_resolution_pos); | ||
619 | if (NULL == dot) | 625 | if (NULL == dot) |
620 | { | 626 | { |
621 | /* done, this was the last one */ | 627 | /* done, this was the last one */ |
@@ -630,6 +636,16 @@ resolver_lookup_get_next_label (struct GNS_ResolverHandle *rh) | |||
630 | rp = dot + 1; | 636 | rp = dot + 1; |
631 | rh->name_resolution_pos = dot - rh->name; | 637 | rh->name_resolution_pos = dot - rh->name; |
632 | } | 638 | } |
639 | /* merge labels starting with underscore with label on the right (SRV/DANE case) */ | ||
640 | while ( (NULL != (dot = memrchr (rh->name, | ||
641 | (int) '.', | ||
642 | rh->name_resolution_pos))) && | ||
643 | ('_' == dot[1]) ) | ||
644 | { | ||
645 | len += rh->name_resolution_pos - (dot - rh->name) - 1; | ||
646 | rp = dot + 1; | ||
647 | rh->name_resolution_pos = dot - rh->name; | ||
648 | } | ||
633 | return GNUNET_strndup (rp, len); | 649 | return GNUNET_strndup (rp, len); |
634 | } | 650 | } |
635 | 651 | ||
@@ -1584,8 +1600,6 @@ handle_gns_resolution_result (void *cls, | |||
1584 | struct GNUNET_DNSPARSER_SrvRecord *srv; | 1600 | struct GNUNET_DNSPARSER_SrvRecord *srv; |
1585 | 1601 | ||
1586 | off = 0; | 1602 | off = 0; |
1587 | /* FIXME: passing rh->name here is is not necessarily what we want | ||
1588 | (SRV support not finished) */ | ||
1589 | srv = GNUNET_DNSPARSER_parse_srv (rh->name, | 1603 | srv = GNUNET_DNSPARSER_parse_srv (rh->name, |
1590 | rd[i].data, | 1604 | rd[i].data, |
1591 | rd[i].data_size, | 1605 | rd[i].data_size, |