[tahoe-lafs-trac-stream] [Tahoe-LAFS] #517: make tahoe Tor- and I2P-friendly

Tahoe-LAFS trac at tahoe-lafs.org
Mon Sep 14 18:12:57 UTC 2015


#517: make tahoe Tor- and I2P-friendly
-------------------------+-------------------------------------------------
     Reporter:  warner   |      Owner:  ioerror
         Type:           |     Status:  new
  enhancement            |  Milestone:  undecided
     Priority:  minor    |    Version:  1.2.0
    Component:  code-    |   Keywords:  privacy anonymity anti-censorship
  network                |  i2p tor-protocol usability
   Resolution:           |
Launchpad Bug:           |
-------------------------+-------------------------------------------------

Comment (by warner):

 It's because we can get our IP address synchronously, via blocking
 `subprocess.check_output(["ifconfig"])`. We'll do this before Twisted has
 taken over the SIGCHLD handler (which happens in a reactor "during-
 startup" event trigger, so after reactor.run, so after
 `allmydata.node.Node` is constructed).

 We can also allocate a port synchronously. I just landed some code in
 Foolscap to do this (in `foolscap/util.py`):

 {{{

 def allocate_tcp_port():
     """Return an (integer) available TCP port on localhost. This briefly
     listens on the port in question, then closes it right away."""
     # We want to bind() the socket but not listen(). Twisted (in
     # tcp.Port.createInternetSocket) would do several other things:
     # non-blocking, close-on-exec, and SO_REUSEADDR. We don't need
     # non-blocking because we never listen on it, and we don't need
     # close-on-exec because we close it right away. So just add
 SO_REUSEADDR.
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     if platformType == "posix" and sys.platform != "cygwin":
         s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     s.bind(("127.0.0.1", 0))
     port = s.getsockname()[1]
     s.close()
     return port
 }}}

 (mind you, I'd like to confirm that function works correctly on windows..
 if you've got a windows box handy, could you run Foolscap's current trunk
 unit tests and see if `test_util.AllocatePort` passes?)

 Although as I think we talked about before, we probably don't need to use
 `allocate_tcp_port()` in tahoe's startup code: the only case where a node
 starts up with `tub.port = tcp:0` and '''doesn't''' have a
 `NODEDIR/client.port` file is if you created the node with the older
 version of `tahoe create-node`, but never actually started it with that
 version, and now you're trying to start it with the newer version.

 The newer version of `tahoe create-node` will allocate the port before
 writing out `tahoe.cfg`, so the runtime will never see a `tcp:0` anywhere.

--
Ticket URL: <https://tahoe-lafs.org/trac/tahoe-lafs/ticket/517#comment:38>
Tahoe-LAFS <https://Tahoe-LAFS.org>
secure decentralized storage


More information about the tahoe-lafs-trac-stream mailing list