[tor-commits] [tor/master] core/or: Allow IPv6 connections to be canonical
nickm at torproject.org
nickm at torproject.org
Fri Apr 24 12:15:10 UTC 2020
commit 41fa07f751aaf50297d3139c440f7fb3ed71338a
Author: teor <teor at torproject.org>
Date: Tue Apr 14 12:16:48 2020 +1000
core/or: Allow IPv6 connections to be canonical
Consider IPv6 addresses when checking if a connection is canonical.
In 17604, relays assumed that a remote relay could consider an IPv6
connection canonical, but did not set the canonical flag on their side
of the connection.
Fixes bug 33899; bugfix on 0.3.1.1-alpha.
---
changes/bug33899 | 5 +++++
src/core/or/connection_or.c | 12 +++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/changes/bug33899 b/changes/bug33899
new file mode 100644
index 000000000..319df45df
--- /dev/null
+++ b/changes/bug33899
@@ -0,0 +1,5 @@
+ o Minor bugfixes (IPv6, relay):
+ - Consider IPv6 addresses when checking if a connection is canonical.
+ In 17604, relays assumed that a remote relay could consider an IPv6
+ connection canonical, but did not set the canonical flag on their side
+ of the connection. Fixes bug 33899; bugfix on 0.3.1.1-alpha.
diff --git a/src/core/or/connection_or.c b/src/core/or/connection_or.c
index 6b11f3323..2eecbc50a 100644
--- a/src/core/or/connection_or.c
+++ b/src/core/or/connection_or.c
@@ -901,12 +901,14 @@ connection_or_check_canonicity(or_connection_t *conn, int started_here)
}
if (r) {
- tor_addr_port_t node_ap;
- node_get_pref_orport(r, &node_ap);
- /* XXXX proposal 186 is making this more complex. For now, a conn
- is canonical when it uses the _preferred_ address. */
- if (tor_addr_eq(&conn->base_.addr, &node_ap.addr))
+ tor_addr_port_t node_ipv4_ap;
+ tor_addr_port_t node_ipv6_ap;
+ node_get_prim_orport(r, &node_ipv4_ap);
+ node_get_pref_ipv6_orport(r, &node_ipv6_ap);
+ if (tor_addr_eq(&conn->base_.addr, &node_ipv4_ap.addr) ||
+ tor_addr_eq(&conn->base_.addr, &node_ipv6_ap.addr)) {
connection_or_set_canonical(conn, 1);
+ }
if (!started_here) {
/* Override the addr/port, so our log messages will make sense.
* This is dangerous, since if we ever try looking up a conn by
More information about the tor-commits
mailing list