Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInterfaceIsNil = errors.New("interface is nil") ErrModeNotSupported = errors.New("mode is not supported") ErrAmbiguousModeAnnounce = errors.New("ambiguous mode announce, expected other byte sequence") )
var (
ErrChecksumMismatch = errors.New("checksum mismatch")
)
Functions ¶
func GetProtocolID ¶ added in v1.6.7
Types ¶
type ErrNotMultiple ¶
type ErrNotMultiple struct {
Len int
}
func (ErrNotMultiple) Error ¶
func (e ErrNotMultiple) Error() string
type Mode ¶
type Mode interface {
WriteMsg([]byte) error // this is not same as the io.Writer
ReadMsg() ([]byte, error)
// contains filtered or unexported methods
}
Mode is an interface that defines how the connection sides determine the size of transmitted messages. Unlike HTTP or UDP connections, raw TCP connections and WebSockets don't have a standard way to determine the size of transmitted or received messages. Their main purpose is to transmit bytes in the correct order. Mode allows the connection sides to avoid analyzing traffic or using end-of-message sequences.
In the MTProto world, Mode acts like a microprotocol. It packages messages in a container that announces its size in advance.
func Detect ¶
func Detect(conn io.ReadWriter) (Mode, error)
Detect detects mode based on first byte sequence returned from conn
func NewWithoutAnnouncement ¶ added in v1.6.7
func NewWithoutAnnouncement(v Variant, conn io.ReadWriter) (Mode, error)
NewWithoutAnnouncement creates a mode without sending the announcement Used for obfuscated connections where protocol ID is embedded in obfuscation handshake