diff options
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gnunet-service-gns_interceptor.c | 20 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 61 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.h | 17 |
3 files changed, 71 insertions, 27 deletions
diff --git a/src/gns/gnunet-service-gns_interceptor.c b/src/gns/gnunet-service-gns_interceptor.c index 15289fc35..7f34c93ce 100644 --- a/src/gns/gnunet-service-gns_interceptor.c +++ b/src/gns/gnunet-service-gns_interceptor.c | |||
@@ -210,9 +210,6 @@ reply_to_dns(void* cls, uint32_t rd_count, | |||
210 | packet->num_additional_records = 0; | 210 | packet->num_additional_records = 0; |
211 | packet->additional_records = NULL; | 211 | packet->additional_records = NULL; |
212 | GNUNET_DNSPARSER_free_packet(packet); | 212 | GNUNET_DNSPARSER_free_packet(packet); |
213 | //FIXME free resolver handle in resp functions in resolver! | ||
214 | //GNUNET_free((struct RecordLookupHandle*)rh->proc_cls); | ||
215 | //free_resolver_handle(rh); | ||
216 | GNUNET_free(ilh); | 213 | GNUNET_free(ilh); |
217 | } | 214 | } |
218 | 215 | ||
@@ -265,8 +262,6 @@ handle_dns_request(void *cls, | |||
265 | const char *request) | 262 | const char *request) |
266 | { | 263 | { |
267 | struct GNUNET_DNSPARSER_Packet *p; | 264 | struct GNUNET_DNSPARSER_Packet *p; |
268 | int i; | ||
269 | char *tldoffset; | ||
270 | 265 | ||
271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hijacked a DNS request...processing\n"); | 266 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hijacked a DNS request...processing\n"); |
272 | p = GNUNET_DNSPARSER_parse (request, request_length); | 267 | p = GNUNET_DNSPARSER_parse (request, request_length); |
@@ -310,20 +305,11 @@ handle_dns_request(void *cls, | |||
310 | 305 | ||
311 | 306 | ||
312 | /** | 307 | /** |
313 | * Check for .gnunet | 308 | * Check for .gnunet/.zkey |
314 | */ | 309 | */ |
315 | tldoffset = p->queries[0].name + strlen(p->queries[0].name) - 1; | ||
316 | |||
317 | for (i=0; i<strlen(p->queries[0].name); i++) | ||
318 | { | ||
319 | if (*(tldoffset-i) == '.') | ||
320 | break; | ||
321 | } | ||
322 | |||
323 | i--; | ||
324 | 310 | ||
325 | if ((i==strlen(GNUNET_GNS_TLD)-1) | 311 | if ((is_gnunet_tld(p->queries[0].name) == GNUNET_YES) || |
326 | && (0 == strcmp(tldoffset-i, GNUNET_GNS_TLD))) | 312 | (is_zkey_tld(p->queries[0].name) == GNUNET_YES)) |
327 | { | 313 | { |
328 | start_resolution_for_dns(rh, p, p->queries); | 314 | start_resolution_for_dns(rh, p, p->queries); |
329 | } | 315 | } |
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 1bbb431e0..4ac6cea36 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -1164,26 +1164,26 @@ pop_tld(char* name, char* dest) | |||
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | /** | 1166 | /** |
1167 | * Checks if name is in .zkey TLD | 1167 | * Checks if name is in tld |
1168 | * | 1168 | * |
1169 | * @param name the name to check | 1169 | * @param name the name to check |
1170 | * @return GNUNET_YES or GNUNET_NO | 1170 | * @return GNUNET_YES or GNUNET_NO |
1171 | */ | 1171 | */ |
1172 | int | 1172 | int |
1173 | is_zkey_tld(const char* name) | 1173 | is_tld(const char* name, const char* tld) |
1174 | { | 1174 | { |
1175 | int offset = 0; | 1175 | int offset = 0; |
1176 | 1176 | ||
1177 | if (strlen(name) <= strlen(GNUNET_GNS_TLD_ZKEY)) | 1177 | if (strlen(name) <= strlen(tld)) |
1178 | { | 1178 | { |
1179 | return GNUNET_NO; | 1179 | return GNUNET_NO; |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | offset = strlen(name)-strlen(GNUNET_GNS_TLD_ZKEY); | 1182 | offset = strlen(name)-strlen(tld); |
1183 | if (strcmp(name+offset, GNUNET_GNS_TLD_ZKEY) != 0) | 1183 | if (strcmp(name+offset, tld) != 0) |
1184 | { | 1184 | { |
1185 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1185 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1186 | "%s is not in zkey TLD\n", name); | 1186 | "%s is not in .%s TLD\n", name, tld); |
1187 | return GNUNET_NO; | 1187 | return GNUNET_NO; |
1188 | } | 1188 | } |
1189 | return GNUNET_YES; | 1189 | return GNUNET_YES; |
@@ -1823,6 +1823,7 @@ gns_resolver_shorten_name(GNUNET_HashCode zone, | |||
1823 | { | 1823 | { |
1824 | struct ResolverHandle *rh; | 1824 | struct ResolverHandle *rh; |
1825 | struct NameShortenHandle *nsh; | 1825 | struct NameShortenHandle *nsh; |
1826 | char string_hash[MAX_DNS_NAME_LENGTH]; //FIXME LABEL length when shorthash | ||
1826 | 1827 | ||
1827 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1828 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1828 | "Starting shorten for %s!\n", name); | 1829 | "Starting shorten for %s!\n", name); |
@@ -1843,10 +1844,50 @@ gns_resolver_shorten_name(GNUNET_HashCode zone, | |||
1843 | 1844 | ||
1844 | rh = GNUNET_malloc(sizeof (struct ResolverHandle)); | 1845 | rh = GNUNET_malloc(sizeof (struct ResolverHandle)); |
1845 | rh->authority = zone; | 1846 | rh->authority = zone; |
1846 | memset(rh->name, 0, | 1847 | |
1847 | strlen(name)-strlen(GNUNET_GNS_TLD)); | 1848 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1848 | memcpy(rh->name, name, | 1849 | "Checking for TLD...\n"); |
1849 | strlen(name)-strlen(GNUNET_GNS_TLD)-1); | 1850 | if (is_zkey_tld(name) == GNUNET_YES) |
1851 | { | ||
1852 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1853 | "TLD is zkey\n"); | ||
1854 | /** | ||
1855 | * This is a zkey tld | ||
1856 | * build hash and use as initial authority | ||
1857 | */ | ||
1858 | memset(rh->name, 0, | ||
1859 | strlen(name)-strlen(GNUNET_GNS_TLD_ZKEY)); | ||
1860 | memcpy(rh->name, name, | ||
1861 | strlen(name)-strlen(GNUNET_GNS_TLD_ZKEY) - 1); | ||
1862 | pop_tld(rh->name, string_hash); | ||
1863 | |||
1864 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1865 | "ZKEY is %s!\n", string_hash); | ||
1866 | |||
1867 | if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string(string_hash, | ||
1868 | &rh->authority)) | ||
1869 | { | ||
1870 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1871 | "Cannot convert ZKEY %s to hash!\n", string_hash); | ||
1872 | GNUNET_free(rh); | ||
1873 | GNUNET_free(nsh); | ||
1874 | proc(cls, name); | ||
1875 | return; | ||
1876 | } | ||
1877 | |||
1878 | } | ||
1879 | else | ||
1880 | { | ||
1881 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1882 | "TLD is gnunet\n"); | ||
1883 | /** | ||
1884 | * Presumably GNUNET tld | ||
1885 | */ | ||
1886 | memset(rh->name, 0, | ||
1887 | strlen(name)-strlen(GNUNET_GNS_TLD)); | ||
1888 | memcpy(rh->name, name, | ||
1889 | strlen(name)-strlen(GNUNET_GNS_TLD) - 1); | ||
1890 | } | ||
1850 | 1891 | ||
1851 | rh->authority_chain_head = GNUNET_malloc(sizeof(struct AuthorityChain)); | 1892 | rh->authority_chain_head = GNUNET_malloc(sizeof(struct AuthorityChain)); |
1852 | rh->authority_chain_tail = rh->authority_chain_head; | 1893 | rh->authority_chain_tail = rh->authority_chain_head; |
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h index fb612d72d..4f857825c 100644 --- a/src/gns/gnunet-service-gns_resolver.h +++ b/src/gns/gnunet-service-gns_resolver.h | |||
@@ -266,4 +266,21 @@ gns_resolver_get_authority(GNUNET_HashCode zone, | |||
266 | GetAuthorityResultProcessor proc, | 266 | GetAuthorityResultProcessor proc, |
267 | void* cls); | 267 | void* cls); |
268 | 268 | ||
269 | /** | ||
270 | * Generic function to check for TLDs | ||
271 | * | ||
272 | * @param name the name to check | ||
273 | * @param tld the tld to check | ||
274 | * @return GNUNET_YES or GNUNET_NO | ||
275 | */ | ||
276 | int | ||
277 | is_tld(const char* name, const char* tld); | ||
278 | |||
279 | /** | ||
280 | * Checks for gnunet/zkey | ||
281 | */ | ||
282 | #define is_gnunet_tld(name) is_tld(name, GNUNET_GNS_TLD) | ||
283 | #define is_zkey_tld(name) is_tld(name, GNUNET_GNS_TLD_ZKEY) | ||
284 | |||
285 | |||
269 | #endif | 286 | #endif |