inbound_mysql

package
v0.0.0-...-c0343d2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2023 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPacketIncomplete = errors.New("packet is incomplete")
View Source
var ErrReaderEOF = errors.New("reader EOF")
View Source
var ErrUnknownPacket = errors.New("unknown packet")

Functions

This section is empty.

Types

type ClientCommandQueryPacket

type ClientCommandQueryPacket struct {
	Statement string
}

func (*ClientCommandQueryPacket) PacketType

func (this *ClientCommandQueryPacket) PacketType() PacketType

type ClientCommandStatementClosePacket

type ClientCommandStatementClosePacket struct {
	StatementId uint32
}

func (*ClientCommandStatementClosePacket) PacketType

func (this *ClientCommandStatementClosePacket) PacketType() PacketType

type ClientCommandStatementPreparePacket

type ClientCommandStatementPreparePacket struct {
	Statement string
}

func (*ClientCommandStatementPreparePacket) PacketType

type EndpointSide

type EndpointSide string
const (
	TypeServerSide EndpointSide = "server"
	TypeClientSide EndpointSide = "client"
)

type MySQLConn

type MySQLConn struct {
	State MySQLConnState

	CommandQueue list.List
	QueueLock    sync.Mutex

	SQLSnifferHandler    SQLSnifferHandler
	UnknownPacketHandler UnknownPacketHandler

	DebugUnknownPacketType bool
	DebugRawPacket         bool
}

func NewMySQLConn

func NewMySQLConn() *MySQLConn

func NewMySQLConnWithSniffer

func NewMySQLConnWithSniffer(handler SQLSnifferHandler, unknownPacketHandler UnknownPacketHandler) *MySQLConn

func (*MySQLConn) ChangeState

func (this *MySQLConn) ChangeState(newState MySQLConnState) (MySQLConnState, bool, error)

func (*MySQLConn) DequeuePacket

func (this *MySQLConn) DequeuePacket() *RawPacket

func (*MySQLConn) Enqueue

func (this *MySQLConn) Enqueue(rawPacket *RawPacket)

func (*MySQLConn) GetCurrentState

func (this *MySQLConn) GetCurrentState() MySQLConnState

func (*MySQLConn) HandleCommandPhaseClientPacket

func (this *MySQLConn) HandleCommandPhaseClientPacket(rawPacket *RawPacket) error

func (*MySQLConn) HandleCommandPhaseServerPacket

func (this *MySQLConn) HandleCommandPhaseServerPacket(rawPacket *RawPacket) error

func (*MySQLConn) HandleConnPhase

func (this *MySQLConn) HandleConnPhase(inbound, outbound io.ReadWriter) error

func (*MySQLConn) HandleConnPhase0

func (this *MySQLConn) HandleConnPhase0(inbound, outbound io.ReadWriter) error

type MySQLConnState

type MySQLConnState int32
const (
	StateConn    MySQLConnState = 1
	StateCommand MySQLConnState = 2
)

type OkPacket

type OkPacket struct {
}

func (*OkPacket) PacketType

func (o *OkPacket) PacketType() PacketType

type Packet

type Packet interface {
	PacketType() PacketType
}

func ParseClientPayloadPacket

func ParseClientPayloadPacket(data []byte) (Packet, error)

func ParseServerPayloadPacket

func ParseServerPayloadPacket(data []byte, seqId uint8) (Packet, error)

type PacketType

type PacketType int
const (
	UnknownPacketType  PacketType = -1
	CommonOkPacketType PacketType = 1
)
const (
	ClientCommandQueryType            PacketType = 101
	ClientCommandStatementPrepareType PacketType = 102
	ClientCommandStatementCloseType   PacketType = 103
)
const (
	ServerCommandStatementResponseType PacketType = 201
)

type RawPacket

type RawPacket struct {
	Length uint32
	SeqId  uint8
	Data   []byte
}

func (*RawPacket) ReadRawPacket

func (this *RawPacket) ReadRawPacket(reader io.Reader) error

func (*RawPacket) String

func (this *RawPacket) String() string

func (*RawPacket) WriteRawPacket

func (this *RawPacket) WriteRawPacket(writer io.Writer) error

type SQLSnifferHandler

type SQLSnifferHandler func(sql string)

type ServerCommandStatementResponsePacket

type ServerCommandStatementResponsePacket struct {
	StatementId uint32
}

func (*ServerCommandStatementResponsePacket) PacketType

type UnknownPacket

type UnknownPacket struct {
	Type uint8
	Data []byte
}

func (*UnknownPacket) PacketType

func (this *UnknownPacket) PacketType() PacketType

type UnknownPacketHandler

type UnknownPacketHandler func(packet *RawPacket, side EndpointSide)

Jump to

Keyboard shortcuts

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