meejah / txtorcon

Twisted-based asynchronous Tor control protocol implementation. Includes unit-tests, examples, state-tracking code and configuration abstraction.
http://fjblvrw2jrxnhtg67qpbzi45r7ofojaoo3orzykesly2j3c2m3htapid.onion/
MIT License
250 stars 72 forks source link

Incorrect documentation for build_local_tor_connection? #276

Closed DonnchaC closed 6 years ago

DonnchaC commented 6 years ago

The txtorcon documentation for build_local_tor_connection states that the control port is tried before the control socket. However the code seems to try to connect to the socket first. Is this a documentation mistake?

def build_local_tor_connection(reactor, host='127.0.0.1', port=9051,
                               socket='/var/run/tor/control', *args, **kwargs):
    try:
        return build_tor_connection((reactor, socket), *args, **kwargs)
    except Exception:
        return build_tor_connection((reactor, host, port), *args, **kwargs)
meejah commented 6 years ago

Sounds like it that could be true! I'll take a look.

If you're writing new code, you should use txtorcon.connect() instead of the above. The code in connect() definitely tries: unix-socket, then 9051, then 9151 in that order .. or you can pass in any IStreamClientEndpoint if you know what you want to connect to.

meejah commented 6 years ago

Hmm, yeah the wording is confusing in that docstring. I should probably also add "...perhaps you should try connect() instead" as well :)

meejah commented 6 years ago

fixed in master