diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-21 15:19:45 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-21 15:19:45 +0000 |
commit | 1980c195fb4b84015ffc65d5a107e30a19bb0daa (patch) | |
tree | 4ace8211f754bce6364d7ee8748161cf88d59e7c /src/gns/gnunet-service-gns_resolver.c | |
parent | 40c8383cbd3decba4d605d6f94b102a1ed18a825 (diff) | |
download | gnunet-1980c195fb4b84015ffc65d5a107e30a19bb0daa.tar.gz gnunet-1980c195fb4b84015ffc65d5a107e30a19bb0daa.zip |
-fix cnames #2448
Diffstat (limited to 'src/gns/gnunet-service-gns_resolver.c')
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 64 |
1 files changed, 45 insertions, 19 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index cfd6be5f3..045112eae 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -2757,6 +2757,7 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh, | |||
2757 | { | 2757 | { |
2758 | struct RecordLookupHandle* rlh; | 2758 | struct RecordLookupHandle* rlh; |
2759 | rlh = (struct RecordLookupHandle*) cls; | 2759 | rlh = (struct RecordLookupHandle*) cls; |
2760 | int s_len = 0; | ||
2760 | 2761 | ||
2761 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2762 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2762 | "GNS_PHASE_DELEGATE_NS-%llu: Resolution status: %d.\n", | 2763 | "GNS_PHASE_DELEGATE_NS-%llu: Resolution status: %d.\n", |
@@ -2783,16 +2784,44 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh, | |||
2783 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2784 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2784 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried CNAME in NS.\n", | 2785 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried CNAME in NS.\n", |
2785 | rh->id); | 2786 | rh->id); |
2786 | finish_lookup(rh, rlh, rd_count, rd); | 2787 | strcpy (rh->name, rh->authority_name); |
2787 | free_resolver_handle(rh); | 2788 | finish_lookup (rh, rlh, rd_count, rd); |
2789 | free_resolver_handle (rh); | ||
2788 | return; | 2790 | return; |
2789 | } | 2791 | } |
2790 | 2792 | ||
2791 | /* A CNAME can only occur alone */ | 2793 | /* A .+ CNAME */ |
2792 | GNUNET_assert (is_canonical ((char*)rd->data)); | 2794 | if (is_tld ((char*)rd->data, GNUNET_GNS_TLD_PLUS)) |
2793 | strcpy (rh->name, rd->data); | 2795 | { |
2794 | resolve_delegation_ns (rh); | 2796 | s_len = strlen (rd->data) - 2; |
2795 | return; | 2797 | memcpy (rh->name, rd->data, s_len); |
2798 | rh->name[s_len] = '\0'; | ||
2799 | resolve_delegation_ns (rh); | ||
2800 | return; | ||
2801 | } | ||
2802 | else if (is_tld ((char*)rd->data, GNUNET_GNS_TLD_ZKEY)) | ||
2803 | { | ||
2804 | gns_resolver_lookup_record (rh->authority, | ||
2805 | rh->private_local_zone, | ||
2806 | rlh->record_type, | ||
2807 | (char*)rd->data, | ||
2808 | rh->priv_key, | ||
2809 | rh->timeout, | ||
2810 | rh->only_cached, | ||
2811 | rlh->proc, | ||
2812 | rlh->proc_cls); | ||
2813 | GNUNET_free (rlh); | ||
2814 | free_resolver_handle (rh); | ||
2815 | return; | ||
2816 | } | ||
2817 | else | ||
2818 | { | ||
2819 | //Try DNS resolver | ||
2820 | strcpy (rh->dns_name, (char*)rd->data); | ||
2821 | resolve_dns_name (rh); | ||
2822 | return; | ||
2823 | } | ||
2824 | |||
2796 | } | 2825 | } |
2797 | else if (rh->status & RSL_DELEGATE_VPN) | 2826 | else if (rh->status & RSL_DELEGATE_VPN) |
2798 | { | 2827 | { |
@@ -3051,9 +3080,6 @@ process_delegation_result_ns (void* cls, | |||
3051 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3080 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
3052 | "GNS_PHASE_DELEGATE_NS-%llu: CNAME found.\n", | 3081 | "GNS_PHASE_DELEGATE_NS-%llu: CNAME found.\n", |
3053 | rh->id); | 3082 | rh->id); |
3054 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
3055 | "GNS_PHASE_DELEGATE_NS-%llu: new name to resolve: %s.\n", | ||
3056 | rh->id, rh->name); | ||
3057 | 3083 | ||
3058 | rh->status |= RSL_CNAME_FOUND; | 3084 | rh->status |= RSL_CNAME_FOUND; |
3059 | rh->proc (rh->proc_cls, rh, rd_count, rd); | 3085 | rh->proc (rh->proc_cls, rh, rd_count, rd); |
@@ -3219,15 +3245,15 @@ resolve_delegation_ns (struct ResolverHandle *rh) | |||
3219 | * @param cls the closure to pass to proc | 3245 | * @param cls the closure to pass to proc |
3220 | */ | 3246 | */ |
3221 | void | 3247 | void |
3222 | gns_resolver_lookup_record(struct GNUNET_CRYPTO_ShortHashCode zone, | 3248 | gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, |
3223 | struct GNUNET_CRYPTO_ShortHashCode pzone, | 3249 | struct GNUNET_CRYPTO_ShortHashCode pzone, |
3224 | uint32_t record_type, | 3250 | uint32_t record_type, |
3225 | const char* name, | 3251 | const char* name, |
3226 | struct GNUNET_CRYPTO_RsaPrivateKey *key, | 3252 | struct GNUNET_CRYPTO_RsaPrivateKey *key, |
3227 | struct GNUNET_TIME_Relative timeout, | 3253 | struct GNUNET_TIME_Relative timeout, |
3228 | int only_cached, | 3254 | int only_cached, |
3229 | RecordLookupProcessor proc, | 3255 | RecordLookupProcessor proc, |
3230 | void* cls) | 3256 | void* cls) |
3231 | { | 3257 | { |
3232 | struct ResolverHandle *rh; | 3258 | struct ResolverHandle *rh; |
3233 | struct RecordLookupHandle* rlh; | 3259 | struct RecordLookupHandle* rlh; |