router

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0, MIT Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package router is Skiff's edge router: it discovers apps from Docker labels and reverse-proxies <app>.<domain> to them, with automatic HTTPS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	T      int64 `json:"t"` // minute, unix seconds (floored)
	Req    int   `json:"req"`
	S2     int   `json:"s2"`
	S3     int   `json:"s3"`
	S4     int   `json:"s4"`
	S5     int   `json:"s5"`
	LatMs  int64 `json:"lat"` // summed latency in ms (÷ Req for the average)
	BytesI int64 `json:"bi"`  // request bytes in
	BytesO int64 `json:"bo"`  // response bytes out
}

type Metrics

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

func NewMetrics

func NewMetrics(file string) *Metrics

func (*Metrics) Record

func (m *Metrics) Record(app string, status int, bytesIn, bytesOut int64, dur time.Duration)

func (*Metrics) Run

func (m *Metrics) Run()

type ReqEntry added in v0.2.0

type ReqEntry struct {
	T  int64  `json:"t"` // unix millis
	A  string `json:"a"` // app
	M  string `json:"m"`
	P  string `json:"p"` // path, no query string
	S  int    `json:"s"`
	D  int64  `json:"d"`           // duration ms
	B  int64  `json:"b"`           // response bytes
	R  string `json:"r,omitempty"` // referring host, when it's another site
	V  string `json:"v"`           // visitor: keyed hash of ip+user agent, rotating daily
	Bt bool   `json:"bt,omitempty"`
}

ReqEntry is one proxied request, as appended to <dir>/<YYYY-MM-DD>.jsonl.

type ReqLog added in v0.2.0

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

ReqLog appends request entries from a buffered channel so the proxy path never waits on disk; when the buffer is full, entries are dropped.

func NewReqLog added in v0.2.0

func NewReqLog(dir string) *ReqLog

func (*ReqLog) Record added in v0.2.0

func (l *ReqLog) Record(app string, r *http.Request, status int, bytes int64, dur time.Duration)

func (*ReqLog) Run added in v0.2.0

func (l *ReqLog) Run()

type Router

type Router struct {
	Domains []string
	Engine  *docker.Engine
	Panel   string // fallback host:port of the control panel; dash.<domain> proxies here
	// PanelPointer, when set, is a file the panel rewrites during a zero-downtime self-deploy to flip dash.<domain> onto the new process without restarting the router.
	PanelPointer string
	SiteApp      string // app that serves the apex + www.<domain>
	// DomainsFile, when set, is a JSON file of custom host→app mappings read live (cached briefly) so domains change without restarting the edge.
	DomainsFile string
	// MetricsFile, when set, is where the router snapshots per-app request metrics for the panel's Analytics page.
	MetricsFile string
	// RequestsDir, when set, receives a daily JSONL log of each request to an app, which the panel reads for per-project insights.
	RequestsDir string
	// SleepFile lists apps the panel stopped for being idle; a visit to one starts it again.
	SleepFile string
	// MailFile is the JSON forwarding table (domain → alias → destinations) read live by the SMTP listener on SMTPAddr.
	MailFile string
	SMTPAddr string
	// contains filtered or unexported fields
}

func (*Router) MailHost added in v0.2.0

func (rt *Router) MailHost() string

func (*Router) ServeHTTP

func (rt *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Router) ServeHTTPOnly

func (rt *Router) ServeHTTPOnly(addr string) error

func (*Router) ServeTLS

func (rt *Router) ServeTLS(cacheDir string) error

Jump to

Keyboard shortcuts

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