diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-04-28 19:35:12 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-04-28 19:35:12 +0000 |
commit | ac622d94dcf5c00ab9264ec234ea6e9e1a2a28f9 (patch) | |
tree | 1ab02f2335c4920d65fd518185dd5040903e18f9 /src/or | |
parent | 8cc9001391d010f06553a1576276925bc8fc0667 (diff) | |
download | tor-ac622d94dcf5c00ab9264ec234ea6e9e1a2a28f9.tar tor-ac622d94dcf5c00ab9264ec234ea6e9e1a2a28f9.tar.gz |
Workarounds for a couple of pieces of windows strangeness.
svn:r1734
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/dns.c | 19 | ||||
-rw-r--r-- | src/or/routerlist.c | 5 |
2 files changed, 8 insertions, 16 deletions
diff --git a/src/or/dns.c b/src/or/dns.c index b49e6dafa..6d7f36fc8 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -451,7 +451,6 @@ int dnsworker_main(void *data) { char address[MAX_ADDRESSLEN]; unsigned char address_len; char answer[5]; - struct hostent *rent; int *fdarray = data; int fd; @@ -475,21 +474,17 @@ int dnsworker_main(void *data) { } address[address_len] = 0; /* null terminate it */ - rent = gethostbyname(address); - if (!rent) { - if(h_errno == TRY_AGAIN) { /* transient error -- don't cache it */ + switch (tor_lookup_hostname(address, (uint32_t*)answer+1)) { + case 1: log_fn(LOG_INFO,"Could not resolve dest addr %s (transient).",address); answer[0] = DNS_RESOLVE_FAILED_TRANSIENT; - } else { /* permanent error, can be cached */ + break; + case -1: log_fn(LOG_INFO,"Could not resolve dest addr %s (permanent).",address); answer[0] = DNS_RESOLVE_FAILED_PERMANENT; - } - memset(answer+1,0,4); - } else { - tor_assert(rent->h_length == 4); /* break to remind us if we move away from ipv4 */ - answer[0] = DNS_RESOLVE_SUCCEEDED; - memcpy(answer+1, rent->h_addr, 4); - log_fn(LOG_INFO,"Resolved address '%s'.",address); + case 0: + log_fn(LOG_INFO,"Resolved address '%s'.",address); + answer[0] = DNS_RESOLVE_SUCCEEDED; } if(write_all(fd, answer, 5, 1) != 5) { log_fn(LOG_ERR,"writing answer failed. Child exiting."); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 3c01838dc..318382031 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -507,14 +507,11 @@ router_resolve(routerinfo_t *router) { struct hostent *rent; - rent = (struct hostent *)gethostbyname(router->address); - if (!rent) { + if (tor_lookup_hostname(router->address, &router->addr)) { log_fn(LOG_WARN,"Could not get address for router %s (%s).", router->address, router->nickname); return -1; } - tor_assert(rent->h_length == 4); - memcpy(&router->addr, rent->h_addr,rent->h_length); router->addr = ntohl(router->addr); /* get it back into host order */ return 0; |