Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add socks_endpoint kwarg to TorClientEndpoint's constructor #182

Closed
wants to merge 15 commits into from

Conversation

david415
Copy link
Contributor

this adds UNIX domain socket functionality to the TorClientEndpoint... so that we connect to the SOCKS proxy via a unix domain socket.

@coveralls
Copy link

coveralls commented Aug 29, 2016

Coverage Status

Coverage decreased (-0.2%) to 99.338% when pulling 3cc23fc on david415:181.unix_socks.0 into 24d4aa2 on meejah:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.338% when pulling 3cc23fc on david415:181.unix_socks.0 into 24d4aa2 on meejah:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.338% when pulling 3cc23fc on david415:181.unix_socks.0 into 24d4aa2 on meejah:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.338% when pulling 3cc23fc on david415:181.unix_socks.0 into 24d4aa2 on meejah:master.

@@ -667,6 +668,7 @@ class TorClientEndpoint(object):
socks_ports_to_try = [9050, 9150]

def __init__(self, host, port,
socks_socket=None,
socks_hostname=None, socks_port=None,
Copy link
Owner

@meejah meejah Aug 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it'd be better to have just one way to specify "how to connect to SOCKS" -- right now there's _proxy_endpoint_generator= and socks_socket= (and socks_hostname/socks_port) -- can we just have e.g. "socks_endpoint=None" and if it's None, we try some default things? We could change the "list of default things" to be actual endpoint-strings, too (e.g. in case there's a well-known Tor SOCKS unix socket default in future). In any case, I think it'd be better if "socks_socket" were at least "socks_endpoint" so that a user can manually specify any sort of endpoint (including of course UNIXClientEndpoint).

Backwards-compatibilitiy: socks_hostname/socks_port are public API; we can capture **kwargs and do something sensible if these were specified (i.e. pretend they said socks_endpoint=TCP4ClientEndpoint(host, port)).

I see I dropped _proxy_endpoint_generator from "the new stuff" so maybe we can accomplish that here, too?

Copy link
Contributor Author

@david415 david415 Aug 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i've turned the new argument into socks_endpoint... but i did not yet try to change all the default things to endpoints.

@codecov-io
Copy link

codecov-io commented Aug 29, 2016

Current coverage is 99.41% (diff: 88.88%)

Merging #182 into master will decrease coverage by 0.14%

@@             master       #182   diff @@
==========================================
  Files            15         15          
  Lines          2709       2724    +15   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           2697       2708    +11   
- Misses           12         16     +4   
  Partials          0          0          

Powered by Codecov. Last update 24d4aa2...6e85838

@coveralls
Copy link

coveralls commented Aug 29, 2016

Coverage Status

Coverage decreased (-0.2%) to 99.374% when pulling 594e8ed on david415:181.unix_socks.0 into 24d4aa2 on meejah:master.

@@ -667,6 +667,7 @@ class TorClientEndpoint(object):
socks_ports_to_try = [9050, 9150]

def __init__(self, host, port,
socks_endpoint=None,
socks_hostname=None, socks_port=None,
socks_username=None, socks_password=None,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to get rid of socks_hostname + socks_port too then, right? (i.e. it's socks_endpoint=TCP4ClientEndpoint(host, port) instead of socks_hostname=host and socks_port=port right?)

@coveralls
Copy link

coveralls commented Aug 29, 2016

Coverage Status

Coverage decreased (-0.1%) to 99.411% when pulling 7682481 on david415:181.unix_socks.0 into 24d4aa2 on meejah:master.

here we also fix some of the tests
@david415 david415 changed the title Add socks_socket kwarg to TorClientEndpoint's constructor Add socks_endpoint kwarg to TorClientEndpoint's constructor Aug 29, 2016
@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 99.558% when pulling 31a46dd on david415:181.unix_socks.0 into 24d4aa2 on meejah:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 99.558% when pulling 31a46dd on david415:181.unix_socks.0 into 24d4aa2 on meejah:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 99.558% when pulling 31a46dd on david415:181.unix_socks.0 into 24d4aa2 on meejah:master.

@coveralls
Copy link

coveralls commented Aug 29, 2016

Coverage Status

Coverage increased (+0.001%) to 99.558% when pulling 31a46dd on david415:181.unix_socks.0 into 24d4aa2 on meejah:master.

@meejah
Copy link
Owner

meejah commented Aug 30, 2016

Cool, looks good. Should probably have a test for the backwards-compat thing I guess ...

@david415
Copy link
Contributor Author

I tested it! It works. I tested with tor configured with a unix socket SOCKS port...

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 99.413% when pulling 6e85838 on david415:181.unix_socks.0 into 24d4aa2 on meejah:master.

1 similar comment
@coveralls
Copy link

coveralls commented Aug 31, 2016

Coverage Status

Coverage decreased (-0.1%) to 99.413% when pulling 6e85838 on david415:181.unix_socks.0 into 24d4aa2 on meejah:master.

@@ -5,3 +5,4 @@ Twisted>=11.1.0
ipaddress>=1.0.16
zope.interface>=3.6.1
txsocksx>=1.13.0
pyopenssl>=16.1.0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this get added by Twisted? Or is that an optional thing? (I mean: I don't think txtorcon actually directly depends on pyopenssl, does it?)

@meejah
Copy link
Owner

meejah commented Aug 31, 2016

Oh, hmm: need tests for the if self.tls cases too...

@@ -677,7 +677,6 @@ def __init__(self, host, port,
except KeyError:
pass

if self.socks_endpoint is None:
self._socks_port_iter = iter(self.socks_ports_to_try)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't actually a duplicate: socks_endpoint might still be None here, if a) the user didn't pass socks_endpoint to begin with and b) also didn't use the old style socks_host/socks_port options... (i.e. if it hits the KeyError).

@meejah
Copy link
Owner

meejah commented Aug 31, 2016

Superceded by #183 (so that I don't have to wait for @david415 to merge my moar-commits to his branch etc).

@meejah meejah closed this Aug 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants