clientprobe

package
v0.1.76 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 20 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 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

View Source
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 Kinds added in v0.1.56

Kinds folds the report rows by node and server kind, with the median measured delay and download checks. At most maxGroups kinds are returned per node, most reports first.

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.

func Results

func Results(r Report, match Match) []store.ClientProbeResult

Results are the server results of a report that matched a node, as stored; a result for anything else is dropped, and so is a second result for the same node, type and port.

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

type Match func(host string, port uint16) (nodeID string, ok bool)

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

func Parse(body []byte) (Report, error)

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.

type Service

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

Service is the owner's switch of the kl!ck reports and what the stored reports say.

func New

func New(cfg Config) *Service

New builds the service.

func (*Service) Handler

func (s *Service) Handler(opts ...connect.HandlerOption) (string, http.Handler)

Handler is the admin ClientProbeService.

Jump to

Keyboard shortcuts

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