cheburcheck

package
v0.1.90-dev.4 Latest Latest
Warning

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

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

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

View Source
const (
	SourcePublic = "cheburcheck"
	SourceOwn    = "cheburcheck_own"
)
View Source
const (
	// DefaultBaseURL is cheburcheck's API. Tests override it with a local httptest server.
	DefaultBaseURL = "https://cheburcheck.ru"
)

Variables

This section is empty.

Functions

func StateKeys

func StateKeys() []string

StateKeys are the settings this source reads; StateFrom builds State from their values, so the panel can read them in one call with another source's.

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 New

func New(cfg Config) (*Service, error)

func (*Service) Handler

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

func (*Service) Run

func (s *Service) Run(ctx context.Context)

Run is the VPS polling loop. The edge build calls Tick from its cron job instead.

func (*Service) State

func (s *Service) State(ctx context.Context) State

State reports the source switches and freshness windows using settings only.

func (*Service) Tick

func (s *Service) Tick(ctx context.Context) error

Tick runs at most one overdue (source, node) check. It uses the same 30-second site lease on the VPS and edge.

type SourceState

type SourceState struct {
	Source string
	On     bool
	MaxAge time.Duration
}

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
	Unavailable  string
	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 StateFrom

func StateFrom(kv map[string]string) State

StateFrom is State from the values of StateKeys.

func (State) Sources

func (st State) Sources() []SourceState

Sources maps State to the source entries consumed by health.Config.External.

Jump to

Keyboard shortcuts

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