proxy

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CertPath

func CertPath(dataDir string) string

CertPath returns the CA certificate path.

func LoadOrGenerateCA

func LoadOrGenerateCA(dataDir string) (tls.Certificate, error)

LoadOrGenerateCA loads the CA cert/key from dataDir, or generates a new pair.

func ParseSSE

func ParseSSE(raw []byte) []wire.SSEEvent

ParseSSE parses raw SSE data into events. SSE format: "event: <type>\ndata: <json>\n\n"

Types

type PriceLookup

type PriceLookup interface {
	// Cost calculates cost from parsed usage data and request-level modifiers.
	// multiplier applies to all token costs (e.g. 6.0 for fast mode, 1.1 for data residency).
	// cacheTTL1h switches cache write rate from 1.25x to 2x input price.
	Cost(providerName, model string, result *wire.Result, multiplier float64, cacheTTL1h bool) *float64
	Normalize(gateway, model string) string
}

PriceLookup calculates cost and normalizes model names. Can be nil.

type Proxy

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

Proxy is the MITM proxy server.

func New

func New(addr, dataDir string, store storage.Store, price PriceLookup) (*Proxy, error)

New creates a new proxy server.

func (*Proxy) ListenAndServe

func (p *Proxy) ListenAndServe() error

ListenAndServe starts the proxy.

func (*Proxy) Shutdown

func (p *Proxy) Shutdown() error

Shutdown gracefully stops the proxy, flushing any buffered records. It waits for in-flight requests to finish before signaling the batcher, ensuring no records are lost between server.Shutdown and the drain loop.

Jump to

Keyboard shortcuts

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