Documentation
¶
Overview ¶
Package clientprobe is the source "kl!ck reports" of the Reachability page: the local server check of the kl!ck VPN app, which a person starts in the app and, with the "send to the panel" switch on, sends to the panel that issued the subscription (client_probe.proto). This file reads and checks a report; the subscription endpoint (subs, probe.go) takes it under the link, matches its servers against the person's subscription and stores the result (store, migration 00075); service.go is the owner's switch and the counts the page shows.
A report is untrusted input from anyone who holds a link: every field is checked against the contract of the app (kl!ck, crates/klick-service/src/probe.rs PanelReport), and anything else is refused.
Index ¶
Constants ¶
const ( // Version is the newest report version the panel takes: the value of the Probe-Report header. Version = 1 // MaxBody is the largest report body; a full one (MaxServers results) is about 60 KB. MaxBody = 128 << 10 // MaxServers is the most server results one report may carry. MaxServers = 256 // Every is how often one subscription may send a report (the app sends at most once in 10 minutes). Every = 10 * time.Minute // Keep is how long a report is stored (the health retention sweep). Keep = 7 * 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func NetworkOf ¶
func NetworkOf(r Report) store.ClientProbeNetwork
NetworkOf is the network of a report as stored.
func NewID ¶
func NewID() string
NewID is the id of one stored report: random, it only groups the report's rows.
func Nodes ¶
func Nodes(counts []store.ClientProbeCount) []*adminv1.ClientProbeNode
Nodes folds the counts by node and network into the answer: per node the totals, the operators and the regions, most reports first (then the most freezes and blocks), at most maxGroups of each. The nodes are in the order of the counts.
Types ¶
type Config ¶
type Config struct {
Store *store.Store
// StepUp is auth.Service.RequireStepUp: changing the switch asks for it.
StepUp func(context.Context) error
// Invalidate drops the cached subscription settings of this process (subsettings.Cache.Invalidate), which carry the switch,
// so that its subscription answers follow at once; nil = within the cache's TTL.
Invalidate func()
Log *slog.Logger
Now func() time.Time
}
Config configures Service. Store and StepUp are required.
type Detail ¶
type Detail struct {
Flaky bool `json:"flaky"`
TCPOK *uint8 `json:"tcp_ok,omitempty"`
TCPTries *uint8 `json:"tcp_tries,omitempty"`
TCPMS *uint32 `json:"tcp_ms,omitempty"`
DelayMS *uint32 `json:"delay_ms,omitempty"`
DLBytes *uint64 `json:"dl_bytes,omitempty"`
DLStalled *bool `json:"dl_stalled,omitempty"`
DNS *string `json:"dns,omitempty"`
}
Detail is what was measured of a server: stored as it is (detail_json).
type Match ¶
Match finds the node of a server of the person's subscription by its host (lower case) and port.
type Network ¶
type Network struct {
ASN uint32 `json:"asn"`
Operator string `json:"operator"`
Country string `json:"country"`
Region string `json:"region"`
Type string `json:"type"`
}
Network is the network the person was on, as the app saw it; empty fields are unknown.
type Report ¶
type Report struct {
V int `json:"v"`
VPN bool `json:"vpn"`
DirectChecked bool `json:"direct_checked"`
Network Network `json:"network"`
Servers []Server `json:"servers"`
}
Report is a report as the app sends it (v1). The pointers are values that were not measured when nil.
func Parse ¶
Parse reads and checks a report body: one JSON object of version 1 with no unknown field, every value in its range and every word one the contract knows. The operator and region become plain text (see plain), the country is upper-cased, host and type lower-cased. The error names the first field that is wrong (it carries no value from the body).
type Server ¶
type Server struct {
Type string `json:"type"`
Host string `json:"host"`
Port uint16 `json:"port"`
Verdict string `json:"verdict"`
Detail
}
Server is one server of the subscription as the app checked it. Host and Port are as the subscription gave them.