Documentation
¶
Index ¶
- 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
- type Settings
- type SyncReport
- type SyncResult
- type Target
Constants ¶
This section is empty.
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) 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.