packet

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderLen = 4
View Source
const InProgress = 0xffff
View Source
const PacketNo = 3

Variables

View Source
var ErrIncompletePacket = er.New("packet: incomplete packet")

ErrIncompletePacket the data being written didn't form a complete set of packets. Call aborted when it reached the incomplete packet.

Functions

func Copy

func Copy(rdr io.Reader, wrt io.Writer) (int, error)

Copy transfer from a reader to a writer expecting to receive a packet of MySQL data at a time. Makes use of the MySQLPacketWriter to even out the data.

Types

type Buffer

type Buffer struct {
	Times   TimesSeen
	Packets []Packet
	// contains filtered or unexported fields
}

Buffer buffers MySQL packets along with their times seen so they can be played back in order.

func (*Buffer) CurrentPacket

func (b *Buffer) CurrentPacket() *Packet

func (*Buffer) Next

func (b *Buffer) Next()

func (*Buffer) Reset

func (*Buffer) Reset()

func (*Buffer) Seen

func (b *Buffer) Seen() []time.Time

func (*Buffer) SetTimes

func (b *Buffer) SetTimes(t TimesSeen)

func (*Buffer) Write

func (b *Buffer) Write(p []byte) (n int, err error)

Write buffers up the packets and stores when they were seen.

type MySQLPacketWriter

type MySQLPacketWriter struct {
	Receiver            io.Writer
	CompressionDetected bool
}

MySQLPacketWriter wraps a writer expecting MySQL packets and ensures that writer receives single MySQL packets for each Write call. Will return an error if it can't, or if the underlying writer errors.

func (*MySQLPacketWriter) Write

func (w *MySQLPacketWriter) Write(data []byte) (n int, err error)

Write sends complete packets through as individual calls to Write on the Receiver. If there is incomplete data at the end it will return an ErrIncompletePacket and the number of bytes it did write. Note that the Receiver can also return an error.

type Packet

type Packet struct {
	Seen []time.Time
	Data []byte
}

Packet MySQL packet along with when it was seen.

func (Packet) FirstSeen

func (p Packet) FirstSeen() time.Time

type Splitter

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

Splitter takes writes for the packets and ensures we emit full MySQL packets to the writer provided. This will buffer up data as necessary. To check if there was left over, call the IncompletePacket() function once done writing.

func NewSplitter

func NewSplitter(wrt io.Writer) *Splitter

func (*Splitter) Bytes added in v0.0.4

func (c *Splitter) Bytes() []byte

func (*Splitter) CompressionDetected

func (c *Splitter) CompressionDetected()

func (*Splitter) IncompletePacket

func (c *Splitter) IncompletePacket() bool

func (*Splitter) Write

func (c *Splitter) Write(p []byte) (int, error)

type TimesSeen

type TimesSeen interface {
	Reset()
	Seen() []time.Time
}

TimesSeen interface for something that gathers the times that data was seen. Due to the nature of how ip packets and then mysql packets, and then 'requests' and 'responses' etc. may not have a one to one relationship there may be multiple time stamps associated with parts of the data.

Jump to

Keyboard shortcuts

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