Commit 83bec238 authored by Maxim Gubin's avatar Maxim Gubin Committed by Francesco Poldi

Fix Tor proxy not being able to connect (#248)

* Fix Tor proxy not being able to connect

* Fix request calls

* Fix proxy args
parent 528a2506
...@@ -105,6 +105,9 @@ def initialize(args): ...@@ -105,6 +105,9 @@ def initialize(args):
c.Media = args.media c.Media = args.media
c.Replies = args.replies c.Replies = args.replies
c.Pandas_clean = args.pandas_clean c.Pandas_clean = args.pandas_clean
c.Proxy_host = args.proxy_host
c.Proxy_port = args.proxy_port
c.Proxy_type = args.proxy_type
c.ES_count = {"likes":True, "replies":True, "retweets":True} c.ES_count = {"likes":True, "replies":True, "retweets":True}
return c return c
......
...@@ -18,7 +18,7 @@ async def RequestUrl(config, init): ...@@ -18,7 +18,7 @@ async def RequestUrl(config, init):
_connector = None _connector = None
if config.Proxy_host is not None: if config.Proxy_host is not None:
if config.Proxy_host.lower() == "tor": if config.Proxy_host.lower() == "tor":
connector = SocksConnector( _connector = SocksConnector(
socks_ver=SocksVer.SOCKS5, socks_ver=SocksVer.SOCKS5,
host='127.0.0.1', host='127.0.0.1',
port=9050, port=9050,
...@@ -54,7 +54,7 @@ async def RequestUrl(config, init): ...@@ -54,7 +54,7 @@ async def RequestUrl(config, init):
response = await Request(_url, connector=_connector) response = await Request(_url, connector=_connector)
elif config.TwitterSearch: elif config.TwitterSearch:
_url = await url.Search(config, init) _url = await url.Search(config, init)
response = await Request(_url, options=_connector) response = await Request(_url, connector=_connector)
else: else:
if config.Following: if config.Following:
_url = await url.Following(config.Username, init) _url = await url.Following(config.Username, init)
...@@ -72,7 +72,7 @@ async def RequestUrl(config, init): ...@@ -72,7 +72,7 @@ async def RequestUrl(config, init):
async def MobileRequest(url, **options): async def MobileRequest(url, **options):
#loggin.info("[<] " + str(datetime.now()) + ':: get+MobileRequest') #loggin.info("[<] " + str(datetime.now()) + ':: get+MobileRequest')
ua = {'User-Agent': 'Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/0.8.12'} ua = {'User-Agent': 'Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/0.8.12'}
connector = options.get("_connector") connector = options.get("connector")
if connector: if connector:
async with aiohttp.ClientSession(headers=ua, connector=connector) as session: async with aiohttp.ClientSession(headers=ua, connector=connector) as session:
return await Response(session, url) return await Response(session, url)
...@@ -81,7 +81,7 @@ async def MobileRequest(url, **options): ...@@ -81,7 +81,7 @@ async def MobileRequest(url, **options):
async def Request(url, **options): async def Request(url, **options):
#loggin.info("[<] " + str(datetime.now()) + ':: get+Request') #loggin.info("[<] " + str(datetime.now()) + ':: get+Request')
connector = options.get("_connector") connector = options.get("connector")
if connector: if connector:
async with aiohttp.ClientSession(connector=connector) as session: async with aiohttp.ClientSession(connector=connector) as session:
return await Response(session, url) return await Response(session, url)
......
Markdown is supported
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