fakeconsole

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0 Imports: 24 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 fakeconsole is a minimal in-memory implementation of the console's NodeService and ProbeService (connect-go) used by the integration tests and the container smoke test. It enforces the same authentication rules as the real console: Enroll and EnrollProbe are authorised by single-use tokens, every other RPC requires an mTLS client certificate issued by the internal CA whose CN is the node id (NodeService, and ProbeService while the node may probe) or the probe id with O=Edgeweir Probe (ProbeService only).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Console

type Console struct {
	nodev1connect.UnimplementedNodeServiceHandler

	CA *pkitest.CA
	// contains filtered or unexported fields
}

Console is the fake NodeService.

func New

func New(opts Options) (*Console, error)

New creates a console with a fresh internal CA.

func (*Console) AddBan

func (c *Console) AddBan(b *nodev1.Ban) uint64

AddBan stores (or replaces, by id) an active ban under a new sequence and announces it on open watch streams. It returns the sequence.

func (*Console) AddProbeToken

func (c *Console) AddProbeToken(token string)

AddProbeToken registers a single-use probe token.

func (*Console) AddTask

func (c *Console) AddTask(task *nodev1.NodeTask, quiet bool)

AddTask queues a task and announces it on open watch streams (unless quiet, which leaves discovery to heartbeats and polling).

func (*Console) AddTasks

func (c *Console) AddTasks(quiet bool, tasks ...*nodev1.NodeTask)

AddTasks queues several tasks at once (one PullTasks sees all of them).

func (*Console) AddToken

func (c *Console) AddToken(token string)

AddToken registers a single-use enrollment token.

func (*Console) ChallengeKeyRequests

func (c *Console) ChallengeKeyRequests() [][]string

ChallengeKeyRequests returns the ids of every GetChallengeKeys call.

func (*Console) ChannelChecks added in v1.2.0

func (c *Console) ChannelChecks() []string

ChannelChecks returns the callers of CheckChannel and CheckProbeChannel.

func (*Console) CheckChannel added in v1.2.0

CheckChannel implements NodeService.

func (*Console) CheckProbeChannel added in v1.2.0

CheckProbeChannel implements ProbeService.

func (*Console) Close

func (c *Console) Close()

Close ends all open WatchConfig streams.

func (*Console) CorruptNextDiff

func (c *Console) CorruptNextDiff()

CorruptNextDiff makes the next diff announce a wrong content hash.

func (*Console) Counters

func (c *Console) Counters() (enrollments, renewals, watchStreams int, mtls map[string]int)

Counters returns enrollments, renewals, watch streams and per-procedure mTLS call counts.

func (*Console) CredentialRequests

func (c *Console) CredentialRequests() [][]string

CredentialRequests returns the ids of every GetOriginCredentials call.

func (*Console) DebugLogUploads added in v1.6.0

func (c *Console) DebugLogUploads() []*nodev1.UploadDebugLogsRequest

DebugLogUploads returns the debug log uploads received.

func (*Console) DisableCheck added in v1.2.0

func (c *Console) DisableCheck(on bool)

DisableCheck makes CheckChannel and CheckProbeChannel answer Unimplemented, like a console before channel-follow-v1.

func (*Console) Enroll

Enroll implements NodeService.

func (*Console) EnrollProbe

EnrollProbe implements ProbeService.

func (*Console) FailDebugLogUploads added in v1.6.0

func (c *Console) FailDebugLogUploads(n int)

FailDebugLogUploads refuses the next n debug log uploads.

func (*Console) FailLogsAcknowledgements

func (c *Console) FailLogsAcknowledgements(n int)

func (*Console) FailNodeLogsAcknowledgements added in v1.3.0

func (c *Console) FailNodeLogsAcknowledgements(n int)

FailNodeLogsAcknowledgements loses the next n acknowledgements of node log batches (after storing them).

func (*Console) FailProbeReports

func (c *Console) FailProbeReports(n int)

func (*Console) FailProbeTargets

func (c *Console) FailProbeTargets(n int)

FailProbeTargets and FailProbeReports make the next n calls fail with Unavailable.

func (*Console) FailReportBans

func (c *Console) FailReportBans(n int)

FailReportBans makes the next n ReportBans calls fail.

func (*Console) FailReportSecurityEvents

func (c *Console) FailReportSecurityEvents(n int)

FailReportSecurityEvents makes the next n ReportSecurityEvents calls fail.

func (*Console) FailStatsAcknowledgements

func (c *Console) FailStatsAcknowledgements(count int)

func (*Console) FailStatsQueries

func (c *Console) FailStatsQueries(count int)

FailStatsQueries makes the next count statistics cursor queries fail (an empty ReportStatsV2 without a watermark), as while the console is unreachable.

func (*Console) FailTaskResults added in v1.7.0

func (c *Console) FailTaskResults(n int)

FailTaskResults makes the next n ReportTaskResult calls fail (Unavailable) without recording them.

func (*Console) GetBans

GetBans implements NodeService like the console: a snapshot (reset) when after_sequence is 0 or ahead of the console, otherwise the changes after it, in sequence order and paged.

func (*Console) GetBansCalls

func (c *Console) GetBansCalls() []*nodev1.GetBansRequest

GetBansCalls returns every GetBans request.

func (*Console) GetCertificates added in v1.0.0

GetCertificates implements NodeService: the certificates it knows, others left out.

func (*Console) GetConfig

GetConfig implements NodeService.

func (*Console) GetConfigCalls

func (c *Console) GetConfigCalls() []GetConfigCall

GetConfigCalls returns all GetConfig exchanges.

func (*Console) GetOriginCredentials

GetOriginCredentials implements NodeService.

func (*Console) GetProbeTargets

GetProbeTargets implements ProbeService.

func (*Console) GetSessionTicketKeys added in v1.0.0

GetSessionTicketKeys implements NodeService: the keys it knows, others left out.

func (*Console) Handler

func (c *Console) Handler() http.Handler

Handler returns the HTTP handler serving NodeService and ProbeService.

func (*Console) L4Stats

func (c *Console) L4Stats() []*nodev1.L4MinuteStats

L4Stats returns the layer-4 buckets of the accepted statistics batches.

func (*Console) LastStatus

func (c *Console) LastStatus() *nodev1.ReportStatusRequest

LastStatus returns the latest ReportStatus request, or nil.

func (*Console) LiftOwnBan

func (c *Console) LiftOwnBan(b *nodev1.Ban) uint64

LiftOwnBan lifts an automatic ban of the node that was never shared (GetBans returns it in lifted_own_bans) and announces it.

func (*Console) Logs

func (c *Console) Logs() []*nodev1.AccessLog

func (*Console) LogsSequences

func (c *Console) LogsSequences() []uint64

func (*Console) NodeLogs added in v1.3.0

func (c *Console) NodeLogs() ([]*nodev1.NodeLogEntry, []uint64, [2]uint64)

NodeLogs returns the node log entries stored, the batch sequences received and the drops reported (rate limited, overflow).

func (*Console) Options

func (c *Console) Options() Options

Options returns the effective options.

func (*Console) PinLatest

func (c *Console) PinLatest(rev uint64)

PinLatest makes the console serve revision rev as its latest one (a console restored from an older backup); 0 serves the newest again.

func (*Console) ProbeCounters

func (c *Console) ProbeCounters() (enrollments, renewals int)

ProbeCounters returns probe enrollments and certificate renewals.

func (*Console) ProbeReports

func (c *Console) ProbeReports() []ProbeReport

ProbeReports returns every stored round.

func (*Console) ProbeTargetCalls

func (c *Console) ProbeTargetCalls() []ProbeTargetsCall

ProbeTargetCalls returns every GetProbeTargets call.

func (*Console) Publish

func (c *Console) Publish(cfg *nodev1.NodeConfig) uint64

Publish stores cfg as the next revision (canonicalized and hashed) and notifies watchers. It returns the new revision.

func (*Console) PullTasks

PullTasks implements NodeService: every queued task is handed out once.

func (*Console) Purges added in v1.0.0

func (c *Console) Purges() []*nodev1.SubmitPurgeRequest

Purges returns every accepted SubmitPurge request.

func (*Console) RefuseReports

func (c *Console) RefuseReports(on bool)

RefuseReports answers ReportStatus with PermissionDenied while on, as the console does for a disabled node.

func (*Console) RejectNode added in v1.2.0

func (c *Console) RejectNode(on bool)

RejectNode makes every NodeService call but Enroll answer Unauthenticated, like the console for a deleted node.

func (*Console) RemoveBan

func (c *Console) RemoveBan(id string) uint64

RemoveBan lifts a ban under a new sequence and announces it.

func (*Console) RenewCertificate

RenewCertificate implements NodeService.

func (*Console) RenewProbeCertificate

RenewProbeCertificate implements ProbeService.

func (*Console) ReportBans

ReportBans implements NodeService.

func (*Console) ReportLogs

ReportLogs implements NodeService.

func (*Console) ReportNodeLogs added in v1.3.0

ReportNodeLogs implements NodeService.

func (*Console) ReportProbeResults

ReportProbeResults implements ProbeService.

func (*Console) ReportStats

ReportStats implements NodeService.

func (*Console) ReportStatus

ReportStatus implements NodeService.

func (*Console) ReportTaskResult

ReportTaskResult implements NodeService.

func (*Console) ReportedBans

func (c *Console) ReportedBans() []*nodev1.AutoBan

ReportedBans returns every automatic ban the node reported.

func (*Console) RequestProbeRenewal

func (c *Console) RequestProbeRenewal()

RequestProbeRenewal sets renew_certificate in the next GetProbeTargets response.

func (*Console) RequestRenewal

func (c *Console) RequestRenewal()

RequestRenewal sets renew_certificate in the next ReportStatus response.

func (*Console) SecurityEvents

func (c *Console) SecurityEvents() ([]*nodev1.SecurityEvent, []int)

SecurityEvents returns the stored events (each id once, in arrival order) and the size of every accepted call.

func (*Console) SessionTicketKeyRequests added in v1.0.0

func (c *Console) SessionTicketKeyRequests() [][]string

SessionTicketKeyRequests returns the ids of every GetSessionTicketKeys call.

func (*Console) SetBanPageLimit

func (c *Console) SetBanPageLimit(n int)

SetBanPageLimit caps the bans of one GetBans page (0: 5000).

func (*Console) SetBanSequence

func (c *Console) SetBanSequence(seq uint64)

SetBanSequence moves the ban sequence (a console restored from an older backup sets it below what nodes have applied).

func (*Console) SetCertificate added in v1.0.0

func (c *Console) SetCertificate(m *nodev1.CertificateMaterial)

SetCertificate makes GetCertificates hand out a site certificate.

func (*Console) SetChallengeKey

func (c *Console) SetChallengeKey(id string, secret []byte)

SetChallengeKey makes GetChallengeKeys hand out a key.

func (*Console) SetChannel added in v1.2.0

func (c *Console) SetChannel(a *nodev1.ChannelAddress)

SetChannel sets the node channel address heartbeats and probe rounds hand out (nil: none, like an older console).

func (*Console) SetClock added in v1.5.0

func (c *Console) SetClock(ahead time.Duration)

SetClock sets how far the console's clock (console_time) is ahead of the real time.

func (*Console) SetCredential

func (c *Console) SetCredential(cred *nodev1.OriginCredential)

SetCredential makes GetOriginCredentials hand out cred.

func (*Console) SetExtensionPackage added in v1.8.0

func (c *Console) SetExtensionPackage(digest string, archive []byte)

func (*Console) SetExtensionPackageError added in v1.8.0

func (c *Console) SetExtensionPackageError(err error)

func (*Console) SetExtensionSecret added in v1.8.0

func (c *Console) SetExtensionSecret(secret *nodev1.ExtensionSecret)

func (*Console) SetLocateAddress added in v1.6.2

func (c *Console) SetLocateAddress(address string)

SetLocateAddress makes ReportStatus ask the node to locate address.

func (*Console) SetNodeLogsUnsupported added in v1.3.0

func (c *Console) SetNodeLogsUnsupported(v bool)

SetNodeLogsUnsupported answers ReportNodeLogs with Unimplemented (a console older than node-logs-v1).

func (*Console) SetNodeProbe

func (c *Console) SetNodeProbe(on bool)

SetNodeProbe lets the node probe (ReportStatusResponse.probe and access to ProbeService with the node certificate) or stops it.

func (*Console) SetProbeTargets

func (c *Console) SetProbeTargets(resp *nodev1.GetProbeTargetsResponse)

SetProbeTargets sets what GetProbeTargets answers (targets and timing).

func (*Console) SetPurgeError added in v1.0.0

func (c *Console) SetPurgeError(err error)

SetPurgeError makes SubmitPurge fail with err (nil: succeed again).

func (*Console) SetSessionTicketKey added in v1.0.0

func (c *Console) SetSessionTicketKey(id string, secret []byte)

SetSessionTicketKey makes GetSessionTicketKeys hand out a key.

func (*Console) StartTLS

func (c *Console) StartTLS(tb testing.TB) *httptest.Server

StartTLS serves the console on a local HTTPS test server (HTTP/2 enabled) with a certificate for 127.0.0.1, ::1, localhost and console.test. The server is closed when the test ends.

func (*Console) StartWebSocketEntry added in v0.2.0

func (c *Console) StartWebSocketEntry(tb testing.TB, srv *httptest.Server, secure bool) *httptest.Server

StartWebSocketEntry serves a node channel WebSocket entry in front of srv (from StartTLS), like the console's on its web port: each WebSocket at /node-channel with the edgeweir-node-channel subprotocol is piped to a TCP connection to srv, so the node's TLS runs inside it. With secure the entry itself is served over TLS (wss://, with httptest's own certificate); otherwise over plain HTTP (ws://). The server is closed when the test ends.

func (*Console) Stats

func (c *Console) Stats() []*nodev1.MinuteStats

func (*Console) StatsSequences

func (c *Console) StatsSequences() []uint64

func (*Console) Statuses

func (c *Console) Statuses() []*nodev1.ReportStatusRequest

Statuses returns all ReportStatus requests received so far.

func (*Console) SubmitPurge added in v1.0.0

SubmitPurge implements NodeService: records the request and answers with task "purge-<n>", or with the error SetPurgeError set.

func (*Console) TLSConfig

func (c *Console) TLSConfig(dnsNames []string, ips []net.IP) (*tls.Config, error)

TLSConfig returns the server TLS configuration (leaf + CA chain, client certificates verified when presented).

func (*Console) TaskPulls

func (c *Console) TaskPulls() []bool

TaskPulls returns purge_only of every PullTasks call so far.

func (*Console) TaskResults

func (c *Console) TaskResults() []*nodev1.ReportTaskResultRequest

TaskResults returns every reported task result.

func (*Console) UploadDebugLogs added in v1.6.0

UploadDebugLogs stores the upload (debug-logs-v1).

func (*Console) WatchConfig

WatchConfig implements NodeService.

func (*Console) Watermarks

func (c *Console) Watermarks() []Watermark

Watermarks returns the statistics watermarks received, oldest first.

type GetConfigCall

type GetConfigCall struct {
	Request  *nodev1.GetConfigRequest
	Snapshot bool
	Revision uint64
}

GetConfigCall records one GetConfig exchange.

type Options

type Options struct {
	NodeID            string
	ClusterID         string
	NodeName          string
	CertLifetime      time.Duration
	KeepaliveInterval time.Duration
	ReportInterval    uint32
	// The probe that EnrollProbe registers (defaults probe-1, probe-east,
	// region-1).
	ProbeID   string
	ProbeName string
	RegionID  string
}

Options configure a Console.

type ProbeReport

type ProbeReport struct {
	Caller  string
	Request *nodev1.ReportProbeResultsRequest
}

ProbeReport is one ReportProbeResults call.

type ProbeTargetsCall

type ProbeTargetsCall struct {
	Caller  string
	Info    *nodev1.ProbeInfo
	Channel *nodev1.ChannelStatus
}

ProbeTargetsCall is one GetProbeTargets call: who made it (the probe or node id) and the ProbeInfo it sent.

type Watermark

type Watermark struct {
	CompleteUntil time.Time
	BatchSequence uint64
	Acknowledged  uint64
}

Stats returns all uploaded minute stats. Watermark is one complete_until a node reported, with the batch sequence of its request and the highest sequence acknowledged at that time.

Jump to

Keyboard shortcuts

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