Listener is a simple net.Listener wrapper for listening
MTProto transport connections.codecfunc() Codeclistenernet.Listener Accept waits for and returns the next connection to the listener. Addr returns the listener's network address. Close closes the listener.
Any blocked Accept operations will be unblocked and return errors.
Listener : io.Closer
func Listen(listener net.Listener) Listener
func ListenCodec(codec func() Codec, listener net.Listener) Listener
Protocol is MTProto transport protocol.
See https://core.telegram.org/mtproto/mtproto-transportscodecfunc() Codec Codec creates new codec using protocol settings. CodecNoHeader is Codec without header. Handshake inits given net.Conn as MTProto connection. Pipe creates an in-memory MTProto connection.
Protocol : github.com/gotd/td/telegram/dcs.Protocol
Protocol : github.com/gotd/td/telegram/dcs.protocol
func NewProtocol(getCodec func() Codec) Protocol
var Abridged
var Full
var Intermediate
var PaddedIntermediate
connection is MTProto connection.codecCodecconnnet.ConnreadMuxsync.MutexwriteMuxsync.Mutex Close closes MTProto connection. Recv reads message to buffer using MTProto connection. Send sends message from buffer using MTProto connection.
*connection : Conn
*connection : io.Closer
Connnet.Connreaderio.Readerwriterio.Writer Close closes the connection.
Any blocked Read or Write operations will be unblocked and return errors. LocalAddr returns the local network address, if known.(*obfConn) Read(p []byte) (int, error) RemoteAddr returns the remote network address, if known. SetDeadline sets the read and write deadlines associated
with the connection. It is equivalent to calling both
SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations
fail instead of blocking. The deadline applies to all future
and pending I/O, not just the immediately following call to
Read or Write. After a deadline has been exceeded, the
connection can be refreshed by setting a deadline in the future.
If the deadline is exceeded a call to Read or Write or to other
I/O methods will return an error that wraps os.ErrDeadlineExceeded.
This can be tested using errors.Is(err, os.ErrDeadlineExceeded).
The error's Timeout method will return true, but note that there
are other possible errors for which the Timeout method will
return true even if the deadline has not been exceeded.
An idle timeout can be implemented by repeatedly extending
the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out. SetReadDeadline sets the deadline for future Read calls
and any currently-blocked Read call.
A zero value for t means Read will not time out. SetWriteDeadline sets the deadline for future Write calls
and any currently-blocked Write call.
Even if write times out, it may return n > 0, indicating that
some of the data was successfully written.
A zero value for t means Write will not time out.(*obfConn) Write(p []byte) (int, error)
*obfConn : internal/bisect.Writer
obfConn : io.Closer
*obfConn : io.ReadCloser
*obfConn : io.Reader
*obfConn : io.ReadWriteCloser
*obfConn : io.ReadWriter
*obfConn : io.WriteCloser
*obfConn : io.Writer
*obfConn : net.Conn
*obfConn : crypto/tls.transcriptHash
listenernet.Listener Accept waits for and returns the next connection to the listener. Addr returns the listener's network address. Close closes the listener.
Any blocked Accept operations will be unblocked and return errors.
obfListener : io.Closer
obfListener : net.Listener
onceCloseListener wraps a net.Listener, protecting it from
multiple Close calls.Listenernet.Listenererrerroroncesync.Once Accept waits for and returns the next connection to the listener. Addr returns the listener's network address.(*onceCloseListener) Close() error
*onceCloseListener : io.Closer
*onceCloseListener : net.Listener
Connnet.Connreaderio.Reader Close closes the connection.
Any blocked Read or Write operations will be unblocked and return errors. LocalAddr returns the local network address, if known.( wrappedConn) Read(b []byte) (int, error) RemoteAddr returns the remote network address, if known. SetDeadline sets the read and write deadlines associated
with the connection. It is equivalent to calling both
SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations
fail instead of blocking. The deadline applies to all future
and pending I/O, not just the immediately following call to
Read or Write. After a deadline has been exceeded, the
connection can be refreshed by setting a deadline in the future.
If the deadline is exceeded a call to Read or Write or to other
I/O methods will return an error that wraps os.ErrDeadlineExceeded.
This can be tested using errors.Is(err, os.ErrDeadlineExceeded).
The error's Timeout method will return true, but note that there
are other possible errors for which the Timeout method will
return true even if the deadline has not been exceeded.
An idle timeout can be implemented by repeatedly extending
the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out. SetReadDeadline sets the deadline for future Read calls
and any currently-blocked Read call.
A zero value for t means Read will not time out. SetWriteDeadline sets the deadline for future Write calls
and any currently-blocked Write call.
Even if write times out, it may return n > 0, indicating that
some of the data was successfully written.
A zero value for t means Write will not time out. Write writes data to the connection.
Write can be made to time out and return an error after a fixed
time limit; see SetDeadline and SetWriteDeadline.
wrappedConn : internal/bisect.Writer
wrappedConn : io.Closer
wrappedConn : io.ReadCloser
wrappedConn : io.Reader
wrappedConn : io.ReadWriteCloser
wrappedConn : io.ReadWriter
wrappedConn : io.WriteCloser
wrappedConn : io.Writer
wrappedConn : net.Conn
wrappedConn : crypto/tls.transcriptHash
Connnet.Connclosedtdsync.Readyreaderio.Readerwriterio.Writer(*wsServerConn) Close() error LocalAddr returns the local network address, if known.(*wsServerConn) Read(p []byte) (int, error) RemoteAddr returns the remote network address, if known. SetDeadline sets the read and write deadlines associated
with the connection. It is equivalent to calling both
SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations
fail instead of blocking. The deadline applies to all future
and pending I/O, not just the immediately following call to
Read or Write. After a deadline has been exceeded, the
connection can be refreshed by setting a deadline in the future.
If the deadline is exceeded a call to Read or Write or to other
I/O methods will return an error that wraps os.ErrDeadlineExceeded.
This can be tested using errors.Is(err, os.ErrDeadlineExceeded).
The error's Timeout method will return true, but note that there
are other possible errors for which the Timeout method will
return true even if the deadline has not been exceeded.
An idle timeout can be implemented by repeatedly extending
the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out. SetReadDeadline sets the deadline for future Read calls
and any currently-blocked Read call.
A zero value for t means Read will not time out. SetWriteDeadline sets the deadline for future Write calls
and any currently-blocked Write call.
Even if write times out, it may return n > 0, indicating that
some of the data was successfully written.
A zero value for t means Write will not time out.(*wsServerConn) Write(p []byte) (int, error)
*wsServerConn : internal/bisect.Writer
*wsServerConn : io.Closer
*wsServerConn : io.ReadCloser
*wsServerConn : io.Reader
*wsServerConn : io.ReadWriteCloser
*wsServerConn : io.ReadWriter
*wsServerConn : io.WriteCloser
*wsServerConn : io.Writer
*wsServerConn : net.Conn
*wsServerConn : crypto/tls.transcriptHash
Package-Level Functions (total 6, in which 5 are exported)
Listen creates new Listener using given net.Listener.
Transport codec will be detected automatically.
ListenCodec creates new Listener using given net.Listener.
Listener will always use given Codec constructor.
NewProtocol creates new transport protocol using user Codec constructor.
See https://core.telegram.org/mtproto/mtproto-transports
ObfuscatedListener creates new obfuscated2 listener using given net.Listener.
Useful for creating Telegram servers:
transport.Listen(transport.ObfuscatedListener(ln))
WebsocketListener creates new MTProto Websocket listener.
Package-Level Variables (total 4, all are exported)
Abridged is abridged transport protocol.
See https://core.telegram.org/mtproto/mtproto-transports#abridged
Full is full transport protocol.
See https://core.telegram.org/mtproto/mtproto-transports#full
Intermediate is intermediate transport protocol.
See https://core.telegram.org/mtproto/mtproto-transports#intermediate
PaddedIntermediate is padded intermediate transport protocol.
See https://core.telegram.org/mtproto/mtproto-transports#padded-intermediate
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.