proxy

package
v0.63.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package proxy provides a logging reverse proxy used for speaker traffic debugging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentItem added in v0.43.0

type ContentItem struct {
	XMLName       xml.Name `xml:"ContentItem"`
	Source        string   `xml:"source,attr"`
	Type          string   `xml:"type,attr"`
	Location      string   `xml:"location,attr"`
	SourceAccount string   `xml:"sourceAccount,attr"`
	IsPresetable  string   `xml:"isPresetable,attr"`
	ItemName      string   `xml:"itemName"`
	ContainerArt  string   `xml:"containerArt"`
}

ContentItem represents the XML structure within Base64-encoded content

type DecodedContent added in v0.43.0

type DecodedContent struct {
	ContentType   string `json:"content_type"`
	ItemName      string `json:"item_name"`
	SourceAccount string `json:"source_account,omitempty"`
	Location      string `json:"location,omitempty"`
	ArtworkURL    string `json:"artwork_url,omitempty"`
	IsPresetable  bool   `json:"is_presetable,omitempty"`
	XMLContent    string `json:"xml_content,omitempty"`
}

DecodedContent represents decoded ContentItem XML data

type EnrichedSCMUDCEvent added in v0.43.0

type EnrichedSCMUDCEvent struct {
	Origin      string          `json:"origin"`
	Action      string          `json:"action"`
	Command     string          `json:"command"`
	Summary     string          `json:"summary"`
	DecodedData *DecodedContent `json:"decoded_data,omitempty"`
}

EnrichedSCMUDCEvent contains human-readable analysis of SCMUDC events

type Interaction added in v0.22.0

type Interaction struct {
	ID         string               `json:"id"`
	Session    string               `json:"session"`
	Category   string               `json:"category"`
	Method     string               `json:"method"`
	Path       string               `json:"path"`
	File       string               `json:"file"`
	Counter    int                  `json:"counter"`
	Status     int                  `json:"status"`
	Timestamp  string               `json:"timestamp"`
	SCMUDCData *EnrichedSCMUDCEvent `json:"scmudc_data,omitempty"`
}

Interaction represents a single recorded HTTP interaction.

type InteractionStats added in v0.22.0

type InteractionStats struct {
	TotalRequests int            `json:"total_requests"`
	ByService     map[string]int `json:"by_service"`
	BySession     map[string]int `json:"by_session"`
}

InteractionStats represents statistics for recorded interactions.

type LoggingProxy

type LoggingProxy struct {
	Proxy         *httputil.ReverseProxy
	Redact        bool
	LogBody       bool
	RecordEnabled bool
	MaxBodySize   int64
	Recorder      *Recorder
}

LoggingProxy wraps a ReverseProxy to provide instrumentation.

func NewLoggingProxy

func NewLoggingProxy(_ string, redact bool) *LoggingProxy

NewLoggingProxy creates a lightweight logger for HTTP requests/responses.

func (*LoggingProxy) LogRequest

func (lp *LoggingProxy) LogRequest(r *http.Request)

LogRequest prints an abbreviated request with optional header/body redaction.

func (*LoggingProxy) LogResponse

func (lp *LoggingProxy) LogResponse(r *http.Response)

LogResponse prints an abbreviated response with optional header/body redaction.

func (*LoggingProxy) SetRecorder added in v0.14.0

func (lp *LoggingProxy) SetRecorder(r *Recorder)

SetRecorder sets the recorder for the proxy.

type PathPattern added in v0.14.0

type PathPattern struct {
	Name        string `json:"name"`
	Regexp      string `json:"regexp"`
	Replacement string `json:"replacement"`
	// contains filtered or unexported fields
}

PathPattern defines a regex and its replacement for sanitizing URL paths.

type PathPatterns added in v0.14.0

type PathPatterns []PathPattern

PathPatterns is a collection of PathPattern.

func DefaultPatterns added in v0.14.0

func DefaultPatterns() PathPatterns

DefaultPatterns returns the default set of path patterns.

func LoadPatterns added in v0.14.0

func LoadPatterns(path string) (PathPatterns, error)

LoadPatterns loads path patterns from a JSON file.

func (PathPatterns) Sanitize added in v0.14.0

func (pp PathPatterns) Sanitize(segment string) (string, string)

Sanitize sanitizes a segment using the configured patterns.

type Recorder added in v0.14.0

type Recorder struct {
	BaseDir    string
	SessionID  string
	SessionDir string
	Patterns   PathPatterns
	Redact     bool
	// contains filtered or unexported fields
}

Recorder handles persisting HTTP interactions as .http files.

func NewRecorder added in v0.14.0

func NewRecorder(baseDir string) *Recorder

NewRecorder creates a new HTTP interaction recorder.

func (*Recorder) ArchiveSession added in v0.26.0

func (r *Recorder) ArchiveSession(sessionID string, w io.Writer) (err error)

ArchiveSession creates a .tar.gz archive of the specified session and writes it to w.

func (*Recorder) CleanupSessions added in v0.22.0

func (r *Recorder) CleanupSessions(keepCount int) error

CleanupSessions deletes all but the most recent keepCount sessions.

func (*Recorder) Close added in v0.25.0

func (r *Recorder) Close()

Close stops the recorder and waits for pending tasks to finish.

func (*Recorder) DeleteSession added in v0.22.0

func (r *Recorder) DeleteSession(sessionID string) error

DeleteSession deletes a specific recording session.

func (*Recorder) GetInteractionContent added in v0.22.0

func (r *Recorder) GetInteractionContent(relPath string) ([]byte, error)

GetInteractionContent returns the raw content of a recorded interaction.

func (*Recorder) GetInteractionStats added in v0.22.0

func (r *Recorder) GetInteractionStats() (*InteractionStats, error)

GetInteractionStats returns statistics about recorded interactions.

func (*Recorder) ListInteractions added in v0.22.0

func (r *Recorder) ListInteractions(sessionFilter, categoryFilter, sinceFilter string) ([]Interaction, error)

ListInteractions returns a list of recorded interactions.

func (*Recorder) Record added in v0.14.0

func (r *Recorder) Record(category string, req *http.Request, res *http.Response) error

Record logs an interaction to the configured category.

type SCMUDCEvent added in v0.43.0

type SCMUDCEvent struct {
	Type string `json:"type"`
	Data struct {
		ButtonID    string `json:"buttonId,omitempty"`
		Origin      string `json:"origin"`
		ContentItem string `json:"contentItem,omitempty"`
		Preset      string `json:"preset,omitempty"`
	} `json:"data"`
}

SCMUDCEvent represents individual events within SCMUDC requests

type SCMUDCRequest added in v0.43.0

type SCMUDCRequest struct {
	Envelope struct {
		MonoTime               int64  `json:"monoTime"`
		PayloadProtocolVersion string `json:"payloadProtocolVersion"`
		PayloadType            string `json:"payloadType"`
		ProtocolVersion        string `json:"protocolVersion"`
		Time                   string `json:"time"`
		UniqueID               string `json:"uniqueId"`
	} `json:"envelope"`
	Payload struct {
		DeviceInfo struct {
			BoseID             string `json:"boseID"`
			DeviceID           string `json:"deviceID"`
			DeviceType         string `json:"deviceType"`
			SerialNumber       string `json:"serialNumber"`
			SoftwareVersion    string `json:"softwareVersion"`
			SystemSerialNumber string `json:"systemSerialNumber"`
		} `json:"deviceInfo"`
		Events []SCMUDCEvent `json:"events"`
	} `json:"payload"`
}

SCMUDCRequest represents the structure of SCMUDC telemetry requests

Jump to

Keyboard shortcuts

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