Commit 527fbc30 authored by Nick Mathewson's avatar Nick Mathewson 🏃
Browse files

r12958@catbus: nickm | 2007-05-25 14:19:29 -0400

 Fix more dnsport bugs: set state correctly, and actually cache the answers.


svn:r10328
parent 5f226f13
......@@ -669,7 +669,7 @@ addressmap_rewrite(char *address, size_t maxlen)
return (rewrites > 0); /* done, no rewrite needed */
cp = tor_strdup(escaped_safe_str(ent->new_address));
log_notice(LD_APP, "Addressmap: rewriting %s to %s",
log_info(LD_APP, "Addressmap: rewriting %s to %s",
escaped_safe_str(address), cp);
tor_free(cp);
strlcpy(address, ent->new_address, maxlen);
......@@ -1945,12 +1945,6 @@ connection_ap_handshake_socks_resolved(edge_connection_t *conn,
char buf[384];
size_t replylen;
if (conn->dns_server_request) {
dnsserv_resolved(conn, answer_type, answer_len, answer, ttl);
conn->socks_request->has_finished = 1; /* DOCDOC */
return;
}
if (ttl >= 0) {
if (answer_type == RESOLVED_TYPE_IPV4 && answer_len == 4) {
uint32_t a = ntohl(get_uint32(answer));
......@@ -1966,6 +1960,12 @@ connection_ap_handshake_socks_resolved(edge_connection_t *conn,
}
}
if (conn->dns_server_request) {
dnsserv_resolved(conn, answer_type, answer_len, answer, ttl);
conn->socks_request->has_finished = 1; /* DOCDOC */
return;
}
if (conn->socks_request->socks_version == 4) {
buf[0] = 0x00; /* version */
if (answer_type == RESOLVED_TYPE_IPV4 && answer_len == 4) {
......
......@@ -90,10 +90,10 @@ evdns_server_callback(struct evdns_server_request *req, void *_data)
return;
}
/* XXXX020 Handle .onion and .exit. */
/* XXXX020 Send a stream event to the controller. */
conn = TO_EDGE_CONN(connection_new(CONN_TYPE_AP));
conn->_base.state = AP_CONN_STATE_RESOLVE_WAIT;
if (q->type == EVDNS_TYPE_A)
conn->socks_request->command = SOCKS_COMMAND_RESOLVE;
else
......@@ -104,8 +104,6 @@ evdns_server_callback(struct evdns_server_request *req, void *_data)
conn->dns_server_request = req;
/* XXXX need to set state ?? */
log_info(LD_APP, "Passing request for %s to rewrite_and_attach.", q->name);
connection_ap_handshake_rewrite_and_attach(conn, NULL, NULL);
/* Now the connection is marked if it was bad. */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment