mtprototest

package
v0.2.0-dev.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mtprototest contains the fake Telegram DC used by proxy tests. Its small client wrappers use the production Fake TLS and obfuscated2 client so tests can run it against the server.

Index

Constants

View Source
const (
	TagAbridged     uint32 = mtclient.TagAbridged
	TagIntermediate uint32 = 0xeeeeeeee
	TagPadded       uint32 = 0xdddddddd
)

Transport tags (header bytes 56..60).

Variables

View Source
var ErrNotProxy = mtclient.ErrNotProxy

Functions

func Echo

func Echo(c *DCConn)

Echo answers every read with "dc:" and the bytes read.

func Hello

func Hello(key [16]byte, domain string, unix uint32) []byte

Hello is a ClientHello record shaped like tdlib's: TLS 1.3 suites after a GREASE value, SNI, an X25519 key share, supported_versions, padding to 517 bytes, and HMAC-SHA256(key, record with a zero random) in the random field with the last four bytes XORed with unix (little-endian).

Types

type Client

type Client = mtclient.Client

Client and Start keep the proxy tests on the production client implementation.

func Start

func Start(conn net.Conn, key [16]byte, hello []byte) (*Client, error)

type DC

type DC struct {
	Addr     string
	Accepted atomic.Int32
	Headers  chan [64]byte // every header received, as sent
}

DC is a fake Telegram DC: it takes plain obfuscated2 (no proxy key) and hands each connection to Serve.

func NewDC

func NewDC(t testing.TB, serve func(*DCConn)) *DC

NewDC listens on loopback until the test ends.

type DCConn

type DCConn struct {
	*net.TCPConn
	Tag uint32
	DC  int16
	// contains filtered or unexported fields
}

DCConn is one connection to the fake DC, decrypted.

func (*DCConn) Read

func (c *DCConn) Read(p []byte) (int, error)

func (*DCConn) Write

func (c *DCConn) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL