packet

package
v0.0.0-...-96fb606 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinCompressionLength = 50
	DefaultBufferSize    = 16 * 1024
	// DefaultReadBufferSize is the bufio.Reader size used by NewConn and
	// EnableReadBuffering.
	DefaultReadBufferSize = 64 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	net.Conn

	Sequence uint8

	Compression uint8

	CompressedSequence uint8
	// contains filtered or unexported fields
}

Conn is the base class to handle MySQL protocol.

func NewBufferedConn

func NewBufferedConn(conn net.Conn, bufferSize int) *Conn

func NewConn

func NewConn(conn net.Conn) *Conn

func NewConnWithTimeout

func NewConnWithTimeout(conn net.Conn, readTimeout, writeTimeout time.Duration, bufferSize int) *Conn

func NewTLSConn

func NewTLSConn(conn net.Conn) *Conn

func NewTLSConnWithTimeout

func NewTLSConnWithTimeout(conn net.Conn, readTimeout, writeTimeout time.Duration) *Conn

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) EnableReadBuffering

func (c *Conn) EnableReadBuffering(bufferSize int)

EnableReadBuffering wraps subsequent reads in a bufio.Reader of the given size. Conns created via NewTLSConn start unbuffered because the peer may still upgrade the transport to TLS during the handshake; call this once the handshake completes, and only between packets. No-op if reads are already buffered or bufferSize is not positive.

func (*Conn) EnableWriteBuffering

func (c *Conn) EnableWriteBuffering(bufferSize int)

EnableWriteBuffering makes WritePacket accumulate packets in a buffer of the given size instead of issuing one write(2) each. Buffered data reaches the wire when the buffer fills, on Flush, or before any ReadPacket* call (so request/response flows cannot deadlock). Callers that stream packets without reading must Flush after each logical unit; Close does not flush. No-op if already enabled or bufferSize is not positive.

func (*Conn) Flush

func (c *Conn) Flush() error

Flush writes any buffered packets to the underlying connection. It is a no-op when write buffering is not enabled.

func (*Conn) ReadPacket

func (c *Conn) ReadPacket() ([]byte, error)

func (*Conn) ReadPacketReuseMem

func (c *Conn) ReadPacketReuseMem(dst []byte) ([]byte, error)

func (*Conn) ReadPacketTo

func (c *Conn) ReadPacketTo(w io.Writer) error

func (*Conn) ResetSequence

func (c *Conn) ResetSequence()

func (*Conn) WriteClearAuthPacket

func (c *Conn) WriteClearAuthPacket(password string) error

WriteClearAuthPacket Client clear text authentication packet https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_auth_switch_response.html

func (*Conn) WriteEncryptedPassword

func (c *Conn) WriteEncryptedPassword(password string, seed []byte, pub *rsa.PublicKey) error

func (*Conn) WritePacket

func (c *Conn) WritePacket(data []byte) error

WritePacket data already has 4 bytes header will modify data in-place

func (*Conn) WritePublicKeyAuthPacket

func (c *Conn) WritePublicKeyAuthPacket(password string, cipher []byte) error

WritePublicKeyAuthPacket Caching sha2 authentication. Public key request and send encrypted password https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_auth_switch_response.html

Jump to

Keyboard shortcuts

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