67 Commits

Author SHA1 Message Date
Alexander Bersenev
37d570f8dc handle unknown ips, e.g. from unix sockets 2020-03-05 13:55:10 +05:00
Alexander Bersenev
8f48e9ef65 fix the missing constant 2020-02-27 19:17:15 +05:00
Alexander Bersenev
76bc2253eb small code style fixes 2020-02-25 20:41:08 +05:00
Alexander Bersenev
07bd9b795a handle bad secrets in configs 2020-02-25 02:41:49 +05:00
Alexander Bersenev
1cad031947 make dataflow functions top level functions for better speed and memory consumption 2020-02-23 03:03:15 +05:00
Alexander Bersenev
923dac842b handle broken pipe error 2020-02-17 12:18:13 +05:00
Alexander Bersenev
1a63fdae11 add an option to ignore time skew 2020-02-15 17:12:15 +05:00
Alexander Bersenev
c7b6dcf3c2 save the utilitary task as a variable to prevent early garbage collecting 2020-02-14 18:58:25 +05:00
Alexander Bersenev
a95b1ec3c1 fix typo 2020-02-13 18:21:09 +05:00
Alexander Bersenev
49bc5d1f3b get rid of "socket.send() raised exception" messages 2020-02-13 18:14:37 +05:00
Alexander Bersenev
c2414c3487 simplify dockerfile 2020-02-13 15:08:01 +05:00
Alexander Bersenev
8b26cc843d catch IncompleteReadError while handling a bad client 2020-02-13 14:22:32 +05:00
Alexander Bersenev
639dea5e8d use debian image by default 2020-02-13 04:13:49 +05:00
Alexander Bersenev
c48cacce83 add statisctics about up/down traffic 2020-02-12 16:28:18 +05:00
Alexander Bersenev
2bb0ef0b1f simplify initialization and stats 2020-02-12 15:41:05 +05:00
Alexander Bersenev
f5ee5db86f use asyncio.all_tasks on new pythons 2020-02-11 19:10:43 +05:00
Peter Dave Hello
9c50cab94e Fix file permission in Docker image (#189)
`chown` needs to be done "after" the file copy, otherwise there is no
meaning to do it as /home/tgproxy is default owned by tgproxy already.
2020-02-11 13:50:48 +02:00
Boris Klimenko
199eaeb7c4 Alpine 3.11, Python 3.8 (#185) 2020-01-22 20:04:29 +02:00
Alexander Bersenev
66ac871a74 remove the hackish logic against replay attacks because it stopped to work with new android clients
see https://github.com/alexbers/mtprotoproxy/issues/183
2020-01-16 19:05:18 +05:00
Alexander Bersenev
c5344df0eb Add wiki links to readme 2019-12-14 14:55:10 +05:00
Alexander Bersenev
93ad268d48 add ip logging 2019-11-29 17:30:10 +05:00
Alexander Bersenev
1c29465b6e change comment in config 2019-11-22 02:11:41 +05:00
Alexander Bersenev
d41b4abf35 MODES option instead of SECURE_ONLY and TLS_ONLY 2019-11-22 02:05:05 +05:00
Alexander Bersenev
7f19b3f78d more secure defaul settings 2019-11-19 05:22:49 +05:00
Alexander Bersenev
0549fd7200 increase the connection pool size 2019-11-19 05:00:53 +05:00
Alexander Bersenev
fd75ca3cf9 remove loop argument from create server for compatibility with Python 3.8 2019-11-14 02:43:10 +05:00
Alexander Bersenev
522b0cfe75 move more logic to pooled connection 2019-11-13 02:56:05 +05:00
Alexander Bersenev
4a4d449a34 init pooled connections to save one more round trip time 2019-11-13 02:31:51 +05:00
Alexander Bersenev
8c15fc8fe0 use socket from pool in the creation order 2019-11-12 04:31:47 +05:00
Alexander Bersenev
e436792992 introduce connection pool to reduce pings 2019-11-12 03:53:10 +05:00
K900
07759f67cb Fix running on Python 3.8 (#161)
3.8 removes the asyncio.streams re-export of `IncompleteReadError`, so just access it directly from `asyncio`, like everywhere else in the code already does.
2019-11-11 16:04:14 +05:00
Alexander Bersenev
f525cc9611 more strict validation of tls domain 2019-10-30 22:27:46 +05:00
dasmfm
c010543889 Prefix for Prometheus metrics (#151)
Added default prefix for Prometheus metrics.
2019-10-09 14:35:02 +05:00
Alexander Bersenev
0a41479054 add copy instruction to docker-compose 2019-10-09 01:56:48 +05:00
Alexander Bersenev
5f206361f2 revert the last commit 2019-10-09 01:56:06 +05:00
Alexander Bersenev
6980bfd3be add copy instruction to docker-compose 2019-10-09 01:52:09 +05:00
Alexander Bersenev
027ee2713b use tls-only mode in the default config 2019-10-08 14:44:09 +05:00
Alexander Bersenev
3c4c92cdb2 adjust stats duration bucket sizes 2019-10-08 14:42:03 +05:00
Alexander Bersenev
3ef826cd6b more logical name for connection duration 2019-09-21 23:55:53 +05:00
Alexander Bersenev
9ec1e543bd expose the length of connections as metrics 2019-09-21 23:17:00 +05:00
Alexander Bersenev
fae04ed3c7 do not export proxy links by default 2019-09-20 18:57:37 +05:00
Alexander Bersenev
25685f370c reword the link desc 2019-09-20 18:10:37 +05:00
Alexander Bersenev
1feb8e5fc7 export proxy links as metrics 2019-09-20 17:52:30 +05:00
Alexander Bersenev
5e488203a2 check for socks mode before importing uvloop 2019-09-20 17:26:30 +05:00
Alexander Bersenev
94fd98a1fb correct spelling 2019-09-20 17:19:33 +05:00
Alexander Bersenev
4c5b0803fa add upstream socks proxy consistency checks 2019-09-20 17:17:16 +05:00
Alexander Bersenev
8fa8aabc8e ability to specify socks user and pass 2019-09-20 16:13:06 +05:00
Alexander Bersenev
f2fbaa923b refactor upstream proxy handling 2019-09-20 16:06:59 +05:00
Alexander Bersenev
79eaabdd23 move socks handling in the config parsing 2019-09-20 15:40:33 +05:00
Alexander Bersenev
23c7b0d53b make the socks module optional 2019-09-20 15:38:18 +05:00
pasha-zzz
516600a32d Add support for upstream SOCKS5 proxy (#143) 2019-09-20 15:28:29 +05:00
Alexander Bersenev
5fcd1c0158 change metrics pushes to pulls 2019-09-19 02:27:57 +05:00
Alexander Bersenev
781549f37f update readme 2019-09-19 00:08:20 +05:00
Alexander Bersenev
dc1223fd90 add hanshake_timeout metric 2019-09-18 23:22:06 +05:00
Alexander Bersenev
0d52ae0bc7 rename metrics, add connects_all metric 2019-09-18 23:13:32 +05:00
Alexander Bersenev
2b1469985d add an ability to export metrics to prometheus 2019-09-18 19:44:19 +05:00
Alexander Bersenev
4784491800 use only half of the digest as a key for used digest 2019-09-13 17:20:32 +05:00
Alexander Bersenev
7a2c6b9825 cast client port to int 2019-09-13 01:19:19 +05:00
Alexander Bersenev
37307a98fb print replay attackers summary 2019-09-08 14:28:46 +05:00
Alexander Bersenev
02b39168c3 print the possible replay-attackers summary instead of every time 2019-09-08 14:12:06 +05:00
Alexander Bersenev
163e7b7cce print a message about getting the cert 2019-09-08 03:12:19 +05:00
Alexander Bersenev
1ed13d9efa get rid from annoying time skew messages, print summary instead 2019-09-08 02:01:23 +05:00
Alexander Bersenev
51c8d68271 disable the first bad packet heuristics if the tls-only mode activated, it has time-based protection instead 2019-09-08 01:09:44 +05:00
Alexander Bersenev
50cd74051f add a message if uvloop is found 2019-08-30 16:05:08 +05:00
Alexander Bersenev
1d826866d1 print time skew message as one line 2019-08-26 17:00:34 +05:00
Alexander Bersenev
ff6b826e13 do not output canceled errors to get rid from scarry traceback on the proxy termination 2019-08-26 16:51:48 +05:00
Alexander Bersenev
3315ac1df6 add one more param into the undocummented mode of launch 2019-08-26 16:07:35 +05:00
4 changed files with 636 additions and 222 deletions

View File

@@ -1,11 +1,14 @@
FROM alpine:3.10
FROM python:3.8-slim-buster
RUN adduser tgproxy -u 10000 -D
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 apk add --no-cache python3 py3-cryptography ca-certificates libcap
RUN pip3 --no-cache-dir install cryptography uvloop
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.7
USER tgproxy

View File

@@ -1,6 +1,6 @@
# Async MTProto Proxy #
Fast and simple to setup mtproto proxy written on Python.
Fast and simple to setup MTProto proxy written in Python.
## Starting Up ##
@@ -20,10 +20,15 @@ To advertise a channel get a tag from **@MTProxybot** and put it to *config.py*.
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 for [Prometheus](https://prometheus.io/): using [prometheus](https://github.com/alexbers/mtprotoproxy/tree/prometheus) branch
- with runtime statistics exported to [Prometheus](https://prometheus.io/)

View File

@@ -1,20 +1,25 @@
PORT = 3256
PORT = 443
# name -> secret (32 hex chars)
USERS = {
"tg": "00000000000000000000000000000000",
"tg2": "0123456789abcdef0123456789abcdef"
"tg": "00000000000000000000000000000001",
# "tg2": "0123456789abcdef0123456789abcdef",
}
# Makes the proxy harder to detect
# Can be incompatible with very old clients
SECURE_ONLY = True
MODES = {
# Classic mode, easy to detect
"classic": False,
# Makes the proxy even more hard to detect
# Compatible only with the recent clients
# TLS_ONLY = True
# Makes the proxy harder to detect
# Can be incompatible with very old clients
"secure": False,
# The domain for TLS, bad clients are proxied there
# 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"

File diff suppressed because it is too large Load Diff