diff options
author | Roger Dingledine <arma@torproject.org> | 2003-02-06 23:48:35 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-02-06 23:48:35 +0000 |
commit | 0bc8dc1314652e8b5ccaa89a98c1a9922422ae1d (patch) | |
tree | cc6ef22f079992904f06f7e7149f8af450e4592c /src/or/dns.c | |
parent | ceafe12ed67528ce4dd656f43bccb7c7a9f7317f (diff) | |
download | tor-0bc8dc1314652e8b5ccaa89a98c1a9922422ae1d.tar tor-0bc8dc1314652e8b5ccaa89a98c1a9922422ae1d.tar.gz |
fix endian issues for topics -- they might work on bsd now
(they wouldn't have before)
alternate code which bypasses the dns farm, so we can compare speed
svn:r154
Diffstat (limited to 'src/or/dns.c')
-rw-r--r-- | src/or/dns.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/or/dns.c b/src/or/dns.c index 1bfaaee26..6ba43358b 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -339,10 +339,30 @@ static int dns_master_to_tor(int from, int to) { return 0; } -int dns_tor_to_master(char *address) { +int dns_tor_to_master(connection_t *exitconn) { connection_t *conn; unsigned char len; +#ifdef DO_DNS_DIRECTLY + /* new version which does it all right here */ + struct hostent *rent; + rent = gethostbyname(exitconn->address); + if (!rent) { + return -1; + } + + memcpy((char *)&exitconn->addr, rent->h_addr, rent->h_length); + exitconn->addr = ntohl(exitconn->addr); /* get it back to host order */ + + if(connection_exit_connect(exitconn) < 0) { + exitconn->marked_for_close = 1; + } + return 0; +#endif + + + + /* old version which actually uses the dns farm */ conn = connection_get_by_type(CONN_TYPE_DNSMASTER); if(!conn) { log(LOG_ERR,"dns_tor_to_master(): dns master nowhere to be found!"); @@ -350,13 +370,13 @@ int dns_tor_to_master(char *address) { return -1; } - len = strlen(address); + len = strlen(exitconn->address); if(connection_write_to_buf(&len, 1, conn) < 0) { log(LOG_DEBUG,"dns_tor_to_master(): Couldn't write length."); return -1; } - if(connection_write_to_buf(address, len, conn) < 0) { + if(connection_write_to_buf(exitconn->address, len, conn) < 0) { log(LOG_DEBUG,"dns_tor_to_master(): Couldn't write address."); return -1; } |