decode

package
v0.32.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

func DirectionMarker(direction byte) string

DirectionMarker returns the two-character marker for a packet direction.

func File

func File(path string, opts Options, out io.Writer) error

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

func FormatOffset(relativeNs int64) string

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.

func Supported

func Supported(protocol string) bool

Supported reports whether a capture of the given protocol can be decoded.

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.

func (Message) String

func (m Message) String() string

String renders the message as one trace line.

type Options

type Options struct {
	// ShowRows prints result-row values, bind parameter values and column names
	// instead of their counts. Authentication payloads stay redacted either way.
	ShowRows bool
}

Options controls how much a decoded line reveals.

Jump to

Keyboard shortcuts

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