cellproxy

package
v0.11.8 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package cellproxy is the metrics-emitting SOCKS5 proxy that runs inside a pr0xteus cell in place of microsocks. It proxies CONNECT through the cell's WireGuard default route while recording per-destination request counts, byte volumes, and live-connection counts, and exposes them plus a real liveness signal over a control HTTP server the controller scrapes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// CellID is this cell's own identifier (its short container ID, from the
	// hostname). ParentID is the spawning controller's container ID. Both are
	// echoed in /stats and tag the cell's logs for correlation.
	CellID   string
	ParentID string

	// SOCKSNetwork/SOCKSAddr are where the SOCKS5 proxy listens (the egress
	// interface inside the cell).
	SOCKSNetwork string
	SOCKSAddr    string

	// ControlAddr is where the metrics + health HTTP server listens. It must be
	// bound to the internal control interface only, never the egress side.
	ControlAddr string

	// DialTimeout bounds each outbound dial through the tunnel.
	DialTimeout time.Duration

	// TopDestinations caps the destination breakdown in a /stats snapshot.
	TopDestinations int
}

Config is the cell proxy's runtime configuration.

func LoadConfig

func LoadConfig() (Config, error)

LoadConfig parses and validates the cell proxy environment.

type DestStat

type DestStat struct {
	Destination string `json:"destination"`
	Requests    int64  `json:"requests"`
	BytesUp     int64  `json:"bytesUp"`
	BytesDown   int64  `json:"bytesDown"`
	Active      int64  `json:"active"`
}

DestStat aggregates traffic for one destination host:port.

type Recorder

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

Recorder accumulates proxy traffic metrics. It is safe for concurrent use.

func NewRecorder

func NewRecorder(topN int) *Recorder

NewRecorder returns an empty Recorder that ranks up to topN destinations in a snapshot. A non-positive topN falls back to the destination cap.

func (*Recorder) Close

func (r *Recorder) Close(key string)

Close marks one live connection to key finished.

func (*Recorder) DialFailed

func (r *Recorder) DialFailed()

DialFailed records a failed outbound dial, a signal the controller uses to spot a dead tunnel without needing privileged handshake inspection.

func (*Recorder) Down

func (r *Recorder) Down(key string, n int64)

Down records n bytes received from key toward the client.

func (*Recorder) Open

func (r *Recorder) Open(dest string) string

Open records a new proxied request to dest and returns the bucket key later passed to Up, Down, and Close (the caller may have been folded into the overflow bucket).

func (*Recorder) Snapshot

func (r *Recorder) Snapshot() Stats

Snapshot returns the current totals plus the byte-volume-ranked, bounded destination breakdown.

func (*Recorder) Up

func (r *Recorder) Up(key string, n int64)

Up records n bytes sent from the client toward key.

type Server

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

Server runs the SOCKS5 proxy and the control HTTP server against one shared Recorder.

func New

func New(cfg Config) *Server

New builds a cell proxy from cfg.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts both listeners and blocks until ctx is cancelled or a server fails.

type Stats

type Stats struct {
	Requests     int64      `json:"requests"`
	BytesUp      int64      `json:"bytesUp"`
	BytesDown    int64      `json:"bytesDown"`
	Active       int64      `json:"active"`
	DialFailures int64      `json:"dialFailures"`
	Destinations []DestStat `json:"destinations"`
}

Stats is the snapshot the control server returns from GET /stats. Totals are exact; Destinations is a bounded, byte-volume-ranked slice.

type Status

type Status struct {
	CellID        string  `json:"cellId"`
	ParentID      string  `json:"parentId,omitempty"`
	StartedAt     string  `json:"startedAt"`
	UptimeSeconds float64 `json:"uptimeSeconds"`
	Traffic       Stats   `json:"traffic"`
}

Status is the full cell picture returned by GET /status: identity, uptime, and the traffic snapshot. GET /v1/cells/{id} on the controller proxies to it.

Jump to

Keyboard shortcuts

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