[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5074 - in GNUnet/src: server util/network
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5074 - in GNUnet/src: server util/network |
Date: |
Fri, 15 Jun 2007 22:04:14 -0600 (MDT) |
Author: grothoff
Date: 2007-06-15 22:04:13 -0600 (Fri, 15 Jun 2007)
New Revision: 5074
Modified:
GNUnet/src/server/gnunet-peer-info.c
GNUnet/src/util/network/dns.c
Log:
fix
Modified: GNUnet/src/server/gnunet-peer-info.c
===================================================================
--- GNUnet/src/server/gnunet-peer-info.c 2007-06-16 03:42:49 UTC (rev
5073)
+++ GNUnet/src/server/gnunet-peer-info.c 2007-06-16 04:04:13 UTC (rev
5074)
@@ -60,7 +60,47 @@
COMMAND_LINE_OPTION_END,
};
+#if HAVE_ADNS
/**
+ * Prepass just to resolve DNS entries.
+ */
+static int resolveHostInfo(const PeerIdentity * id,
+ const unsigned short proto,
+ int verified,
+ void * data) {
+ P2P_hello_MESSAGE * hello;
+ void * addr;
+ unsigned int addr_len;
+ char * info;
+ int have_addr;
+
+ if (GNUNET_SHUTDOWN_TEST()==YES)
+ return SYSERR;
+ hello = identity->identity2Hello(id,
+ proto,
+ NO);
+ if (NULL == hello)
+ return OK;
+ addr = NULL;
+ addr_len = 0;
+ have_addr = transport->helloToAddress(hello,
+ &addr,
+ &addr_len);
+ FREE(hello);
+ if (have_addr == OK) {
+ info = network_get_ip_as_string(addr,
+ addr_len,
+ ! no_resolve);
+ FREE(addr);
+ addr = NULL;
+ FREENONNULL(info);
+ }
+ return OK;
+}
+
+#endif
+
+/**
* Print information about the peer.
* Currently prints the PeerIdentity, trust and the IP.
* Could of course do more (e.g. resolve via DNS).
@@ -158,12 +198,18 @@
initCore(ectx, cfg, cron, NULL);
identity = requestService("identity");
transport = requestService("transport");
+ if (no_resolve != YES) {
+#if HAVE_ADNS
+ identity->forEachHost(0, /* no timeout */
+ &resolveHostInfo,
+ NULL);
+ /* give GNU ADNS time to resolve... */
+ PTHREAD_SLEEP(2 * cronSECONDS);
+#endif
+ }
identity->forEachHost(0, /* no timeout */
&printHostInfo,
NULL);
- identity->forEachHost(0, /* no timeout */
- &printHostInfo,
- NULL);
releaseService(identity);
releaseService(transport);
doneCore();
Modified: GNUnet/src/util/network/dns.c
===================================================================
--- GNUnet/src/util/network/dns.c 2007-06-16 03:42:49 UTC (rev 5073)
+++ GNUnet/src/util/network/dns.c 2007-06-16 04:04:13 UTC (rev 5074)
@@ -29,9 +29,6 @@
#include "platform.h"
#include "gnunet_util_network.h"
-#undef HAVE_ADNS
-#define HAVE_ADNS YES
-
#if HAVE_ADNS
#include <adns.h>
#endif
@@ -61,8 +58,9 @@
static void cache_resolve(struct IPCache * cache) {
#if HAVE_ADNS
adns_answer * answer;
- void * unused;
adns_status ret;
+ struct IPCache * rec;
+ int reti;
if (cache->posted == NO) {
ret = adns_submit_reverse(a_state,
@@ -73,23 +71,22 @@
&cache->query);
if (adns_s_ok == ret)
cache->posted = YES;
- else
- fprintf(stderr,
- "Oops: %s\n",
- adns_strerror(ret));
}
adns_processany(a_state);
answer = NULL;
- adns_check(a_state,
- &cache->query,
- &answer,
- &unused);
- if (answer != NULL) {
- printf("HAVE ANSWER!\n");
- if (answer->owner != NULL)
- cache->addr = STRDUP(answer->owner);
- free(answer);
- }
+ reti = adns_check(a_state,
+ &cache->query,
+ &answer,
+ (void**)&rec);
+ if (reti == 0) {
+ if (answer != NULL) {
+ if ( (answer->rrs.str != NULL) &&
+ (*(answer->rrs.str) != NULL) )
+ cache->addr = STRDUP(*(answer->rrs.str));
+ free(answer);
+ }
+ cache->posted = NO;
+ }
#else
#if HAVE_GETNAMEINFO
char hostname[256];
@@ -241,6 +238,11 @@
cache->salen = 0;
cache_resolve(cache);
}
+#if HAVE_ADNS
+ if (cache->posted == YES) {
+ cache_resolve(cache);
+ }
+#endif
} else if (do_resolve == NO) {
MUTEX_UNLOCK(lock);
return no_resolve(sav, salen);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5074 - in GNUnet/src: server util/network,
gnunet <=