MTPyroger/docs/source/topics/proxy.rst

56 lines
1.5 KiB
ReStructuredText
Raw Normal View History

2018-02-08 16:04:10 +00:00
SOCKS5 Proxy
2018-01-18 12:23:05 +00:00
============
2018-02-08 16:04:10 +00:00
Pyrogram supports proxies with and without authentication. This feature allows Pyrogram to exchange data with Telegram
through an intermediate SOCKS5 proxy server.
2018-01-18 12:23:05 +00:00
2020-04-01 18:08:46 +00:00
.. contents:: Contents
:backlinks: none
:local:
-----
2018-01-18 12:23:05 +00:00
Usage
-----
2018-02-27 17:18:25 +00:00
- To use Pyrogram with a proxy, simply append the following to your ``config.ini`` file and replace the values
with your own settings:
2018-01-18 12:23:05 +00:00
2018-02-27 17:18:25 +00:00
.. code-block:: ini
2018-01-18 12:23:05 +00:00
2018-02-27 17:18:25 +00:00
[proxy]
enabled = True
hostname = 11.22.33.44
port = 1080
username = <your_username>
password = <your_password>
2018-01-18 12:23:05 +00:00
2018-02-27 17:40:50 +00:00
To enable or disable the proxy without deleting your settings from the config file,
change the ``enabled`` value as follows:
2018-01-18 12:23:05 +00:00
2018-02-27 17:40:50 +00:00
- ``1``, ``yes``, ``True`` or ``on``: Enables the proxy
- ``0``, ``no``, ``False`` or ``off``: Disables the proxy
2018-01-18 12:23:05 +00:00
2018-03-25 19:30:39 +00:00
- Alternatively, you can setup your proxy without the need of the ``config.ini`` file by using the *proxy* parameter
2018-02-27 17:18:25 +00:00
in the Client class:
2018-02-22 10:02:38 +00:00
2018-02-27 17:18:25 +00:00
.. code-block:: python
2018-02-22 10:02:38 +00:00
2018-02-27 17:18:25 +00:00
from pyrogram import Client
2018-02-22 10:02:38 +00:00
app = Client(
2018-02-27 17:18:25 +00:00
session_name="example",
proxy=dict(
hostname="11.22.33.44",
port=1080,
username="<your_username>",
password="<your_password>"
)
)
2018-02-22 10:02:38 +00:00
app.start()
2018-02-22 10:02:38 +00:00
2018-02-27 17:18:25 +00:00
...
2018-02-22 10:02:38 +00:00
2018-03-25 19:30:39 +00:00
.. note:: If your proxy doesn't require authorization you can omit ``username`` and ``password`` by either leaving the
2018-02-22 10:02:38 +00:00
values blank/empty or completely delete the lines.