check

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package check owns what a check is: its protocols, its settings, the rules a valid check follows and its options. The central validates with it before storing, the edge before running, so both always agree.

Index

Constants

View Source
const (
	// TraceMaxHops is how far a traceroute goes.
	TraceMaxHops = 30
	// MTUProbes bounds a path MTU search: binary search from 576 to 9000 bytes.
	MTUProbes = 15
	// InterSample spaces the samples of one cycle.
	InterSample = 100 * time.Millisecond
)

Variables

View Source
var (
	ProbeBounds = Bounds{MinInterval: 5 * time.Second, MaxInterval: time.Hour, MinTimeout: 100 * time.Millisecond, MaxTimeout: 30 * time.Second, MaxCount: 20}
	TraceBounds = Bounds{MinInterval: time.Minute, MaxInterval: 24 * time.Hour, MinTimeout: 100 * time.Millisecond, MaxTimeout: 5 * time.Second, MaxCount: 5}
)

Central bounds, for probes and for traceroutes.

View Source
var DNSTypes = []string{"A", "AAAA", "CNAME", "MX", "NS", "SOA", "TXT", "PTR", "SRV"}

DNSTypes are the question types a DNS check may ask.

Protocols lists every protocol, in display order.

Functions

func Matches

func Matches(selector, labels map[string]string) bool

Matches reports whether labels satisfy every pair of the selector.

func ToProto

func ToProto(versionID int64, host string, s Spec) *netprobev1.Check

ToProto is a check version as sent to edges.

func ValidLabels

func ValidLabels(labels map[string]string) error

ValidLabels checks edge labels and the selectors that match them.

func ValidName

func ValidName(name string) error

ValidName checks the name of an edge or a target.

Types

type Bounds

type Bounds struct {
	MinInterval, MaxInterval time.Duration
	MinTimeout, MaxTimeout   time.Duration
	MaxCount                 int
}

Bounds are limits a spec must also respect: the central sets them for the checks it accepts, an edge for the checks it runs.

func CentralBounds

func CentralBounds(s Spec) Bounds

CentralBounds are the bounds the central applies to s.

func (Bounds) Check

func (b Bounds) Check(s Spec) error

Check returns an error when s is outside b. Zero fields are not checked.

type DNSOptions

type DNSOptions struct {
	Name string // fully qualified, with the final dot
	Type string // one of DNSTypes
	TCP  bool
}

DNSOptions: one question to the target, a resolver.

type Family

type Family string

Family restricts the address family; Auto lets the resolver choose.

const (
	Auto Family = ""
	IPv4 Family = "ipv4"
	IPv6 Family = "ipv6"
)

func FamilyOf

func FamilyOf(f netprobev1.Family) (Family, bool)

FamilyOf returns the family of an API value; false if unknown.

func (Family) Matches

func (f Family) Matches(addr netip.Addr) bool

Matches reports whether addr belongs to f. Auto matches everything.

func (Family) Proto

func (f Family) Proto() netprobev1.Family

Proto is the API value of f.

type HTTPOptions

type HTTPOptions struct {
	TLS      bool
	Path     string
	Expect   int // status wanted; 0: any below 400
	Insecure bool
}

HTTPOptions: GET of Path on the target, HTTPS unless port 80 or scheme=http.

type MTUOptions

type MTUOptions struct {
	Max int
}

MTUOptions: search between the minimum MTU of the family and Max.

type Protocol

type Protocol string
const (
	ICMP      Protocol = "icmp"
	TCP       Protocol = "tcp"
	UDP       Protocol = "udp"
	TraceUDP  Protocol = "trace-udp"
	TraceICMP Protocol = "trace-icmp"
	HTTP      Protocol = "http"
	DNS       Protocol = "dns"
	NTP       Protocol = "ntp"
	MTU       Protocol = "mtu"
)

func ProtocolOf

func ProtocolOf(p netprobev1.Protocol) (Protocol, bool)

ProtocolOf returns the protocol of an API value; false if unknown.

func (Protocol) IsTrace

func (p Protocol) IsTrace() bool

IsTrace reports whether p is a traceroute.

func (Protocol) Proto

func (p Protocol) Proto() netprobev1.Protocol

Proto is the API value of p.

type Spec

type Spec struct {
	Protocol  Protocol
	Port      int
	LocalPort int // source port, 0 for any
	Family    Family
	Interval  time.Duration
	Timeout   time.Duration
	Count     int // samples per cycle; per hop for a traceroute
	Payload   []byte
	Options   map[string]string
}

Spec is what a check measures. Any change of it is a new version.

func FromProto

func FromProto(c *netprobev1.Check) Spec

FromProto is the spec of a check received by an edge. Unknown protocols or families come out invalid, and Validate says so.

func (Spec) DNS

func (s Spec) DNS() (DNSOptions, error)

func (Spec) Duration

func (s Spec) Duration() time.Duration

Duration is the longest a cycle may take: it must fit in the interval.

func (Spec) Equal

func (s Spec) Equal(o Spec) bool

Equal reports whether two specs measure the same thing.

func (Spec) HTTP

func (s Spec) HTTP() (HTTPOptions, error)

func (Spec) Label

func (s Spec) Label() string

Label is the short name of a check: "TCP 443 (IPv6)".

func (Spec) MTU

func (s Spec) MTU() (MTUOptions, error)

func (Spec) Validate

func (s Spec) Validate() error

Validate checks that a spec makes sense, whatever the limits of whoever runs it (see Bounds for those of the central).

Jump to

Keyboard shortcuts

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