Documentation
¶
Overview ¶
Package countryprobe is the third source of the country check ("is the node reachable from Russia"): one of the owner's own nodes inside the country, the probe node, tests with TCP SYNs of a limited TTL whether the connections to the other nodes of the fleet survive the national DPI box (the TSPU). The agent side is internal/tspuprobe (agent.proto "COUNTRY PROBE"); this package is the panel side: the settings and their admin API, the schedule, the batches and the storage of the answers.
The probe node sits in a data centre, so what it reports is a datacentre view: its verdicts carry the confidence "dc_only" (countryreach.Combine) and Globalping on home networks outranks them. Only TCP is tested.
It is an integration of its own and off by default. Off: no command is sent and the results are not shown. Disconnect: also deletes the stored rows and the settings. Only Russia has the references the method needs; with another country selected it does nothing. It is not built for the Cloudflare edition: a run takes minutes, the scheduled jobs of that edition have seconds.
Index ¶
- Constants
- type Config
- type Fleet
- type Node
- type References
- type Service
- func (s *Service) Handler(opts ...connect.HandlerOption) (string, http.Handler)
- func (s *Service) NowPlan(ctx context.Context, nodeID string) (run func(context.Context) (string, string), skip string)
- func (s *Service) Run(ctx context.Context)
- func (s *Service) State(ctx context.Context) State
- func (s *Service) Tick(ctx context.Context) bool
- type State
Constants ¶
const ( DefaultIntervalMin = 120 MinIntervalMin = 30 MaxIntervalMin = 1440 )
const ( StatusOK = "ok" StatusControlFailed = "control_failed" StatusNoDPIHop = "no_dpi_hop" StatusBusy = "busy" StatusFailed = "failed" )
The status words of a run (TspuProbeRun.status).
const ( // ReasonRefsPass: a blocked reference answered, so blocked addresses get through on the probe node's path. ReasonRefsPass = "refs_pass" // ReasonNoHops: no router answered for any reference, so the route is hidden. ReasonNoHops = "no_hops" )
The reasons of a no_dpi_hop run (TspuProbeRun.reason).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Store *store.Store
// StepUp is auth.Service.RequireStepUp: changing the settings asks for it.
StepUp func(context.Context) error
Fleet Fleet
// Nodes lists the active nodes (health.Service.ProbeNodes).
Nodes func(context.Context) ([]Node, error)
// Country is the shared country of the country check (countryreach.Service.Country). Default RU.
Country func(context.Context) string
// OnChange is called after the settings changed, the source was disconnected or a run stored its rows, so that the alerts that
// depend on it are brought up to date at once (health.Service.ReconcileCountry). May be nil.
OnChange func(context.Context)
// Edge is the Cloudflare edition: the source is not built for it, Get says so and nothing runs.
Edge bool
Log *slog.Logger
Now func() time.Time
}
Config configures Service. Store, StepUp, Fleet and Nodes are required.
type Fleet ¶
type Fleet interface {
CountryProbe(ctx context.Context, nodeID string, req fleet.CountryProbeRequest) (fleet.CountryProbeResult, error)
}
Fleet is the part of the fleet the probe uses.
type Node ¶
type Node struct {
ID, Name, Address, CountryCode string
Caps []string // the capabilities its agent listed in its last Hello
Online bool
Ports []uint16 // the TCP ports of its enabled inbounds
}
Node is an active node as the probe sees it: whom it can probe from, and what to test.
type References ¶
type References struct {
Control string
ControlSNI string // reserved by the agent (the SYN method sends no hello); kept so a later hello-based method has it
Blocked []string
}
References are the two addresses of a country that make the probe work (agent.proto "COUNTRY PROBE"). Control is an address that is never blocked there: the probe finds the TSPU box with the references and checks that SYNs to the control still pass behind it, which is how it knows the method applies on the probe node's network. Blocked are addresses that the TSPU surely drops, best first: the probe node SYN-traces one of them and the last router that answers is the box's position. The panel sends them one at a time (see run); the owner does not set them.
They are built into the code, not settings: a wrong reference silently breaks the method, and the list changes with the panel's releases when a service stops being blocked.
func ReferencesFor ¶
func ReferencesFor(country string) (References, bool)
ReferencesFor are the references of a country; ok is false when it has none (the probe does not apply there).
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the integration.
func (*Service) NowPlan ¶
func (s *Service) NowPlan(ctx context.Context, nodeID string) (run func(context.Context) (string, string), skip string)
NowPlan is the TSPU probe's part of "Check now" of a node (health.CountryNowSource): the probe node tests that one node out of turn. It says at once why it will not (the reason words of health.CountryNowSource) or returns the run, which keeps the run lock from now until it ends. The run stores the node's rows like a scheduled one, but leaves the status of the newest run and the rotation of the batches alone. A run is one batch of one node: about a minute; its status is the reason when it did not end "ok".
func (*Service) Run ¶
Run is the background loop of the VPS edition. The Cloudflare edition has no such source, so it has no loop either.
func (*Service) State ¶
State reads the settings; an off source (the default, or any trouble reading them) costs one read.
func (*Service) Tick ¶
Tick runs the probe when it is due and reports whether it ran. The VPS loop calls it; it is safe to call often. Nothing happens (no command, no request of any kind) while the source is off, has no probe node, covers another country, or on the Cloudflare edition; the probe node being offline or too old skips the round without a trace.