aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-09-27 13:26:13 +0000
committerChristian Grothoff <christian@grothoff.org>2012-09-27 13:26:13 +0000
commit7f0beb27efe87c4e78798470a9f3226bdd34c12f (patch)
treed34b1bac6b3efa28d6326b9b1cde02c15ca68873 /src/gns
parent8323699ba0ce8915d9251d687c825955144161f5 (diff)
downloadgnunet-7f0beb27efe87c4e78798470a9f3226bdd34c12f.tar.gz
gnunet-7f0beb27efe87c4e78798470a9f3226bdd34c12f.zip
-fix tld guessing code
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gnunet-dns2gns.c74
1 files changed, 28 insertions, 46 deletions
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c
index 67f7e4ac1..71511c84a 100644
--- a/src/gns/gnunet-dns2gns.c
+++ b/src/gns/gnunet-dns2gns.c
@@ -120,12 +120,12 @@ static GNUNET_SCHEDULER_TaskIdentifier t4;
120static GNUNET_SCHEDULER_TaskIdentifier t6; 120static GNUNET_SCHEDULER_TaskIdentifier t6;
121 121
122/** 122/**
123 * DNS suffix 123 * DNS suffix, suffix of this gateway in DNS; defaults to '.zkey.eu'
124 */ 124 */
125static char *dns_suffix; 125static char *dns_suffix;
126 126
127/** 127/**
128 * FCFS suffix 128 * FCFS suffix, suffix of FCFS-authority in DNS; defaults to 'fcfs.zkey.eu'.
129 */ 129 */
130static char *fcfs_suffix; 130static char *fcfs_suffix;
131 131
@@ -347,9 +347,12 @@ handle_request (struct GNUNET_NETWORK_Handle *lsock,
347 struct Request *request; 347 struct Request *request;
348 struct GNUNET_DNSPARSER_Packet *packet; 348 struct GNUNET_DNSPARSER_Packet *packet;
349 char *name; 349 char *name;
350 char *dot;
351 char *nname;
350 size_t name_len; 352 size_t name_len;
351 enum GNUNET_GNS_RecordType type; 353 enum GNUNET_GNS_RecordType type;
352 int use_gns; 354 int use_gns;
355 struct GNUNET_CRYPTO_ShortHashCode zone;
353 356
354 packet = GNUNET_DNSPARSER_parse (udp_msg, udp_msg_size); 357 packet = GNUNET_DNSPARSER_parse (udp_msg, udp_msg_size);
355 if (NULL == packet) 358 if (NULL == packet)
@@ -360,8 +363,8 @@ handle_request (struct GNUNET_NETWORK_Handle *lsock,
360 return; 363 return;
361 } 364 }
362 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 365 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
363 "Received request for %s with flags %u, #answers %d, #auth %d, #additional %d\n", 366 "Received request for `%s' with flags %u, #answers %d, #auth %d, #additional %d\n",
364 packet->queries[0].name, 367 packet->queries[0].name,
365 (unsigned int) packet->flags.query_or_response, 368 (unsigned int) packet->flags.query_or_response,
366 (int) packet->num_answers, 369 (int) packet->num_answers,
367 (int) packet->num_authority_records, 370 (int) packet->num_authority_records,
@@ -400,51 +403,30 @@ handle_request (struct GNUNET_NETWORK_Handle *lsock,
400 (0 == strcasecmp (dns_suffix, 403 (0 == strcasecmp (dns_suffix,
401 &name[name_len - strlen (dns_suffix)])) ) 404 &name[name_len - strlen (dns_suffix)])) )
402 { 405 {
403 /* 406 /* Test if '.zkey' was requested */
404 * FIXME: Here we want to query fcfs. But what is fcfs in our 407 name[name_len - strlen (dns_suffix)] = '\0';
405 * context?? -> we need a PKEY or name 408 dot = strrchr (name, (int) '.');
406 */ 409 if ( (NULL != dot) &&
407 if ( (name_len >= strlen (fcfs_suffix)) && 410 (GNUNET_OK ==
408 (0 == strcasecmp (fcfs_suffix, 411 GNUNET_CRYPTO_short_hash_from_string (dot + 1, &zone)) )
409 &name[name_len - strlen (fcfs_suffix)])) )
410 { 412 {
411 name[name_len - strlen (fcfs_suffix)] = '\0'; 413 /* valid '.zkey' name */
412 if (0 == strcmp (name, "")) 414 GNUNET_asprintf (&nname,
413 strcpy (name, GNUNET_GNS_TLD); 415 "%s.%s",
414 else 416 name,
415 { 417 GNUNET_GNS_TLD_ZKEY);
416 if (sizeof (name) < (strlen (GNUNET_GNS_TLD)+strlen (name))) 418 GNUNET_free (name);
417 { 419 name = nname;
418 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
419 "Name %s.%s is too long!\n",
420 name,
421 GNUNET_GNS_TLD);
422 GNUNET_DNSPARSER_free_packet (request->packet);
423 return;
424 }
425 sprintf (name, "%s.%s", name, GNUNET_GNS_TLD);
426 }
427 } 420 }
428 else 421 else
429 { 422 {
430 name[name_len - strlen (dns_suffix)] = '\0'; 423 /* try '.gads' name */
431 if (0 == strcmp (name, "")) 424 GNUNET_asprintf (&nname,
432 { 425 "%s.%s",
433 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 426 name,
434 "No zkey given!\n"); 427 GNUNET_GNS_TLD);
435 GNUNET_DNSPARSER_free_packet (request->packet); 428 GNUNET_free (name);
436 return; 429 name = nname;
437 }
438 if (sizeof (name) < (strlen (GNUNET_GNS_TLD_ZKEY)+strlen (name)))
439 {
440 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
441 "Name %s.%s is too long!\n",
442 name,
443 GNUNET_GNS_TLD);
444 GNUNET_DNSPARSER_free_packet (request->packet);
445 return;
446 }
447 sprintf (name, "%s.%s", name, GNUNET_GNS_TLD_ZKEY);
448 } 430 }
449 name_len = strlen (name); 431 name_len = strlen (name);
450 } 432 }