Frage

Bear with me. This is my first post...

The Tor project has recently introduced Stem as a loadable python module. I've been playing around with it to see if it's a viable tool. My results have been mixed.

I try to enable a configuration for a hidden service within the controller (which is supposed to act as though it came directly from the torrc file. It always fails on me. Here's a quick example of what I try:

    #!/usr/bin/env python
    from stem.control import Controller
    controller = Controller.from_port(port = 9051)
    controller.authenticate()
    controller.set_options({'HIDDENSERVICEDIR':'/tmp/hiddenservice/','HIDDENSERVICEPORT':'1234 127.0.0.1:1234'})

...which returns an error:

    InvalidRequest                            Traceback (most recent call last)
    /home/user/my/folder/<ipython-input-5-3921e9b46181> in <module>()
    /usr/local/lib/python2.7/dist-packages/stem/control.pyc in set_options(self, params, reset)
       1618         raise stem.InvalidRequest(response.code, response.message)
       1619       elif response.code in ("513", "553"):
    -> 1620         raise stem.InvalidRequest(response.code, response.message)
       1621       else:
       1622         raise stem.ProtocolError("Returned unexpected status code: %s" % response.code)

    InvalidRequest: Unacceptable option value: Failed to configure rendezvous options. See logs 

...and the following in /var/log/tor/log:

    Aug 1 10:10:05.000 [warn] HiddenServicePort with no preceding HiddenServiceDir directive
    Aug 1 10:10:05.000 [warn] Controller gave us config lines that didn't validate: Failed to configure rendezvous options. See logs for details.

I've tried this with Stem's "set_options" as seen above and in two separate commands with "set_conf". With "set_conf", I can set the HiddenServiceDir but it still fails the same when setting the port, making me think I have a fundamental misunderstanding of Tor.

I checked my circuits and it doesn't seem to matter if I have one with a hidden service rendezvous point; it keeps failing. I'd prefer to keep things pythonic, temporal and clean and not have a hacked up bash script that rewrites the torrc before restarting tor. (In a perfect world, I'd rather not write to a hidden service directory, but tor hasn't implemented that yet.)

I try to be as cross-platform as possible, but I'm running Linux with Tor 2.3.25...

So who has ideas of why Stem won't let me make a hidden service?

War es hilfreich?

Lösung

Thanks for pointing this out to me via our bug tracker. Answering this here. :)

The set_options() docs say...

The params can optionally be a list of key/value tuples, though the only reason this type of argument would be useful is for hidden service configuration (those options are order dependent).

The issue here is that Tor's hidden service options behave in a slightly different fashion from all the rest of its config options. Tor expects a 'HiddenServiceDir' followed by the properties associated with that hidden service (it's order dependent). This is because a single tor instance can provide multiple hidden services.

Please change your call from...

controller.set_options({'HIDDENSERVICEDIR':'/tmp/hiddenservice/','HIDDENSERVICEPORT':'1234 127.0.0.1:1234'})

... to be a list of tuples instead...

controller.set_options([('HiddenServiceDir', '/tmp/hiddenservice/'), ('HiddenServicePort', '1234 127.0.0.1:1234')])

Hope this helps! -Damian

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top