aboutsummaryrefslogtreecommitdiff
path: root/src/util/gnunet-service-resolver.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-06-20 08:50:35 +0000
committerChristian Grothoff <christian@grothoff.org>2011-06-20 08:50:35 +0000
commit61a008c4e471cd5081d5c2871949da779246a868 (patch)
tree95f07d0579ec84330e440a3325109cca45ddb809 /src/util/gnunet-service-resolver.c
parent0211530d9b0e02e31eecd14f8565b88de8210025 (diff)
downloadgnunet-61a008c4e471cd5081d5c2871949da779246a868.tar.gz
gnunet-61a008c4e471cd5081d5c2871949da779246a868.zip
make resolver test pass even if primary DNS is down
Diffstat (limited to 'src/util/gnunet-service-resolver.c')
-rw-r--r--src/util/gnunet-service-resolver.c49
1 files changed, 44 insertions, 5 deletions
diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c
index ee2cfb3b8..bffe2ce26 100644
--- a/src/util/gnunet-service-resolver.c
+++ b/src/util/gnunet-service-resolver.c
@@ -23,8 +23,6 @@
23 * @brief code to do DNS resolution 23 * @brief code to do DNS resolution
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
27#include <stdlib.h>
28#include "platform.h" 26#include "platform.h"
29#include "gnunet_disk_lib.h" 27#include "gnunet_disk_lib.h"
30#include "gnunet_getopt_lib.h" 28#include "gnunet_getopt_lib.h"
@@ -440,6 +438,7 @@ handle_get (void *cls,
440 uint16_t msize; 438 uint16_t msize;
441 const struct GNUNET_RESOLVER_GetMessage *msg; 439 const struct GNUNET_RESOLVER_GetMessage *msg;
442 const char *hostname; 440 const char *hostname;
441 const struct sockaddr *sa;
443 uint16_t size; 442 uint16_t size;
444 int direction; 443 int direction;
445 int domain; 444 int domain;
@@ -473,11 +472,51 @@ handle_get (void *cls,
473 } 472 }
474 else 473 else
475 { 474 {
476#if DEBUG_RESOLVER 475#if DEBUG_RESOLVER
476 char buf[INET6_ADDRSTRLEN] buf;
477#endif
478 sa = (const struct sockaddr*) &msg[1];
479 if (size < sizeof (struct sockaddr_in))
480 {
481 GNUNET_break (0);
482 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
483 return;
484 }
485 switch (sa->sa_family)
486 {
487 case AF_INET:
488 if (size != sizeof (struct sockaddr_in))
489 {
490 GNUNET_break (0);
491 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
492 return;
493 }
494#if DEBUG_RESOLVER
495 inet_ntop (AF_INET, sa, buf, size);
496#endif
497 break;
498 case AF_INET6:
499 if (size != sizeof (struct sockaddr_in6))
500 {
501 GNUNET_break (0);
502 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
503 return;
504 }
505#if DEBUG_RESOLVER
506 inet_ntop (AF_INET6, sa, buf, size);
507#endif
508 break;
509 default:
510 GNUNET_break (0);
511 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
512 return;
513 }
514#if DEBUG_RESOLVER
477 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 515 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
478 _("Resolver asked to look up IP address.\n")); 516 _("Resolver asked to look up IP address `%s'.\n"),
517 buf);
479#endif 518#endif
480 get_ip_as_string (client, (const struct sockaddr *) &msg[1], size); 519 get_ip_as_string (client, sa, size);
481 } 520 }
482} 521}
483 522