py-mtproxy-lib 0.0.2__tar.gz → 0.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: py-mtproxy-lib
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: Production-ready MTProto proxy server library with multi-secret support, statistics, and daemon mode
5
5
  Home-page: https://github.com/twosleepynights0x1/py-mtproxy-lib
6
- Author: Your Name
6
+ Author: AneK
7
7
  Author-email: tashova28@gmail.com
8
8
  Project-URL: Bug Reports, https://github.com/twosleepynights0x1/py-mtproxy-lib
9
9
  Keywords: mtproto telegram proxy vpn daemon docker
@@ -0,0 +1,48 @@
1
+ """Вспомогательные функции"""
2
+
3
+ import secrets
4
+ import hashlib
5
+ import hmac
6
+ from typing import Optional
7
+ import urllib.request
8
+
9
+
10
+ def generate_secret() -> str:
11
+ """
12
+ Генерация случайного секрета для MTProto прокси
13
+
14
+ Returns:
15
+ str: Hex-строка секрета (32 символа)
16
+ """
17
+ return secrets.token_hex(16)
18
+
19
+
20
+ def verify_fake_tls_handshake(data: bytes, secret: bytes) -> bool:
21
+ """
22
+ Проверка Fake TLS handshake
23
+
24
+ Структура:
25
+ - Byte 0: 0x16 (TLS handshake)
26
+ - Bytes 1-2: Protocol version
27
+ - Bytes 3-4: Length
28
+ - Bytes 5-10: Random
29
+ - Bytes 11-42: Digest (HMAC-SHA256)
30
+ - Bytes 43-50: Timestamp
31
+ """
32
+ if not data or len(data) < 51 or data[0] != 0x16:
33
+ return False
34
+
35
+ digest = data[11:43]
36
+ timestamp = data[43:51]
37
+ expected = hmac.new(secret, timestamp, hashlib.sha256).digest()[:32]
38
+
39
+ return hmac.compare_digest(digest, expected)
40
+
41
+
42
+ def get_external_ip() -> Optional[str]:
43
+ """Получение внешнего IP сервера"""
44
+ try:
45
+ with urllib.request.urlopen('https://ifconfig.me', timeout=5) as response:
46
+ return response.read().decode('utf-8').strip()
47
+ except Exception:
48
+ return None
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: py-mtproxy-lib
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: Production-ready MTProto proxy server library with multi-secret support, statistics, and daemon mode
5
5
  Home-page: https://github.com/twosleepynights0x1/py-mtproxy-lib
6
- Author: Your Name
6
+ Author: AneK
7
7
  Author-email: tashova28@gmail.com
8
8
  Project-URL: Bug Reports, https://github.com/twosleepynights0x1/py-mtproxy-lib
9
9
  Keywords: mtproto telegram proxy vpn daemon docker
@@ -7,6 +7,7 @@ mtproxy/daemon.py
7
7
  mtproxy/logger.py
8
8
  mtproxy/server.py
9
9
  mtproxy/stats.py
10
+ mtproxy/utils.py
10
11
  py_mtproxy_lib.egg-info/PKG-INFO
11
12
  py_mtproxy_lib.egg-info/SOURCES.txt
12
13
  py_mtproxy_lib.egg-info/dependency_links.txt
@@ -5,8 +5,8 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="py-mtproxy-lib",
8
- version="0.0.2",
9
- author="Your Name",
8
+ version="0.0.3",
9
+ author="AneK",
10
10
  author_email="tashova28@gmail.com",
11
11
  description="Production-ready MTProto proxy server library with multi-secret support, statistics, and daemon mode",
12
12
  long_description=long_description,
File without changes
File without changes