mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-06 07:50:32 +00:00
Implemented support of Socks5 Proxy
This commit is contained in:
parent
e07115a09f
commit
f047bb6db3
2 changed files with 14 additions and 5 deletions
|
|
@ -58,10 +58,18 @@ class BaseBot:
|
|||
|
||||
# aiohttp main session
|
||||
ssl_context = ssl.create_default_context(cafile=certifi.where())
|
||||
connector = aiohttp.TCPConnector(limit=connections_limit, ssl_context=ssl_context,
|
||||
loop=self.loop)
|
||||
self.session = aiohttp.ClientSession(connector=connector, loop=self.loop,
|
||||
json_serialize=json.dumps)
|
||||
|
||||
if isinstance(proxy, str) and proxy.startswith('socks5://'):
|
||||
from aiosocksy.connector import ProxyClientRequest, ProxyConnector
|
||||
connector = ProxyConnector(limit=connections_limit, ssl_context=ssl_context, loop=self.loop)
|
||||
request_class = ProxyClientRequest
|
||||
else:
|
||||
connector = aiohttp.TCPConnector(limit=connections_limit, ssl_context=ssl_context,
|
||||
loop=self.loop)
|
||||
request_class = aiohttp.ClientRequest
|
||||
|
||||
self.session = aiohttp.ClientSession(connector=connector, request_class=request_class,
|
||||
loop=self.loop, json_serialize=json.dumps)
|
||||
|
||||
# Temp sessions
|
||||
self._temp_sessions = []
|
||||
|
|
|
|||
|
|
@ -11,4 +11,5 @@ rethinkdb>=2.3.0
|
|||
sphinx>=1.7.2
|
||||
sphinx-rtd-theme>=0.3.0
|
||||
aresponses>=1.0.0
|
||||
tox>=3.0.0
|
||||
tox>=3.0.0
|
||||
aiosocksy>=0.1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue