Add native MTProxy support#298
Open
makarovstas wants to merge 5 commits into
Open
Conversation
Contributor
Author
|
@KurimuzonAkuma hi bratello 🙂 |
Owner
|
@makarovstas Да там вайбкод нейрослоп от клода, я еще не тестил, боюсь..... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds first-class MTProxy support directly into the transport layer. Users can now connect through an MTProxy server by passing
scheme: "mtproxy"in the proxy dict — the same way SOCKS5 proxies are configured.All three secret formats are supported:
ee<32 hex><domain hex>dd<32 hex><32 hex>Usage
The secret is the standard MTProxy secret string from the proxy's connection link (tg://proxy?...).
Implementation details
TCP — new _connect_via_mtproxy, _connect_via_mtproxy_obf2, _connect_via_mtproxy_faketls methods handle the handshake; send/recv transparently encrypt/decrypt traffic using AES-CTR once the connection is established
TCPAbridged — skips the abridged \xef marker byte for MTProxy connections (the protocol tag is embedded in the obfuscation nonce instead)
Connection — injects dc_id into the proxy dict before passing it to the transport so the nonce can encode the target DC
ProxyDict — added optional secret field
Fake-TLS implementation follows the mtprotoproxy spec: HMAC-SHA256 signed ClientHello padded to ≥ 512 bytes, padded-intermediate framing (0xdd × 4) after the TLS handshake.