mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 10:53:44 +03:00
Allow using lists and dicts for passing proxy settings
This commit is contained in:
parent
3de398bae6
commit
5362f2578d
|
@ -234,8 +234,8 @@ Once this is done, pass the proxy settings to the ``TelegramClient`` constructor
|
||||||
... api_id=12345, api_hash='0123456789abcdef0123456789abcdef',
|
... api_id=12345, api_hash='0123456789abcdef0123456789abcdef',
|
||||||
... proxy=(socks.SOCKS5, 'localhost', 4444))
|
... proxy=(socks.SOCKS5, 'localhost', 4444))
|
||||||
|
|
||||||
The ``proxy=`` parameter should be a tuple consisting of
|
The ``proxy=`` argument should be a tuple, a list or a dict, consisting of parameters described
|
||||||
``(type, 'ip address', port)``, as described `here <https://github.com/Anorov/PySocks#sockssocksocket>`_.
|
`here <https://github.com/Anorov/PySocks#usage-1>`_.
|
||||||
|
|
||||||
Disclaimer
|
Disclaimer
|
||||||
==========
|
==========
|
||||||
|
|
|
@ -25,7 +25,10 @@ class TcpClient:
|
||||||
else:
|
else:
|
||||||
import socks
|
import socks
|
||||||
self._socket = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM)
|
self._socket = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
self._socket.set_proxy(*self._proxy)
|
if type(self._proxy) is dict:
|
||||||
|
self._socket.set_proxy(**self._proxy)
|
||||||
|
else: # tuple, list, etc.
|
||||||
|
self._socket.set_proxy(*self._proxy)
|
||||||
|
|
||||||
def connect(self, ip, port):
|
def connect(self, ip, port):
|
||||||
"""Connects to the specified IP and port number"""
|
"""Connects to the specified IP and port number"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user