diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-06-07 16:17:04 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-06-07 16:17:14 +0200 |
commit | 3ec6a0f2b110771d09f407b47c3d56b2bcf12848 (patch) | |
tree | a847266fc8487e36668bbd12ba648305b78a5c76 /src | |
parent | 50e9c61954ebe7ec3bfde169249d49ac6d849687 (diff) | |
download | gnunet-3ec6a0f2b110771d09f407b47c3d56b2bcf12848.tar.gz gnunet-3ec6a0f2b110771d09f407b47c3d56b2bcf12848.zip |
add LEHO records to DNS record sets if we know them from GNS2DNS
Diffstat (limited to 'src')
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index c915c616a..809bde8f9 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -368,6 +368,12 @@ struct GNS_ResolverHandle | |||
368 | char *name; | 368 | char *name; |
369 | 369 | ||
370 | /** | 370 | /** |
371 | * Legacy Hostname to use if we encountered GNS2DNS record | ||
372 | * and thus can deduct the LEHO from that transition. | ||
373 | */ | ||
374 | char *leho; | ||
375 | |||
376 | /** | ||
371 | * DLL of results we got from DNS. | 377 | * DLL of results we got from DNS. |
372 | */ | 378 | */ |
373 | struct DnsResult *dns_result_head; | 379 | struct DnsResult *dns_result_head; |
@@ -960,6 +966,12 @@ dns_result_parser (void *cls, | |||
960 | af = AF_UNSPEC; | 966 | af = AF_UNSPEC; |
961 | break; | 967 | break; |
962 | } | 968 | } |
969 | if (NULL != rh->leho) | ||
970 | add_dns_result (rh, | ||
971 | GNUNET_TIME_UNIT_HOURS.rel_value_us, | ||
972 | GNUNET_GNSRECORD_TYPE_LEHO, | ||
973 | strlen (rh->leho), | ||
974 | rh->leho); | ||
963 | rh->std_resolve = GNUNET_RESOLVER_ip_get (rh->name, | 975 | rh->std_resolve = GNUNET_RESOLVER_ip_get (rh->name, |
964 | af, | 976 | af, |
965 | DNS_LOOKUP_TIMEOUT, | 977 | DNS_LOOKUP_TIMEOUT, |
@@ -974,8 +986,8 @@ dns_result_parser (void *cls, | |||
974 | /* convert from (parsed) DNS to (binary) GNS format! */ | 986 | /* convert from (parsed) DNS to (binary) GNS format! */ |
975 | rd_count = p->num_answers + p->num_authority_records + p->num_additional_records; | 987 | rd_count = p->num_answers + p->num_authority_records + p->num_additional_records; |
976 | { | 988 | { |
977 | struct GNUNET_GNSRECORD_Data rd[rd_count]; | 989 | struct GNUNET_GNSRECORD_Data rd[rd_count + 1]; /* +1 for LEHO */ |
978 | unsigned int skip; | 990 | int skip; |
979 | char buf[UINT16_MAX]; | 991 | char buf[UINT16_MAX]; |
980 | size_t buf_off; | 992 | size_t buf_off; |
981 | size_t buf_start; | 993 | size_t buf_start; |
@@ -1099,11 +1111,23 @@ dns_result_parser (void *cls, | |||
1099 | skip++; | 1111 | skip++; |
1100 | continue; | 1112 | continue; |
1101 | } | 1113 | } |
1114 | } /* end of for all records in answer */ | ||
1115 | if (NULL != rh->leho) | ||
1116 | { | ||
1117 | rd[rd_count - skip].record_type = GNUNET_GNSRECORD_TYPE_LEHO; | ||
1118 | rd[rd_count - skip].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | ||
1119 | rd[rd_count - skip].expiration_time = GNUNET_TIME_UNIT_HOURS.rel_value_us; | ||
1120 | rd[rd_count - skip].data = rh->leho; | ||
1121 | rd[rd_count - skip].data_size = strlen (rh->leho); | ||
1122 | skip--; /* skip one LESS */ | ||
1123 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1124 | "Adding LEHO %s\n", | ||
1125 | rh->leho); | ||
1102 | } | 1126 | } |
1103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1104 | "Returning DNS response for `%s' with %u answers\n", | 1128 | "Returning DNS response for `%s' with %u answers\n", |
1105 | rh->ac_tail->label, | 1129 | rh->ac_tail->label, |
1106 | (unsigned int) p->num_answers); | 1130 | (unsigned int) (rd_count - skip)); |
1107 | rh->proc (rh->proc_cls, | 1131 | rh->proc (rh->proc_cls, |
1108 | rd_count - skip, | 1132 | rd_count - skip, |
1109 | rd); | 1133 | rd); |
@@ -1172,6 +1196,7 @@ recursive_dns_resolution (struct GNS_ResolverHandle *rh) | |||
1172 | rh->original_dns_id = p->id; | 1196 | rh->original_dns_id = p->id; |
1173 | GNUNET_assert (NULL != ac->authority_info.dns_authority.dns_handle); | 1197 | GNUNET_assert (NULL != ac->authority_info.dns_authority.dns_handle); |
1174 | GNUNET_assert (NULL == rh->dns_request); | 1198 | GNUNET_assert (NULL == rh->dns_request); |
1199 | rh->leho = GNUNET_strdup (ac->label); | ||
1175 | rh->dns_request = GNUNET_DNSSTUB_resolve (ac->authority_info.dns_authority.dns_handle, | 1200 | rh->dns_request = GNUNET_DNSSTUB_resolve (ac->authority_info.dns_authority.dns_handle, |
1176 | dns_request, | 1201 | dns_request, |
1177 | dns_request_length, | 1202 | dns_request_length, |
@@ -2830,6 +2855,7 @@ GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh) | |||
2830 | dr); | 2855 | dr); |
2831 | GNUNET_free (dr); | 2856 | GNUNET_free (dr); |
2832 | } | 2857 | } |
2858 | GNUNET_free_non_null (rh->leho); | ||
2833 | GNUNET_free (rh->name); | 2859 | GNUNET_free (rh->name); |
2834 | GNUNET_free (rh); | 2860 | GNUNET_free (rh); |
2835 | } | 2861 | } |