aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection_edge.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-11-25 14:51:36 -0500
committerNick Mathewson <nickm@torproject.org>2012-12-17 14:51:30 -0500
commit8d080d0b01f61c282ca8843801f2ebc8ae98c764 (patch)
tree2607cd2b36d89d15bebadaa8f3a88ce6f3e000d6 /src/or/connection_edge.c
parentde4cc126cbb5e663bdd048fd782fde869be7b80a (diff)
downloadtor-8d080d0b01f61c282ca8843801f2ebc8ae98c764.tar.gz
tor-8d080d0b01f61c282ca8843801f2ebc8ae98c764.zip
Per-listener option to prefer IPv6 automaps when possible.
Diffstat (limited to 'src/or/connection_edge.c')
-rw-r--r--src/or/connection_edge.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 960802654e..28c9e09ee5 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -932,9 +932,15 @@ connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
automap = addressmap_address_should_automap(socks->address, options);
if (automap) {
const char *new_addr;
- /*XXXX IPv6 Sometimes this should be RESOLVED_TYPE_IPV6 */
+ int addr_type = RESOLVED_TYPE_IPV4;
+ if (conn->socks_request->socks_version != 4) {
+ if (!conn->ipv4_traffic_ok ||
+ (conn->ipv6_traffic_ok && conn->prefer_ipv6_traffic) ||
+ conn->prefer_ipv6_virtaddr)
+ addr_type = RESOLVED_TYPE_IPV6;
+ }
new_addr = addressmap_register_virtual_address(
- RESOLVED_TYPE_IPV4, tor_strdup(socks->address));
+ addr_type, tor_strdup(socks->address));
if (! new_addr) {
log_warn(LD_APP, "Unable to automap address %s",
escaped_safe_str(socks->address));