mirror of
https://github.com/alexbers/mtprotoproxy.git
synced 2026-03-14 07:13:09 +00:00
f51a4bfe34cd6be5dfb49d567405a767ff8a75f4
* add proxy protocol v1/v2 support With fake-tls enabled, it was still quite hard to use mtprotoproxy as backend behing some reverse https/tls proxy (nginx, haproxy, etc) because it still need client address & port info. With nginx already configured to use stream proxy with proxy protocol, it was impossibe to connect due additional proxy header transmission before real hadshake. Adding general support of proxy protocol fixed both issues. New config option PROXY_PROTOCOL = True enables transparent support, unproxied incoming connections will still be accepted. Since reverse proxy needs to be trusted, option disabled by default. References: * https://www.haproxy.com/blog/haproxy/proxy-protocol/ * http://haproxy.1wt.eu/download/1.5/doc/proxy-protocol.txt * slightly optimize proxy v1 error path * rework proxy handler * deny direct connection with enabled PROXY_PROTOCOl per specs * simplify proxy header checking * use textual form of proxy v1 header * drop useless find() call * fix client address logging
Async MTProto Proxy
Fast and simple to setup mtproto proxy.
Starting Up
git clone -b stable https://github.com/alexbers/mtprotoproxy.git; cd mtprotoproxy- (optional, recommended) edit config.py, set PORT, USERS and AD_TAG
docker-compose up --build -d(or justpython3 mtprotoproxy.pyif you don't like docker)- (optional, shows telegram link to set the proxy)
docker-compose logs
Channel Advertising
To advertise a channel get a tag from @MTProxybot and write it to config.py.
Performance
The proxy performance should be enough to comfortably serve about 4 000 simultaneous users on the VDS instance with 1 CPU core and 1024MB RAM.
Advanced Usage
The proxy can be launched:
- with a custom config:
python3 mtprotoproxy.py [configfile] - several times, clients will be automaticaly balanced between instances
- using PyPy interprteter
- with runtime statistics exported for Prometheus: using prometheus branch
Description
Languages
Python
99.7%
Dockerfile
0.3%