Documentation
¶
Index ¶
- Constants
- func BuildInstallCommand(publicURL, prefix, token, scriptHash string) (string, error)
- func BuildServerInstallCommand(publicURL, prefix, token, scriptHash string) (string, error)
- func BuildServerUpdateCommand(publicURL, prefix, scriptHash string) (string, error)
- func BuildUpdateCommand(publicURL, prefix, scriptHash string) (string, error)
- func ScriptHash() string
- func ScriptVersion() string
- type Config
- type References
- type Service
- func (s *Service) Handler(opts ...connect.HandlerOption) (string, http.Handler)
- func (s *Service) NowPlan(ctx context.Context, _ string) (run func(context.Context) (string, string), skip string)
- func (s *Service) PublicHandler(decoyDir string) http.Handler
- func (s *Service) SourceState(ctx context.Context) (bool, time.Duration, error)
- type Settings
- type SyncReport
- type SyncResult
- type Target
Constants ¶
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 ¶
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 ¶
BuildServerInstallCommand is the one-time command for a server: no opkg, the script through sudo.
func BuildServerUpdateCommand ¶
BuildServerUpdateCommand is BuildUpdateCommand for a server.
func BuildUpdateCommand ¶
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 ¶
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 (*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 ¶
PublicHandler is the handler of the probes' endpoint, to mount under probe_prefix; decoyDir is the decoy site's directory.
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 ¶
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.