]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
core/or: Accurately log remote relay IPv6 addresses
authorteor <teor@torproject.org>
Tue, 14 Apr 2020 02:21:49 +0000 (12:21 +1000)
committerteor <teor@torproject.org>
Tue, 14 Apr 2020 02:21:49 +0000 (12:21 +1000)
Log IPv6 addresses on connections where this relay is the responder.

Previously, responding relays would replace the remote IPv6 address with
the IPv4 address from the consensus.

(The port is replaced with the IPv6 ORPort from the consensus, we will
resolve this issue in 33898.)

Fixes bug 33899; bugfix on 0.3.1.1-alpha.

changes/bug33899
src/core/or/connection_or.c

index 319df45dff19b324f918f8f5e06ad7544bab0666..b9b7d7cf134b08dd50ff03d46012cc436f69d509 100644 (file)
@@ -3,3 +3,7 @@
       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.
+    - Log IPv6 addresses on connections where this relay is the responder.
+      Previously, responding relays would replace the remote IPv6 address with
+      the IPv4 address from the consensus.
+      Fixes bug 33899; bugfix on 0.3.1.1-alpha.
index 2eecbc50a7c4e39e5729c3bd228d250c8487317c..f059bae25d7fe9fb744811465aa923071c84b668 100644 (file)
@@ -909,6 +909,13 @@ connection_or_check_canonicity(or_connection_t *conn, int started_here)
         tor_addr_eq(&conn->base_.addr, &node_ipv6_ap.addr)) {
       connection_or_set_canonical(conn, 1);
     }
+    /* Choose the correct canonical address and port. */
+    tor_addr_port_t *node_ap;
+    if (tor_addr_family(&conn->base_.addr) == AF_INET) {
+      node_ap = &node_ipv4_ap;
+    } else {
+      node_ap = &node_ipv6_ap;
+    }
     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
@@ -920,13 +927,14 @@ connection_or_check_canonicity(or_connection_t *conn, int started_here)
        * right IP address and port 56244, that wouldn't be as helpful. now we
        * log the "right" port too, so we know if it's moria1 or moria2.
        */
-      tor_addr_copy(&conn->base_.addr, &node_ap.addr);
-      conn->base_.port = node_ap.port;
+      /* See #33898 for a ticket that resolves this technical debt. */
+      tor_addr_copy(&conn->base_.addr, &node_ap->addr);
+      conn->base_.port = node_ap->port;
     }
     tor_free(conn->nickname);
     conn->nickname = tor_strdup(node_get_nickname(r));
     tor_free(conn->base_.address);
-    conn->base_.address = tor_addr_to_str_dup(&node_ap.addr);
+    conn->base_.address = tor_addr_to_str_dup(&node_ap->addr);
   } else {
     tor_free(conn->nickname);
     conn->nickname = tor_malloc(HEX_DIGEST_LEN+2);