Documentation
¶
Overview ¶
Package decode turns a dbbat session capture into a readable protocol trace: one line per protocol message, both directions, with the offset from the start of the session.
234ms C> Execute portal="" maxRows=501 251ms <S RowDescription(8 fields) 329ms <S PortalSuspended 329ms <S ReadyForQuery I
The capture is plain pcapng and Wireshark reads it, but Wireshark is not on a build host and not in a terminal-driven investigation. This package is that same view without a GUI.
All five protocols dbbat proxies are decoded: PostgreSQL, MySQL/MariaDB, MongoDB, SQL Server and Oracle. Each has its own splitter, doing its own framing; the protocol comes from the capture header, never from sniffing the bytes.
Captures may hold customer data, so a decoded line is redacted by default: result-row values and bind parameters collapse to their count, and a MongoDB document to the shape of its fields. Options.ShowRows opts into the values. Authentication payloads are never printed, with or without that flag.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrOutOfSync = errors.New("protocol stream out of sync")
ErrOutOfSync is returned when a stream cannot be cut at the protocol's framing any more. The usual cause is a capture truncated by DBB_DUMP_MAX_SIZE, which drops whole packets mid-session.
var ErrUnsupportedProtocol = errors.New("no message decoder for this capture's protocol")
ErrUnsupportedProtocol is returned for a capture whose protocol has no decoder. All five protocols dbbat proxies have one, so this is reached only by a capture header naming something else.
Functions ¶
func DirectionMarker ¶
DirectionMarker returns the two-character marker for a packet direction.
func File ¶
File decodes the capture at path and writes the trace to out.
The first line names the session and protocol; every following line is one protocol message. Lines produced before a decoding failure are written out before the error is returned, so a truncated capture still yields everything that was readable.
func FormatOffset ¶
FormatOffset renders a nanosecond offset as a compact duration: 234ms, 1.234s, 2m3.456s. Truncated to the millisecond, which is the resolution anything in a session trace is actually read at.
Types ¶
type Message ¶
type Message struct {
// RelativeNs is the offset from the session start of the packet that
// *completed* the message. A message split across packets is timed by its
// last byte, which is when the peer could act on it.
RelativeNs int64
Direction byte
Text string
}
Message is one decoded protocol message.