Documentation
¶
Overview ¶
Package mtproxy implements MTProxy client support for connecting to Telegram through intermediate proxy servers.
MTProxy allows bypassing network restrictions by tunneling MTProto traffic through a proxy that mimics normal TLS or uses obfuscated transport.
Three secret types are supported:
- Simple (32 hex chars): raw 16-byte secret, uses obfuscated2 transport.
- dd-prefixed (34 hex chars): tag byte + 16-byte secret, uses obfuscated2 with PaddedIntermediate codec (most common).
- ee-prefixed (36+ hex chars): tag byte + 16-byte secret + domain name, uses fake TLS handshake followed by obfuscated2.
Basic usage:
conn, err := mtproxy.Dial(
"proxy.example.com:443",
"dd05fb7acb549be047a7c585116581418",
2, // DC ID
30 * time.Second,
)
Or via the client config:
client, _ := telegram.NewClient(apiID, apiHash, &telegram.Config{
MTProxy: &telegram.MTProxyConfig{
Addr: "proxy.example.com:443",
Secret: "dd05fb7acb549be047a7c585116581418",
},
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidSecretLen is returned when the MTProxy secret is not 16 bytes // (standard), 17 bytes (with DD prefix for TLS), or 18+ bytes (with // domain for fake TLS). ErrInvalidSecretLen = errors.New("mtproxy: secret must be 16, 17, or 18+ bytes") // ErrServerHelloFailed is returned when the server's hello response // cannot be verified against the expected key derived from the secret. ErrServerHelloFailed = errors.New("mtproxy: server hello verification failed") )
MTProxy errors.
These errors are returned during MTProxy connection setup and the specialized handshake.
Functions ¶
func Dial ¶
Dial connects to an MTProxy server and returns a net.Conn ready for MTProto traffic. The secret is parsed from hex and the connection is established with the appropriate obfuscation (dd: obfuscated2 only, ee: fake TLS + obfuscated2, simple: obfuscated2 only).
func DialSecret ¶
DialSecret connects to an MTProxy server using a parsed Secret.
Types ¶
type Secret ¶
type Secret struct {
Type SecretType
Secret []byte // 16-byte secret
Tag byte // protocol tag (0xdd, 0xee, 0xef)
Domain string // SNI domain (ee-secrets only)
}
func ParseSecret ¶
func ParseSecretBytes ¶
func (Secret) NeedsFakeTLS ¶
type SecretType ¶
type SecretType int
const ( SecretSimple SecretType = iota SecretSecured // dd-prefix: tag(1) + secret(16) SecretTLS // ee-prefix: tag(1) + secret(16) + domain )