packet

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FILTER_HOSTNAME = "hostname"
	FILTER_METHOD   = "method"
	FILTER_PATH     = "path"
	FILTER_REQ_BODY = "reqbody"
	// TODO filter on version?
	FILTER_STATUS    = "status"
	FILTER_RESP_BODY = "respbody"
)
View Source
const (
	ServerFrame frameType = frameType(false)
	ClientFrame frameType = frameType(true)
)

Variables

This section is empty.

Functions

func MarshalPackets added in v0.15.0

func MarshalPackets(p []Packet) ([]byte, error)

func UnmarshalPackets added in v0.15.0

func UnmarshalPackets(data []byte, p *[]Packet) error

Types

type HttpPacket

type HttpPacket struct {
	TimeStamp_ time.Time `json:"TimeStamp"`
	Type_      string    `json:"Type"`
	Id         [16]byte  `json:"id"`
	Hostname   string
	Method     string
	Status     string
	Path       string
	// The request protocol version, i.e. "HTTP/1.1"
	// The response protocol version, i.e. "HTTP/1.1"
	ReqProto    string
	RespProto   string
	RespHeaders map[string][]string
	RespBody    []byte
	ReqHeaders  map[string][]string
	ReqBody     []byte
}

HttpPacket represents a captured packet from either the https or http proxy. An HttpPacket contains all the information from the http request, as well as the information from the http response (once it has been captured).

func CreatePacket

func CreatePacket(
	hostname string,
	method string,
	status string,
	path string,
	respProto string,
	reqProto string,
	respHeaders map[string][]string,
	respBody []byte,
	reqHeaders map[string][]string,
	reqBody []byte,
) HttpPacket

func (*HttpPacket) FindPacket added in v0.15.0

func (p *HttpPacket) FindPacket(packets []Packet) Packet

func (*HttpPacket) FormatHostname added in v0.15.0

func (p *HttpPacket) FormatHostname() string

func (*HttpPacket) FormatRequestContent added in v0.13.0

func (p *HttpPacket) FormatRequestContent() string

func (*HttpPacket) FormatRequestLine added in v0.15.0

func (p *HttpPacket) FormatRequestLine() string

func (*HttpPacket) FormatResponseContent added in v0.13.0

func (p *HttpPacket) FormatResponseContent() string

func (*HttpPacket) FormatResponseLine added in v0.15.0

func (p *HttpPacket) FormatResponseLine() string

func (*HttpPacket) MatchesFilter added in v0.15.0

func (p *HttpPacket) MatchesFilter(tokens []internal.FilterToken) bool

func (*HttpPacket) TimeStamp added in v0.14.0

func (p *HttpPacket) TimeStamp() time.Time

func (*HttpPacket) Type added in v0.15.0

func (p *HttpPacket) Type() string

func (*HttpPacket) UpdatePacket

func (p *HttpPacket) UpdatePacket(inPacket Packet)

type Packet added in v0.15.0

type Packet interface {
	TimeStamp() time.Time
	Type() string
	FindPacket([]Packet) Packet
	UpdatePacket(Packet)
	FormatHostname() string
	FormatRequestLine() string
	FormatResponseLine() string
	FormatRequestContent() string
	FormatResponseContent() string
	MatchesFilter([]internal.FilterToken) bool
}

type WebsocketFrame added in v0.15.0

type WebsocketFrame struct {
	TimeStamp     time.Time
	Type          frameType
	Fin           bool
	RSV1          bool
	RSV2          bool
	RSV3          bool
	Opcode        byte
	Masked        bool
	PayloadLength uint64
	MaskingKey    [4]byte
	// TODO: Split this up into extension data and application data
	Payload []byte
}

type WebsocketPacket added in v0.15.0

type WebsocketPacket struct {
	HttpPacket
	ServerFrames []*WebsocketFrame
	ClientFrames []*WebsocketFrame
}

func CreateWebsocketPacket added in v0.15.0

func CreateWebsocketPacket(httpPacket HttpPacket) *WebsocketPacket

func (*WebsocketPacket) AddClientFrame added in v0.15.0

func (w *WebsocketPacket) AddClientFrame(frame *WebsocketFrame)

func (*WebsocketPacket) AddServerFrame added in v0.15.0

func (w *WebsocketPacket) AddServerFrame(frame *WebsocketFrame)

func (*WebsocketPacket) FindPacket added in v0.15.0

func (w *WebsocketPacket) FindPacket(packets []Packet) Packet

func (*WebsocketPacket) FormatRequestContent added in v0.15.0

func (w *WebsocketPacket) FormatRequestContent() string

func (*WebsocketPacket) FormatResponseContent added in v0.15.0

func (w *WebsocketPacket) FormatResponseContent() string

func (*WebsocketPacket) UpdatePacket added in v0.15.0

func (w *WebsocketPacket) UpdatePacket(p Packet)

Jump to

Keyboard shortcuts

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