transport

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 5 * time.Second

Variables

View Source
var ErrClosed = errors.New("reader closed")

Functions

func FormatWebSocketURI added in v1.6.7

func FormatWebSocketURI(host string, tls bool, dc int, testMode bool) string

func NewObfuscatedConn added in v1.6.7

func NewObfuscatedConn(conn io.ReadWriteCloser, protocolID []byte) (*obfuscatedConn, error)

func ParseMTProxyURL added in v1.7.0

func ParseMTProxyURL(urlStr string) (*utils.Proxy, error)

func ProtocolID added in v1.6.7

func ProtocolID(variant uint8) []byte

Types

type CommonConfig added in v1.6.10

type CommonConfig struct {
	Ctx         context.Context
	Host        string
	Timeout     time.Duration
	Socks       *utils.Proxy
	LocalAddr   string
	ModeVariant uint8
	DC          int
	Logger      *utils.Logger
}

CommonConfig contains shared configuration fields for all transport types

type Conn

type Conn io.ReadWriteCloser

func DialMTProxy added in v1.6.7

func DialMTProxy(ctx context.Context, proxy *utils.Proxy, targetHost string, dcID int16, modeVariant uint8, localAddr string, logger *utils.Logger) (Conn, error)

func NewTCP

func NewTCP(cfg TCPConnConfig) (Conn, bool, error)

func NewWebSocket added in v1.6.7

func NewWebSocket(cfg WSConnConfig) (Conn, error)

type ConnConfig

type ConnConfig any

type ErrCode

type ErrCode int64

func (ErrCode) Error

func (e ErrCode) Error() string

type ErrNotMultiple

type ErrNotMultiple struct {
	Len int
}

func (*ErrNotMultiple) Error

func (e *ErrNotMultiple) Error() string

type MTProxyConfig added in v1.6.7

type MTProxyConfig struct {
	Host, Port    string
	Secret        []byte
	FakeTlsDomain []byte
}

func ParseMTProxySecret added in v1.7.0

func ParseMTProxySecret(secret string) (*MTProxyConfig, error)

type Mode

type Mode interface {
	WriteMsg(msg []byte) error // this is not same as the io.Writer
	ReadMsg() ([]byte, error)
}

type ModeConfig

type ModeConfig = func(Conn) (Mode, error)

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

func NewReader

func NewReader(ctx context.Context, r io.Reader) *Reader

func (*Reader) Close added in v1.6.10

func (c *Reader) Close() error

func (*Reader) Read

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

type TCPConnConfig

type TCPConnConfig struct {
	CommonConfig
	IpV6 bool
}

type Transport

type Transport interface {
	Close() error
	WriteMsg(msg messages.Common, seqNo int32) error
	ReadMsg() (messages.Common, error)
}

func NewTransport

func NewTransport(m messages.MessageInformator, conn ConnConfig, modeVariant mode.Variant) (Transport, error)

type WSConnConfig added in v1.6.7

type WSConnConfig struct {
	CommonConfig
	TLS      bool
	TestMode bool
}

Jump to

Keyboard shortcuts

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