[tor-bugs] #659 [Tor Relay]: When configuring OR/Dir Ports, Tor always processes OR Port change first

Tor Bug Tracker & Wiki torproject-admin at torproject.org
Thu Nov 11 17:22:51 UTC 2010


#659: When configuring OR/Dir Ports, Tor always processes OR Port change first
------------------------------+---------------------------------------------
 Reporter:  HANtwister        |         Type:  defect   
   Status:  new               |     Priority:  minor    
Milestone:  Tor: unspecified  |    Component:  Tor Relay
  Version:  0.2.0.23-rc       |   Resolution:  None     
 Keywords:                    |       Parent:           
------------------------------+---------------------------------------------
Changes (by nickm):

  * milestone:  post 0.2.1.x => Tor: unspecified


Old description:

> I wasn't exactly sure how to phrase the subject, so feel free to rename
> it.
>
> Basically, when you change the OR or Directory Port Settings in Vidalia,
> Tor
> will always try to configure the OR Port first.
>
> This creates a problem if the user tries to switch the OR Port and the
> Dir Port
> (or just change the OR Port to the current Dir Port, and change the Dir
> Port to
> anything else). In short, in such a scenario, Tor blocks itself.
>
> For example:
> Say a Tor Server was configured to use Dir Port 443 and OR Port 8080.
> If the user tried to change it to use Dir Port 80 and OR Port 443, the
> following
> error message would be presented:
>
> [Warning] Could not bind to 0.0.0.0:443: Address already in use
> [WSAEADDRINUSE ].
> Is Tor already running?
>
> This error message would be presented because Tor first closes the OR
> Port, 8080.
> It then tries to open Port 443, but it is already using Port 443 as the
> Dir Port.
>
> [Automatically added by flyspray2trac: Operating System: Windows 2k/XP]

New description:

 I wasn't exactly sure how to phrase the subject, so feel free to rename
 it.

 Basically, when you change the OR or Directory Port Settings in Vidalia,
 Tor
 will always try to configure the OR Port first.

 This creates a problem if the user tries to switch the OR Port and the Dir
 Port
 (or just change the OR Port to the current Dir Port, and change the Dir
 Port to
 anything else). In short, in such a scenario, Tor blocks itself.

 For example:
 Say a Tor Server was configured to use Dir Port 443 and OR Port 8080.
 If the user tried to change it to use Dir Port 80 and OR Port 443, the
 following
 error message would be presented:

 [Warning] Could not bind to 0.0.0.0:443: Address already in use
 [WSAEADDRINUSE ].
 Is Tor already running?

 This error message would be presented because Tor first closes the OR
 Port, 8080.
 It then tries to open Port 443, but it is already using Port 443 as the
 Dir Port.

 [Automatically added by flyspray2trac: Operating System: Windows 2k/XP]

--

Comment:

 Moving to the "unspecified" milestone.  The real fix is a bit tricky.
 Here's our current behavior:
    1. For every listener that changed its port, open the new port.
    1. If they all succeeded, close the old sockets and assign the new
 sockets to the listeners.

  Here is the complicated fix:
    1. Inventory all the ports we have.
    1. Figure out all the ports that we want and do not yet have
    1. Bind the ports that we want
    1. (assuming success) Assign every socket to the listener that it
 belongs to
    1. (assuming success) Close the sockets we aren't using any longer

 Here is a more conservative "fix":
    1. When we get an EADDRINUSE, see whether we are already using the port
 for another listener. If so, tell the user that Tor doesn't support
 swapping ports around.

 The fixes are made a bit more complicated because you can't do a simple
 equality check for "is this the same addr:port", since 0.0.0.0 is special.

 It would be cute to have a fix for this, but it's not hurting anybody now,
 and the workaround is pretty easy.

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


More information about the tor-bugs mailing list