mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +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
|
# aiohttp main session
|
||||||
ssl_context = ssl.create_default_context(cafile=certifi.where())
|
ssl_context = ssl.create_default_context(cafile=certifi.where())
|
||||||
connector = aiohttp.TCPConnector(limit=connections_limit, ssl_context=ssl_context,
|
|
||||||
loop=self.loop)
|
if isinstance(proxy, str) and proxy.startswith('socks5://'):
|
||||||
self.session = aiohttp.ClientSession(connector=connector, loop=self.loop,
|
from aiosocksy.connector import ProxyClientRequest, ProxyConnector
|
||||||
json_serialize=json.dumps)
|
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
|
# Temp sessions
|
||||||
self._temp_sessions = []
|
self._temp_sessions = []
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,4 @@ sphinx>=1.7.2
|
||||||
sphinx-rtd-theme>=0.3.0
|
sphinx-rtd-theme>=0.3.0
|
||||||
aresponses>=1.0.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