diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-06-20 08:50:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-06-20 08:50:35 +0000 |
commit | 61a008c4e471cd5081d5c2871949da779246a868 (patch) | |
tree | 95f07d0579ec84330e440a3325109cca45ddb809 /src/util/test_resolver_api.c | |
parent | 0211530d9b0e02e31eecd14f8565b88de8210025 (diff) | |
download | gnunet-61a008c4e471cd5081d5c2871949da779246a868.tar.gz gnunet-61a008c4e471cd5081d5c2871949da779246a868.zip |
make resolver test pass even if primary DNS is down
Diffstat (limited to 'src/util/test_resolver_api.c')
-rw-r--r-- | src/util/test_resolver_api.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c index d1c343f82..be631e36f 100644 --- a/src/util/test_resolver_api.c +++ b/src/util/test_resolver_api.c | |||
@@ -54,6 +54,7 @@ check_hostname(void *cls, const struct sockaddr *sa, socklen_t salen) | |||
54 | GNUNET_a2s(sa, salen)); | 54 | GNUNET_a2s(sa, salen)); |
55 | } | 55 | } |
56 | 56 | ||
57 | |||
57 | static void | 58 | static void |
58 | check_localhost_num(void *cls, const char *hostname) | 59 | check_localhost_num(void *cls, const char *hostname) |
59 | { | 60 | { |
@@ -78,6 +79,7 @@ check_localhost_num(void *cls, const char *hostname) | |||
78 | } | 79 | } |
79 | } | 80 | } |
80 | 81 | ||
82 | |||
81 | static void | 83 | static void |
82 | check_localhost(void *cls, const char *hostname) | 84 | check_localhost(void *cls, const char *hostname) |
83 | { | 85 | { |
@@ -223,7 +225,7 @@ run(void *cls, char * const *args, | |||
223 | int *ok = cls; | 225 | int *ok = cls; |
224 | struct sockaddr_in sa; | 226 | struct sockaddr_in sa; |
225 | struct GNUNET_TIME_Relative timeout = GNUNET_TIME_relative_multiply( | 227 | struct GNUNET_TIME_Relative timeout = GNUNET_TIME_relative_multiply( |
226 | GNUNET_TIME_UNIT_MILLISECONDS, 2500); | 228 | GNUNET_TIME_UNIT_SECONDS, 30); |
227 | int count_ips = 0; | 229 | int count_ips = 0; |
228 | char * own_fqdn; | 230 | char * own_fqdn; |
229 | 231 | ||
@@ -233,15 +235,6 @@ run(void *cls, char * const *args, | |||
233 | sa.sin_len = (u_char) sizeof (sa); | 235 | sa.sin_len = (u_char) sizeof (sa); |
234 | #endif | 236 | #endif |
235 | sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); | 237 | sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
236 | GNUNET_RESOLVER_ip_get("localhost", AF_INET, timeout, &check_127, | ||
237 | cls); | ||
238 | GNUNET_RESOLVER_hostname_get((const struct sockaddr *) &sa, | ||
239 | sizeof(struct sockaddr), GNUNET_YES, timeout, &check_localhost, cls); | ||
240 | GNUNET_RESOLVER_hostname_get((const struct sockaddr *) &sa, | ||
241 | sizeof(struct sockaddr), GNUNET_NO, timeout, &check_localhost_num, cls); | ||
242 | GNUNET_RESOLVER_hostname_resolve(AF_UNSPEC, timeout, | ||
243 | &check_hostname, cls); | ||
244 | |||
245 | 238 | ||
246 | /* | 239 | /* |
247 | * Looking up our own fqdn | 240 | * Looking up our own fqdn |
@@ -254,7 +247,6 @@ run(void *cls, char * const *args, | |||
254 | * Testing non-local DNS resolution | 247 | * Testing non-local DNS resolution |
255 | * DNS rootserver to test: a.root-servers.net - 198.41.0.4 | 248 | * DNS rootserver to test: a.root-servers.net - 198.41.0.4 |
256 | */ | 249 | */ |
257 | |||
258 | const char * rootserver_name = ROOTSERVER_NAME; | 250 | const char * rootserver_name = ROOTSERVER_NAME; |
259 | struct hostent *rootserver; | 251 | struct hostent *rootserver; |
260 | 252 | ||
@@ -340,10 +332,11 @@ run(void *cls, char * const *args, | |||
340 | } | 332 | } |
341 | 333 | ||
342 | #if DEBUG_RESOLVER | 334 | #if DEBUG_RESOLVER |
343 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "System's own reverse name resolution is working\n"); | 335 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
336 | "System's own reverse name resolution is working\n"); | ||
344 | #endif | 337 | #endif |
345 | /* Resolve the same using GNUNET */ | ||
346 | 338 | ||
339 | /* Resolve the same using GNUNET */ | ||
347 | memset(&sa, 0, sizeof(sa)); | 340 | memset(&sa, 0, sizeof(sa)); |
348 | sa.sin_family = AF_INET; | 341 | sa.sin_family = AF_INET; |
349 | #if HAVE_SOCKADDR_IN_SIN_LEN | 342 | #if HAVE_SOCKADDR_IN_SIN_LEN |
@@ -356,6 +349,25 @@ run(void *cls, char * const *args, | |||
356 | #endif | 349 | #endif |
357 | GNUNET_RESOLVER_hostname_get((const struct sockaddr *) &sa, | 350 | GNUNET_RESOLVER_hostname_get((const struct sockaddr *) &sa, |
358 | sizeof(struct sockaddr), GNUNET_YES, timeout, &check_rootserver_name, cls); | 351 | sizeof(struct sockaddr), GNUNET_YES, timeout, &check_rootserver_name, cls); |
352 | |||
353 | memset(&sa, 0, sizeof(sa)); | ||
354 | sa.sin_family = AF_INET; | ||
355 | #if HAVE_SOCKADDR_IN_SIN_LEN | ||
356 | sa.sin_len = (u_char) sizeof (sa); | ||
357 | #endif | ||
358 | sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); | ||
359 | |||
360 | GNUNET_RESOLVER_ip_get("localhost", AF_INET, timeout, &check_127, | ||
361 | cls); | ||
362 | fprintf (stderr, "Trying to get hostname for 127.0.0.1\n"); | ||
363 | GNUNET_RESOLVER_hostname_get((const struct sockaddr *) &sa, | ||
364 | sizeof(struct sockaddr), GNUNET_YES, timeout, &check_localhost, cls); | ||
365 | |||
366 | GNUNET_RESOLVER_hostname_get((const struct sockaddr *) &sa, | ||
367 | sizeof(struct sockaddr), GNUNET_NO, timeout, &check_localhost_num, cls); | ||
368 | GNUNET_RESOLVER_hostname_resolve(AF_UNSPEC, timeout, | ||
369 | &check_hostname, cls); | ||
370 | |||
359 | } | 371 | } |
360 | 372 | ||
361 | static int | 373 | static int |