Skip to content

mtproto ​

The Telegram proxy (MTProxy) with ee secrets: the client makes a fake TLS handshake that its secret signs, then obfuscated2 follows in the same TLS records. The inbound decrypts the client's side, encrypts it again for the Telegram datacenter the client named and hands routing a plain TCP connection to 149.154.x.x:443 (with ipv6: true, to 2001:…::a). Telegram's traffic can therefore leave through any outbound — direct, vless, wireguard and so on.

A connection that no secret signs (a scanner, a browser, a replayed handshake) goes to fallbacks, so the port answers as the site it stands in front of.

Inbound only. Not supported: secrets without a prefix or with dd (easy to recognise), and Telegram's middle proxies, and with them ad_tag (a sponsored channel).

Inbound ​

FieldTypeDefaultMeaning
userslist of {name, secret}requiredsecret is 32 hex digits, or the client's whole secret: ee, those digits and the domain in hex
ipv6boolfalseConnect to the datacenters over IPv6 rather than IPv4
fallbackslist of rules—Where a stranger's connection goes: fallbacks without name, alpn and path (fake TLS has none of them); xver is the PROXY header

Socket settings are the listener block. There is no tls block: the TLS is fake. A change of users alone applies without rebuilding the inbound.

Example ​

yaml
inbounds:
  tg:
    mtproto:
      listen: 0.0.0.0:443
      users:
        - name: alice
          secret: 0123456789abcdef0123456789abcdef
      fallbacks:
        - server: www.example.com:443
outbounds:
  direct:
    direct:
route:
  final:
    outbound: direct

The client's link: tg://proxy?server=<address>&port=443&secret=ee<secret><domain in hex>, the domain being the site of fallbacks (www.example.com → 7777772e6578616d706c652e636f6d). The client puts it in the SNI; the inbound does not require the SNI to match it.

Differences from MTProxy and telemt (a Rust MTProxy server) ​

  • The time in the handshake's signature may differ from the server's clock by 2 minutes at most, as in MTProxy; a replayed signed handshake goes to fallbacks.
  • A datacenter index outside 1–5 leads to the second datacenter, a negative one (media) to the same datacenter as the positive one.
  • What follows the ServerHello is 2–4 KiB of random data, not sizes taken from a real site.

GPL-3.0-or-later