[tor-bugs] #33898 [Core Tor/Tor]: Stop modifying addr on connections, and delete real_addr

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon May 4 16:23:26 UTC 2020


#33898: Stop modifying addr on connections, and delete real_addr
-------------------------------------------+-------------------------------
 Reporter:  teor                           |          Owner:  nickm
     Type:  defect                         |         Status:  assigned
 Priority:  High                           |      Milestone:  Tor:
                                           |  0.4.4.x-final
Component:  Core Tor/Tor                   |        Version:
 Severity:  Normal                         |     Resolution:
 Keywords:  ipv6, technical-debt, prop311  |  Actual Points:
Parent ID:  #33048                         |         Points:  1
 Reviewer:                                 |        Sponsor:  Sponsor55-can
-------------------------------------------+-------------------------------

Comment (by nickm):

 Okay, I went through all the code that sets or uses addr, real_addr, or
 address.

 It is a labyrinth!  These fields are used and set in subtly different ways
 depending on the connection.

 For most exit connections, the "address" starts out as what we were asked
 to connect to, and then later the "addr" field is made into whatever we
 got from DNS lookup.  The "address" field is used as a key for the DNS
 cache too.

 For linked exit connections, the "addr" appears to be taken from the
 address of the channel, so it can be copied into the linked dirconn.

 For hidden service exit connections, the "addr" is set to the local port
 that we're trying to connect to.

 For incoming connectnions, addr is initialized from the real remote
 sockaddr. Unless it's on a unix socket.

 For listeners, addr is set to the address we're listening on, and address
 is used for unix sockets to reconnect to that address if we need to rebind
 later on.

 For OR connections, addr is changed when we make an outgoing connection in
 connection_or_init_conn_from_address -- we might be using a different
 address than we decided initially to connect to if we have a descriptor
 for a node.  Addr is also set by connection_or_check_canonicity when we
 are receiving an incoming connection.

 For directory connections, if there is a Forwarded-For header, its
 contents replace the address field in http_set_address_origin().  This is
 used to send X-Your-Address-Is, and to annotate descriptors.

 For entry connections, "address" and "addr" are address that _made_ the
 request.  This also goes for UDP dns queries and controller resolve
 requests.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/33898#comment:9>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list