flow

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package flow defines the capture data model: a Flow is one HTTP exchange, WebSocket session, or opaque tunnel seen by the proxy, plus the events the engine publishes as a flow progresses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BodyRef

type BodyRef struct {
	Hash      string `json:"hash,omitempty"`
	Size      int64  `json:"size"`
	Captured  int64  `json:"captured"`
	Truncated bool   `json:"truncated,omitempty"`
	Encoding  string `json:"encoding,omitempty"`
	MIME      string `json:"mime,omitempty"`
}

BodyRef describes a captured body stored in the blob store.

type Event

type Event struct {
	Type    EventType  `json:"type"`
	Seq     uint64     `json:"seq"`
	TS      time.Time  `json:"ts"`
	Flow    *Flow      `json:"flow,omitempty"`
	Phase   string     `json:"phase,omitempty"`
	WS      *WSMessage `json:"ws,omitempty"`
	Dropped int        `json:"dropped,omitempty"`
}

Event is what the engine publishes on the bus.

type EventType

type EventType string

EventType enumerates bus events.

const (
	EvStarted EventType = "started" // Flow set (request headers known)
	EvHeaders EventType = "headers" // Flow set (response headers known)
	EvDone    EventType = "done"    // Flow set (final)
	EvHeld    EventType = "held"    // Flow set; Phase set
	EvWS      EventType = "ws"      // WS set
	EvDropped EventType = "dropped" // Dropped set
)

Event types.

type Flow

type Flow struct {
	ID          ID          `json:"id"`
	Session     string      `json:"session"`
	Kind        Kind        `json:"kind"`
	Client      string      `json:"client"`
	Proto       string      `json:"proto,omitempty"`
	UpProto     string      `json:"up_proto,omitempty"`
	Scheme      string      `json:"scheme"`
	Host        string      `json:"host"`
	Port        int         `json:"port"`
	Method      string      `json:"method,omitempty"`
	Path        string      `json:"path,omitempty"`
	Query       string      `json:"query,omitempty"`
	ReqHeaders  http.Header `json:"req_headers,omitempty"`
	ReqBody     BodyRef     `json:"req_body"`
	Status      int         `json:"status,omitempty"`
	RespHeaders http.Header `json:"resp_headers,omitempty"`
	RespBody    BodyRef     `json:"resp_body"`
	Trailers    http.Header `json:"trailers,omitempty"`
	T           Timing      `json:"timing"`
	Error       string      `json:"error,omitempty"`
	Tags        []string    `json:"tags,omitempty"`
	Rules       []RuleHit   `json:"rules,omitempty"`
	State       State       `json:"state"`
	Replay      bool        `json:"replay,omitempty"`
	ReplayOf    ID          `json:"replay_of,omitempty"`
}

Flow is one captured exchange. Once State is Done/Failed it is immutable.

func (*Flow) Clone

func (f *Flow) Clone() *Flow

Clone returns a deep-enough copy for safe publication (headers are cloned).

func (*Flow) URL

func (f *Flow) URL() string

URL reconstructs the absolute URL.

type ID

type ID uint64

ID is a monotonic flow identifier.

func ParseShort

func ParseShort(s string) (ID, bool)

ParseShort inverts Short. It accepts upper case and the Crockford confusables (i/l → 1, o → 0).

func (ID) Short

func (id ID) Short() string

Short renders the ID as a compact Crockford base32 string ("1", "z", "2k7").

type IDGen

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

IDGen hands out monotonic IDs.

func NewIDGen

func NewIDGen(last ID) *IDGen

NewIDGen starts after the given last-used ID.

func (*IDGen) Last

func (g *IDGen) Last() ID

Last returns the most recently issued ID.

func (*IDGen) Next

func (g *IDGen) Next() ID

Next returns the next ID.

type Kind

type Kind string

Kind classifies a flow.

const (
	KindHTTP      Kind = "http"
	KindWebSocket Kind = "websocket"
	KindTunnel    Kind = "tunnel" // bypassed CONNECT, not decrypted
)

Flow kinds.

type RuleHit

type RuleHit struct {
	RuleID string `json:"rule_id"`
	Name   string `json:"name,omitempty"`
	Phase  string `json:"phase"`
	Action string `json:"action"`
	Note   string `json:"note,omitempty"`
}

RuleHit records that a rule acted on the flow.

type State

type State string

State is the lifecycle state.

const (
	StateActive State = "active"
	StateHeld   State = "held"
	StateDone   State = "done"
	StateFailed State = "failed"
)

Flow states.

type Timing

type Timing struct {
	Start       time.Time `json:"start"`
	DNSDone     time.Time `json:"dns_done,omitempty"`
	Connected   time.Time `json:"connected,omitempty"`
	TLSDone     time.Time `json:"tls_done,omitempty"`
	WroteReq    time.Time `json:"wrote_req,omitempty"`
	FirstByte   time.Time `json:"first_byte,omitempty"`
	HeadersSent time.Time `json:"headers_sent,omitempty"`
	End         time.Time `json:"end,omitempty"`
	Reused      bool      `json:"reused,omitempty"`
}

Timing records the phases of an exchange.

func (Timing) TTFB

func (t Timing) TTFB() time.Duration

TTFB is time to first response byte.

func (Timing) Total

func (t Timing) Total() time.Duration

Total is the full duration (or elapsed so far).

type WSMessage

type WSMessage struct {
	FlowID  ID        `json:"flow_id"`
	Seq     int       `json:"seq"`
	TS      time.Time `json:"ts"`
	Dir     string    `json:"dir"` // "c2s" | "s2c"
	Opcode  int       `json:"opcode"`
	Len     int64     `json:"len"`
	Payload []byte    `json:"payload,omitempty"`
	Masked  bool      `json:"masked,omitempty"`
}

WSMessage is one captured WebSocket frame/message.

Jump to

Keyboard shortcuts

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