1 Commits

Author SHA1 Message Date
Alexander Bersenev
7fcc854e80 add Prometheus metrics exporter 2018-07-01 01:35:50 +05:00
5 changed files with 455 additions and 1636 deletions

View File

@@ -1,16 +1,15 @@
FROM python:3.8-slim-buster
FROM alpine:3.6
RUN apt-get update && apt-get install -y libcap2-bin && rm -rf /var/lib/apt/lists/*
RUN setcap cap_net_bind_service=+ep /usr/local/bin/python3.8
RUN adduser tgproxy -u 10000 -D
RUN pip3 --no-cache-dir install cryptography uvloop
RUN apk add --no-cache python3 py3-cryptography ca-certificates libcap
COPY mtprotoproxy.py config.py /home/tgproxy/
RUN useradd tgproxy -u 10000
RUN chown -R tgproxy:tgproxy /home/tgproxy
RUN setcap cap_net_bind_service=+ep /usr/bin/python3.6
USER tgproxy
WORKDIR /home/tgproxy/
CMD ["python3", "mtprotoproxy.py"]
CMD ["./mtprotoproxy.py"]

View File

@@ -1,34 +1,26 @@
# Async MTProto Proxy #
Fast and simple to setup MTProto proxy written in Python.
Fast and simple to setup mtproto proxy.
## Starting Up ##
1. `git clone -b stable https://github.com/alexbers/mtprotoproxy.git; cd mtprotoproxy`
2. *(optional, recommended)* edit *config.py*, set **PORT**, **USERS** and **AD_TAG**
3. `docker-compose up -d` (or just `python3 mtprotoproxy.py` if you don't like Docker)
4. *(optional, get a link to share the proxy)* `docker-compose logs`
![Demo](https://alexbers.com/mtprotoproxy/install_demo_v2.gif)
3. `docker-compose up --build -d` (or just `python3 mtprotoproxy.py` if you don't like docker)
4. *(optional, shows telegram link to set the proxy)* `docker-compose logs`
## Channel Advertising ##
To advertise a channel get a tag from **@MTProxybot** and put it to *config.py*.
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.
## More Instructions ##
- [Running without Docker](https://github.com/alexbers/mtprotoproxy/wiki/Running-Without-Docker)
- [Optimization and fine tuning](https://github.com/alexbers/mtprotoproxy/wiki/Optimization-and-Fine-Tuning)
## Advanced Usage ##
The proxy can be launched:
- with a custom config: `python3 mtprotoproxy.py [configfile]`
- several times, clients will be automaticaly balanced between instances
- with uvloop module to get an extra speed boost
- with runtime statistics exported to [Prometheus](https://prometheus.io/)
- using *PyPy* interprteter

View File

@@ -1,27 +1,10 @@
PORT = 443
PORT = 3256
# name -> secret (32 hex chars)
USERS = {
"tg": "00000000000000000000000000000001",
# "tg2": "0123456789abcdef0123456789abcdef",
"tg": "00000000000000000000000000000000",
"tg2": "0123456789abcdef0123456789abcdef"
}
MODES = {
# Classic mode, easy to detect
"classic": False,
# Makes the proxy harder to detect
# Can be incompatible with very old clients
"secure": False,
# Makes the proxy even more hard to detect
# Can be incompatible with old clients
"tls": True
}
# The domain for TLS mode, bad clients are proxied there
# Use random existing domain, proxy checks it on start
# TLS_DOMAIN = "www.google.com"
# Tag for advertising, obtainable from @MTProxybot
# AD_TAG = "3c09c680b76ee91a4c25ad51f742267d"

View File

@@ -4,7 +4,4 @@ services:
build: .
restart: unless-stopped
network_mode: "host"
volumes:
- ./config.py:/home/tgproxy/config.py
- ./mtprotoproxy.py:/home/tgproxy/mtprotoproxy.py
# mem_limit: 1024m

File diff suppressed because it is too large Load Diff