summaryrefslogtreecommitdiff
path: root/src/or/connection_edge.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-10-31 18:27:48 -0400
committerNick Mathewson <nickm@torproject.org>2012-11-14 23:16:23 -0500
commitcac5335195d3bb9a39af77886992ffa98b8c7817 (patch)
tree8aebb8c010f7a3d926ceadf92be0d9e433d2a250 /src/or/connection_edge.c
parent93dc7dcf418f37023b5a1e3f4e8485d8286996b4 (diff)
downloadtor-cac5335195d3bb9a39af77886992ffa98b8c7817.tar.gz
tor-cac5335195d3bb9a39af77886992ffa98b8c7817.zip
Get the client side of receiving an IPv6 address to work
This makes it so we can handle getting an IPv6 in the 3 different formats we specified it for in RESOLVED cells, END_STREAM_REASON_EXITPOLICY cells, and CONNECTED cells. We don't cache IPv6 addresses yet, since proposal 205 isn't implemented. There's a refactored function for parsing connected cells; it has unit tests.
Diffstat (limited to 'src/or/connection_edge.c')
-rw-r--r--src/or/connection_edge.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index dc7d863f49..969128fcfb 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -1949,10 +1949,19 @@ connection_ap_handshake_socks_resolved(entry_connection_t *conn,
if (CIRCUIT_IS_ORIGIN(circ)) /* should always be true */
origin_circ = TO_ORIGIN_CIRCUIT(circ);
if (answer_type == RESOLVED_TYPE_IPV4 && answer_len == 4) {
- uint32_t a = ntohl(get_uint32(answer));
- if (a) {
+ tor_addr_t a;
+ tor_addr_from_ipv4n(&a, get_uint32(answer));
+ if (! tor_addr_is_null(&a)) {
client_dns_set_addressmap(origin_circ,
- conn->socks_request->address, a,
+ conn->socks_request->address, &a,
+ conn->chosen_exit_name, ttl);
+ }
+ } else if (answer_type == RESOLVED_TYPE_IPV6 && answer_len == 16) {
+ tor_addr_t a;
+ tor_addr_from_ipv6_bytes(&a, (char*)answer);
+ if (! tor_addr_is_null(&a)) {
+ client_dns_set_addressmap(origin_circ,
+ conn->socks_request->address, &a,
conn->chosen_exit_name, ttl);
}
} else if (answer_type == RESOLVED_TYPE_HOSTNAME && answer_len < 256) {