From 372861ac6e3dd3d1d4996282f0905c36c5163fba Mon Sep 17 00:00:00 2001 From: Alexander Bersenev Date: Fri, 29 Jun 2018 18:51:47 +0500 Subject: [PATCH] support for secure mode --- mtprotoproxy.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mtprotoproxy.py b/mtprotoproxy.py index 9a50ed3..a381f48 100755 --- a/mtprotoproxy.py +++ b/mtprotoproxy.py @@ -430,6 +430,10 @@ class MTProtoIntermediateFrameStreamReader(LayeredStreamReaderBase): data = await self.upstream.readexactly(msg_len) + if msg_len % 4 != 0: + cut_border = msg_len - (msg_len % 4) + data = data[:cut_border] + return data, extra @@ -847,7 +851,7 @@ async def handle_client(reader_clt, writer_clt): if proto_tag == PROTO_TAG_ABRIDGED: reader_clt = MTProtoCompactFrameStreamReader(reader_clt) writer_clt = MTProtoCompactFrameStreamWriter(writer_clt) - elif proto_tag == PROTO_TAG_INTERMEDIATE: + elif proto_tag in (PROTO_TAG_INTERMEDIATE, PROTO_TAG_SECURE): reader_clt = MTProtoIntermediateFrameStreamReader(reader_clt) writer_clt = MTProtoIntermediateFrameStreamWriter(writer_clt) else: @@ -1033,6 +1037,10 @@ def print_tg_info(): params_encodeded = urllib.parse.urlencode(params, safe=':') print("{}: tg://proxy?{}".format(user, params_encodeded), flush=True) + params = {"server": ip, "port": PORT, "secret": "dd" + secret} + params_encodeded = urllib.parse.urlencode(params, safe=':') + print("{}: tg://proxy?{} (beta)".format(user, params_encodeded), flush=True) + def loop_exception_handler(loop, context): exception = context.get("exception")