Documentation
¶
Overview ¶
Package check is bweb's loopback checker, bweb check (docs/check.md): a small HTTP service on the node's own loopback that answers whether servers serve a site, for a program on the same node that must decide which addresses to hand out for it (bdns's renderer). Each verdict is the serving challenge (package challenge) run by this node itself, against the site's proven content read through the node's bstore gateway. A verdict from another node is never taken.
GET /v1/check challenges exact addresses of a site; GET /v1/advertised challenges the servers advertising it, each at the addresses its URL resolves to. Verdicts are kept a short time (at most 60 s).
Index ¶
Constants ¶
const ( // MaxCache is the longest a verdict stands. MaxCache = 60 * time.Second )
Bounds. Fixed, not configured: they keep an answer inside the renderer's own 30 s timeout.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Checker ¶
type Checker struct {
// Ref is where a challenge reads the site's content: the node's bstore
// gateway (web.S3Store).
Ref challenge.Reference
// Headers proves a site token's and an advertisement's block.
Headers chaintracker.ChainTracker
// Lookup asks the engine's ls_bweb a question.
Lookup func(ctx context.Context, query map[string]string) ([]lookup.Output, error)
// Resolve answers the addresses a host name resolves to; nil is the
// system's resolver.
Resolve func(ctx context.Context, host string) ([]string, error)
// Token, when set, is the bearer token every request must carry.
Token string
// Engine and AskTTL keep the engine carrying each checked site's
// topics, one ask a site (bweb-check-<site>); a zero AskTTL asks
// nothing. Keep is web.KeepAsking unless set.
Engine string
AskTTL time.Duration
Keep func(ctx context.Context, a *engineask.Asker, after <-chan struct{}) <-chan struct{}
// CacheTTL is how long a verdict stands, at most MaxCache.
CacheTTL time.Duration
// MaxChecks bounds the challenges run at once, MaxAddrs the addresses
// of one /v1/check, MaxServers the entries one /v1/advertised
// challenges.
MaxChecks, MaxAddrs, MaxServers int
// Samples and FirstByte are each challenge's reads and the bound on a
// read's first byte.
Samples int
FirstByte time.Duration
// Private are the ranges a challenge may dial although they are not
// public addresses (challenge.PublicAddr).
Private []*net.IPNet
Now func() time.Time
Logf func(format string, args ...any)
Metrics *Metrics
// contains filtered or unexported fields
}
Checker answers the checker's two requests. Set the fields, then serve Handler and call Run.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics are the checker's counters. Every method is safe on a nil Metrics.
By the USE method: utilization (challenges in flight against their bound), saturation (the wait for a challenge slot), errors (answers by status, 503s, challenges by result).
func NewMetrics ¶
func NewMetrics(reg prometheus.Registerer) *Metrics
NewMetrics registers the checker's metrics with reg.
type Server ¶
type Server struct {
Address string `json:"address"`
Port int `json:"port"`
URL string `json:"url"`
Pass bool `json:"pass"`
// Unjudged is a verdict the checker could not make for this address
// (its own store failed during the challenge, or the challenge ran out
// of the checker's time): Pass is false, and nothing is kept.
Unjudged bool `json:"unjudged"`
Checked string `json:"checked"`
Samples int `json:"samples"`
Passed int `json:"passed"`
Reason string `json:"reason"`
}
Server is one server's verdict, as an answer lists it.