Documentation
¶
Overview ¶
Package server hosts the speed-test endpoints and the embedded web UI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Addr string // e.g. ":8080"
MaxDownloadMiB int64 // safety cap, default 1024 (1 GiB)
MaxUploadMiB int64 // safety cap, default 1024
ReadTimeout time.Duration // per request, default 60s — uploads can be large
IPInfoToken string // optional ipinfo.io token for richer ISP data
// TrustProxyHeaders, when true, makes the server honor
// X-Forwarded-For / X-Real-IP for client-IP determination. OFF by
// default to prevent header-spoofing attacks: any direct caller can
// otherwise force /api/info to issue an outbound ipinfo.io lookup
// for an IP of their choosing and read the result, draining the
// operator's quota and acting as an SSRF-style oracle. Only enable
// this when running behind a reverse proxy that *strips and re-sets*
// these headers itself.
TrustProxyHeaders bool
}
Config controls the HTTP server.
type InfoResponse ¶
type InfoResponse struct {
ClientIP string `json:"client_ip"`
ISP string `json:"isp,omitempty"`
City string `json:"city,omitempty"`
Region string `json:"region,omitempty"`
Country string `json:"country,omitempty"`
ServerHost string `json:"server_host"`
ServerTime string `json:"server_time"`
}
InfoResponse is what /api/info returns.
type WSPingConfig ¶ added in v0.2.0
type WSPingConfig struct {
// Samples is the number of ping/pong round-trips to perform.
Samples int
// Spacing is the delay between successive pings.
Spacing time.Duration
// PingTimeout bounds an individual ping/pong. Treated as a hard error
// if exceeded — typically only happens when the network or peer is
// gone.
PingTimeout time.Duration
// MaxLifetime caps the entire connection. Defends against clients
// that open the WS and stop reading.
MaxLifetime time.Duration
}
WSPingConfig controls the /ws ping loop. Defaults are fine for the browser UI; callers can override for tests.
Click to show internal directories.
Click to hide internal directories.