Commit 2483b40b authored by Matt Traudt's avatar Matt Traudt
Browse files

Make sure requests use the specified proxies

On one hand, for weeks now I've been running sbws and it seems to be
correctly doing downloads over tor. I've monitored existing circs and
streams with a script that queries the control port and what I saw made
sense.

On the other hand, I just tried running sbws on my laptop over a VPN
that blocks resolution of a hostname of mine. I got a proxy error with
a suspicious hostname in the message that led me to believe that
destination usability checks were not actually being done over Tor like
they are supposed to be.

The way Requests tells you to use proxies is by specifying them *not* on
the session object, but as an argument[0]. So do that.

[0]: http://docs.python-requests.org/en/master/user/advanced/#proxies
parent 58b86c42
......@@ -5,7 +5,7 @@ import sbws.util.stem as stem_utils
def make_session(controller, timeout):
s = requests.Session()
socks_info = stem_utils.get_socks_info(controller)
s.proxies = {
s.sbws_proxies = {
'http': 'socks5h://{}:{}'.format(*socks_info),
'https': 'socks5h://{}:{}'.format(*socks_info),
}
......@@ -14,8 +14,8 @@ def make_session(controller, timeout):
def get(s, url, **kw):
return s.get(url, timeout=s.sbws_timeout, **kw)
return s.get(url, timeout=s.sbws_timeout, proxies=s.sbws_proxies, **kw)
def head(s, url, **kw):
return s.head(url, timeout=s.sbws_timeout, **kw)
return s.head(url, timeout=s.sbws_timeout, proxies=s.sbws_proxies, **kw)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment