summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-08-27 09:53:37 -0400
committerNick Mathewson <nickm@torproject.org>2012-08-27 09:53:37 -0400
commitb3b4f319367e1fb50ea99ba042ed60030e909c12 (patch)
tree39ec5b9660f32b34457ac141a23e7d2bcb666958
parent6f7dbd3d34fbc476721a64c7c5f5e241ec49b906 (diff)
parent734b09080f31545e8acd57a5c9626f6465ea4374 (diff)
downloadtor-b3b4f319367e1fb50ea99ba042ed60030e909c12.tar.gz
tor-b3b4f319367e1fb50ea99ba042ed60030e909c12.zip
Merge remote-tracking branch 'linus/bug6364'
-rw-r--r--changes/bug63643
-rw-r--r--src/or/command.c14
-rw-r--r--src/or/connection_or.c9
3 files changed, 20 insertions, 6 deletions
diff --git a/changes/bug6364 b/changes/bug6364
new file mode 100644
index 0000000000..c0eb453959
--- /dev/null
+++ b/changes/bug6364
@@ -0,0 +1,3 @@
+ o Minor features:
+ - A relay with an IPv6 OR port now sends that address in NETINFO
+ cells. Fix for bug 6364.
diff --git a/src/or/command.c b/src/or/command.c
index abf664c1e2..88603c924a 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -808,7 +808,7 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
time_t now = time(NULL);
long apparent_skew = 0;
- uint32_t my_apparent_addr = 0;
+ tor_addr_t my_apparent_addr = TOR_ADDR_NULL;
if (conn->link_proto < 2) {
log_fn(LOG_PROTOCOL_WARN, LD_OR,
@@ -868,7 +868,9 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
connection_mark_for_close(TO_CONN(conn));
return;
} else if (my_addr_type == RESOLVED_TYPE_IPV4 && my_addr_len == 4) {
- my_apparent_addr = ntohl(get_uint32(my_addr_ptr));
+ tor_addr_from_ipv4n(&my_apparent_addr, get_uint32(my_addr_ptr));
+ } else if (my_addr_type == RESOLVED_TYPE_IPV6 && my_addr_len == 16) {
+ tor_addr_from_ipv6_bytes(&my_apparent_addr, (const char *) my_addr_ptr);
}
n_other_addrs = (uint8_t) *cp++;
@@ -921,7 +923,6 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
/* XXX maybe act on my_apparent_addr, if the source is sufficiently
* trustworthy. */
- (void)my_apparent_addr;
if (connection_or_set_state_open(conn)<0) {
log_fn(LOG_PROTOCOL_WARN, LD_OR, "Got good NETINFO cell from %s:%d; but "
@@ -931,10 +932,13 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
connection_mark_for_close(TO_CONN(conn));
} else {
log_info(LD_OR, "Got good NETINFO cell from %s:%d; OR connection is now "
- "open, using protocol version %d. Its ID digest is %s",
+ "open, using protocol version %d. Its ID digest is %s. "
+ "Our address is apparently %s.",
safe_str_client(conn->_base.address),
conn->_base.port, (int)conn->link_proto,
- hex_str(conn->identity_digest, DIGEST_LEN));
+ hex_str(conn->identity_digest, DIGEST_LEN),
+ tor_addr_is_null(&my_apparent_addr) ?
+ "<none>" : fmt_and_decorate_addr(&my_apparent_addr));
}
assert_connection_ok(TO_CONN(conn),time(NULL));
}
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 55ea32e57b..da27cba32d 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -1988,12 +1988,19 @@ connection_or_send_netinfo(or_connection_t *conn)
if ((public_server_mode(get_options()) || !conn->is_outgoing) &&
(me = router_get_my_routerinfo())) {
tor_addr_t my_addr;
- *out++ = 1; /* only one address is supported. */
+ *out++ = 1 + !tor_addr_is_null(&me->ipv6_addr);
tor_addr_from_ipv4h(&my_addr, me->addr);
len = append_address_to_payload(out, &my_addr);
if (len < 0)
return -1;
+ out += len;
+
+ if (!tor_addr_is_null(&me->ipv6_addr)) {
+ len = append_address_to_payload(out, &me->ipv6_addr);
+ if (len < 0)
+ return -1;
+ }
} else {
*out = 0;
}