Using a proxy

How to set a proxy

In order to set a proxy for MadelineProto, you have to modify the settings.
Legacy proxy names are allowed (\HttpProxy, \SocksProxy), but not recommended.
The recommended way of getting proxy names to set in the settings is through the getName method of the new proxy interface.

Multiple proxies with automatic switch

To set multiple proxies, and let MadelineProto choose the best one, simply assign arrays of proxy and proxy extras to the appropriate settings.
You can also use iterable objects instead of arrays of proxy settings to dynamically change the proxies used without reloading the settings.

Build your proxy

In order to build your proxy, you have to use the new MadelineProto stream API to create your own proxy class.
Feel free to study existing proxies and the stream API: it’s well structured and well documented, so feel free to read the code.
Don’t forget to add support for TLS connections as well!