Documentation
¶
Overview ¶
Package cheburcheck checks whether volunteer networks can send a SYN through the TSPU box to a node's IPv4 address. The site sees the node address, panel address and Mistgate User-Agent. The integration is off by default; own-probe credentials are sealed in the vault and are only sent to the site's probe endpoint.
Index ¶
- Constants
- func StateKeys() []string
- type Config
- type Service
- func (s *Service) Handler(opts ...connect.HandlerOption) (string, http.Handler)
- func (s *Service) NowPlan(ctx context.Context, nodeID, source 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) error
- type SourceState
- type State
Constants ¶
const ( SourcePublic = "cheburcheck" SourceOwn = "cheburcheck_own" )
const (
// DefaultBaseURL is cheburcheck's API. Tests override it with a local httptest server.
DefaultBaseURL = "https://cheburcheck.ru"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Store *store.Store
Vault *vault.Vault
// StepUp is auth.Service.RequireStepUp: changing the settings asks for it.
StepUp func(context.Context) error
// Address resolves a node the way health.Service.NodeIPv4 does. It must return an IPv4 address.
Address func(context.Context, store.NodeRow) (netip.Addr, bool)
// HTTPClient and BaseURL are transport overrides. Tests use an httptest server; BaseURL defaults to the public site.
HTTPClient *http.Client
BaseURL string
// Edge uses the shorter tick budget. RoundLease coordinates the shared site limit across edge isolates.
Edge bool
RoundLease func(context.Context, string, time.Duration) bool
// ProbeTimeout overrides the whole check+SSE budget in tests. Production uses the VPS or edge default.
ProbeTimeout time.Duration
// OnChange refreshes the country alerts after a setting change or stored result.
OnChange func(context.Context)
Log *slog.Logger
Now func() time.Time
}
Config configures Service. Store, Vault, StepUp and Address are required.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) NowPlan ¶
func (s *Service) NowPlan(ctx context.Context, nodeID, source string) (run func(context.Context) (string, string), skip string)
NowPlan is cheburcheck's part of "Check now" of a node (health.CountryNowSource): the node is checked on one source (SourcePublic or SourceOwn) out of turn, whatever its interval says. It says at once why it will not (the reason words of health.CountryNowSource) or returns the check, which waits for the spacing of the site's calls, then stores the result like a scheduled one. The hold after a rate limit or repeated failures is kept: no call goes to the site during it.
func (*Service) Run ¶
Run is the VPS polling loop. The edge build calls Tick from its cron job instead.
type SourceState ¶
SourceState is a source name with its current switch and freshness window, ready for health.Config.External.
type State ¶
type State struct {
On bool
PublicOn bool
OwnOn bool
PublicMaxAge time.Duration
OwnMaxAge time.Duration
Status string
TokenUnknown bool
HoldUntil time.Time
LastRun time.Time
LastVerdict string
}
State is the cheburcheck source state the health module needs. Its sources have separate intervals and freshness windows.
func (State) Sources ¶
func (st State) Sources() []SourceState
Sources maps State to the source entries consumed by health.Config.External.