2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-23 10:28:00 +00:00

57 lines
1.5 KiB
ReStructuredText
Raw Normal View History

2018-02-08 17:04:10 +01:00
SOCKS5 Proxy
2018-01-18 13:23:05 +01:00
============
2018-02-08 17:04:10 +01: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 13:23:05 +01:00
2020-04-01 20:08:46 +02:00
.. contents:: Contents
:backlinks: none
:depth: 1
2020-04-01 20:08:46 +02:00
:local:
-----
2018-01-18 13:23:05 +01:00
Usage
-----
2018-02-27 18:18:25 +01: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 13:23:05 +01:00
2018-02-27 18:18:25 +01:00
.. code-block:: ini
2018-01-18 13:23:05 +01:00
2018-02-27 18:18:25 +01:00
[proxy]
enabled = True
hostname = 11.22.33.44
port = 1080
username = <your_username>
password = <your_password>
2018-01-18 13:23:05 +01:00
2018-02-27 18:40:50 +01:00
To enable or disable the proxy without deleting your settings from the config file,
change the ``enabled`` value as follows:
2018-01-18 13:23:05 +01:00
2018-02-27 18:40:50 +01:00
- ``1``, ``yes``, ``True`` or ``on``: Enables the proxy
- ``0``, ``no``, ``False`` or ``off``: Disables the proxy
2018-01-18 13:23:05 +01:00
2018-03-25 21:30:39 +02:00
- Alternatively, you can setup your proxy without the need of the ``config.ini`` file by using the *proxy* parameter
2018-02-27 18:18:25 +01:00
in the Client class:
2018-02-22 11:02:38 +01:00
2018-02-27 18:18:25 +01:00
.. code-block:: python
2018-02-22 11:02:38 +01:00
2018-02-27 18:18:25 +01:00
from pyrogram import Client
2018-02-22 11:02:38 +01:00
app = Client(
2018-02-27 18:18:25 +01:00
session_name="example",
proxy=dict(
hostname="11.22.33.44",
port=1080,
username="<your_username>",
password="<your_password>"
)
)
2018-02-22 11:02:38 +01:00
app.start()
2018-02-22 11:02:38 +01:00
2018-02-27 18:18:25 +01:00
...
2018-02-22 11:02:38 +01:00
2018-03-25 21:30:39 +02:00
.. note:: If your proxy doesn't require authorization you can omit ``username`` and ``password`` by either leaving the
2018-02-22 11:02:38 +01:00
values blank/empty or completely delete the lines.