ownprobe

package
v0.2.0-dev.9 Latest Latest
Warning

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

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

Index

Constants

View Source
const SilentAfter = time.Hour

SilentAfter is how long an active probe may keep silent and still be asked: the Own probes card says "no contact" past it (web/src/lib/ownprobe.ts offlineAfterSec). A probe that has been silent longer than its interval cannot take a job, so it is not asked, and the card says so.

Variables

This section is empty.

Functions

func BuildInstallCommand

func BuildInstallCommand(publicURL, prefix, token, scriptHash string) (string, error)

BuildInstallCommand returns the one-time command for a router with Entware (Keenetic): the packages, the download, the hash check and the install with the token. The random token alphabet is restricted, and URLs are validated before shell quoting. Only a missing package is installed: "opkg install curl" on a router that has curl upgrades the program without its library and breaks it, and "opkg update" fails as a whole when one stale custom feed does, so it runs only when an install needs it.

func BuildServerInstallCommand

func BuildServerInstallCommand(publicURL, prefix, token, scriptHash string) (string, error)

BuildServerInstallCommand is the one-time command for a server: no opkg, the script through sudo.

func BuildServerUpdateCommand

func BuildServerUpdateCommand(publicURL, prefix, scriptHash string) (string, error)

BuildServerUpdateCommand is BuildUpdateCommand for a server.

func BuildUpdateCommand

func BuildUpdateCommand(publicURL, prefix, scriptHash string) (string, error)

BuildUpdateCommand updates a probe already standing on a router: the same download and hash check as the install, then `upgrade`. It carries no token: the probe keeps the panel's address and its own secret in its configuration.

func ScriptHash

func ScriptHash() string

ScriptHash is the SHA-256 of the embedded installation script.

func ScriptVersion

func ScriptVersion() string

ScriptVersion is the version identifier carried by sync reports.

Types

type Config

type Config struct {
	Store       *store.Store
	Limiter     securitylimit.Limiter
	StepUp      func(context.Context) error
	PublicURL   string
	ProbePrefix string
	Now         func() time.Time
	Targets     func(context.Context) ([]Target, error)
	Country     func(context.Context) string
	ASN         func(netip.Addr) uint32
	Operator    func(country string, asn uint32) string
	References  func(country string) (References, bool)
	OnChange    func(context.Context)
	SyncBurst   int // reports in a row one probe may send before the 5-minute refill; 0 = 3
	Log         *slog.Logger
}

type References

type References struct {
	ControlIP  string
	ControlSNI string
	BlockedIP  string
}

References are country-specific control addresses supplied by the existing reference source.

type Service

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

Service owns the admin and public surfaces. mu serializes report folds and revocation refolds in this process.

func New

func New(cfg Config) *Service

func (*Service) Handler

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

func (*Service) NowPlan

func (s *Service) NowPlan(ctx context.Context, _ string) (run func(context.Context) (string, string), skip string)

NowPlan is the owner's probes' part of "Check now" of a node (health.CountryNowSource): every active probe that has been heard from lately has its next job made due now, so that it takes the next one at its next sync (the probes ask every 12 to 18 minutes; the job covers the fleet's nodes, this one among them). Nothing is sent to a probe: it comes for the job itself. The source reads "queued", and the result reaches the verdict when the probes report. With no such probe it says why.

func (*Service) PublicHandler

func (s *Service) PublicHandler(decoyDir string) http.Handler

PublicHandler is the handler of the probes' endpoint, to mount under probe_prefix; decoyDir is the decoy site's directory.

func (*Service) SourceState

func (s *Service) SourceState(ctx context.Context) (bool, time.Duration, error)

SourceState tells the health module whether the "probes" source is on, and how old a point may be before it stops counting: three intervals.

type Settings

type Settings struct {
	Enabled     bool   `json:"enabled"`
	IntervalMin uint32 `json:"intervalMin"`
	FallbackURL string `json:"fallbackUrl"`
}

type SyncReport

type SyncReport struct {
	Version, JobID string
	Control        string
	ControlMS      uint32
	Reference      string
	Results        []SyncResult
}

SyncReport is a fully parsed report. Unknown and malformed lines fail ParseSync as a whole.

func ParseSync

func ParseSync(body []byte) (SyncReport, error)

ParseSync accepts the exact line protocol of the plan (ru-probes-plan §2.3). It does not accept whitespace normalization, CRLF, unknown fields, duplicate fields, repeated or unordered result indexes, or values outside the curl/script contract: the first line it does not know cancels the whole report.

type SyncResult

type SyncResult struct {
	Index           int
	TCP, TLS, Fetch string
	TCPMS, TLSMS    uint32
	Bytes           uint32
}

SyncResult is one numbered result. The target address is never present in the report; the index is matched only to the panel's saved job.

type Target

type Target struct {
	NodeID string `json:"node_id"`
	IP     string `json:"ip"`
	Port   uint16 `json:"port"`
	Kind   string `json:"kind"`
	SNI    string `json:"sni,omitempty"`
	Path   string `json:"path,omitempty"`
}

Target is a panel-selected destination. The public response never accepts or echoes a target from the probe.

Jump to

Keyboard shortcuts

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