summaryrefslogtreecommitdiff
path: root/src/or/dns.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-09-02 18:53:31 +0000
committerNick Mathewson <nickm@torproject.org>2005-09-02 18:53:31 +0000
commita6a45b771381e1fb091ce0f8767f262f2a09f8e2 (patch)
tree34ee340c03706e48b782ed8a50d57d95a0c69530 /src/or/dns.c
parent93179f4e7e68332e7316e40edcb14b584b8c712c (diff)
downloadtor-a6a45b771381e1fb091ce0f8767f262f2a09f8e2.tar.gz
tor-a6a45b771381e1fb091ce0f8767f262f2a09f8e2.zip
Add TTLs to RESOLVED, CONNECTED, and END_REASON_EXITPOLICY cells. Also, add a missing ntohl in connection_ap_handshake_socks_resolved.
svn:r4894
Diffstat (limited to 'src/or/dns.c')
-rw-r--r--src/or/dns.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/or/dns.c b/src/or/dns.c
index 39ce5ff1c4..87a3baaa5f 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -192,14 +192,21 @@ send_resolved_cell(connection_t *conn, uint8_t answer_type)
case RESOLVED_TYPE_IPV4:
buf[1] = 4;
set_uint32(buf+2, htonl(conn->addr));
- buflen = 6;
+ set_uint32(buf+6, htonl(MAX_DNS_ENTRY_AGE)); /*XXXX send a real TTL*/
+ buflen = 10;
break;
case RESOLVED_TYPE_ERROR_TRANSIENT:
case RESOLVED_TYPE_ERROR:
- buf[1] = 24; /* length of "error resolving hostname" */
- strlcpy(buf+2, "error resolving hostname", sizeof(buf)-2);
- buflen = 26;
- break;
+ {
+ const char *errmsg = "Error resolving hostname";
+ int msglen = strlen(errmsg);
+ int ttl = (answer_type == RESOLVED_TYPE_ERROR ? MAX_DNS_ENTRY_AGE : 0);
+ buf[1] = msglen;
+ strlcpy(buf+2, errmsg, sizeof(buf)-2);
+ set_uint32(buf+2+msglen, htonl((uint32_t)ttl));
+ buflen = 6+msglen;
+ break;
+ }
default:
tor_assert(0);
}