dashboard

package
v0.3.88 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNewer added in v0.3.4

func IsNewer(remote, local string) bool

IsNewer returns true if remote version is newer than local. Exported for use by handlers.

Types

type AgentBinaryInfo

type AgentBinaryInfo struct {
	Version    string `json:"version"`
	Checksum   string `json:"checksum"` // SHA-256 hex
	Size       int64  `json:"size"`
	OS         string `json:"os"`   // e.g. "linux"
	Arch       string `json:"arch"` // e.g. "amd64"
	UploadedAt int64  `json:"uploaded_at"`
	FilePath   string `json:"-"` // internal, not serialized to API
}

AgentBinaryInfo holds metadata about an uploaded agent binary.

type DockerTag

type DockerTag struct {
	Name        string `json:"name"`
	LastUpdated string `json:"last_updated"`
	FullSize    int64  `json:"full_size"`
	IsLatest    bool   `json:"is_latest,omitempty"`
}

DockerTag represents a Docker Hub image tag.

type GeoIPResolver

type GeoIPResolver struct {
	// contains filtered or unexported fields
}

GeoIPResolver resolves IP addresses to geographic regions.

func NewGeoIPResolver

func NewGeoIPResolver() *GeoIPResolver

NewGeoIPResolver creates a new resolver with an in-memory cache.

func (*GeoIPResolver) Resolve

func (g *GeoIPResolver) Resolve(ctx context.Context, ip string) string

Resolve returns a human-readable region string for the given IP. Results are cached in memory. Returns empty string on failure.

type RegistrationToken

type RegistrationToken struct {
	Token     string
	CreatedAt time.Time
	ExpiresAt time.Time
}

RegistrationToken is a one-time token for agent registration.

type ReleaseAsset

type ReleaseAsset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
	Size               int64  `json:"size"`
}

ReleaseAsset holds info about a release download asset.

type ReleaseInfo

type ReleaseInfo struct {
	TagName    string         `json:"tag_name"`
	Name       string         `json:"name"`
	Body       string         `json:"body"`
	HTMLURL    string         `json:"html_url"`
	PublishAt  string         `json:"published_at"`
	Assets     []ReleaseAsset `json:"assets"`
	CheckedAt  time.Time      `json:"-"`
	HasUpdate  bool           `json:"has_update"`
	CurrentVer string         `json:"current_version"`
}

ReleaseInfo holds information about a GitHub release.

func (*ReleaseInfo) FindAsset

func (r *ReleaseInfo) FindAsset(prefix, goos, goarch string) string

FindAsset returns the download URL for a specific binary type. Supports both legacy (klever-node-hub-, klever-agent-) and short (dashboard-, agent-) prefixes.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the main dashboard HTTP server.

func NewServer

func NewServer(config *ServerConfig) *Server

NewServer creates a new dashboard server.

func (*Server) Mux

func (s *Server) Mux() *http.ServeMux

Mux returns the underlying ServeMux for registering additional routes.

func (*Server) SecurityHeadersMiddleware

func (s *Server) SecurityHeadersMiddleware(next http.Handler) http.Handler

SecurityHeadersMiddleware wraps a handler with security headers.

func (*Server) SetupRoutes

func (s *Server) SetupRoutes() error

SetupRoutes configures all HTTP routes including static assets and templates.

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTPS server.

type ServerConfig

type ServerConfig struct {
	Addr string       // Listen address, e.g. ":9443"
	CA   *kvcrypto.CA // CA for mTLS (if nil, uses self-signed cert)
}

ServerConfig holds the dashboard HTTP server configuration.

type TagCache

type TagCache struct {
	// contains filtered or unexported fields
}

TagCache caches Docker Hub tag listings.

func NewTagCache

func NewTagCache() *TagCache

NewTagCache creates a new tag cache.

func (*TagCache) GetTags

func (tc *TagCache) GetTags() ([]DockerTag, error)

GetTags returns cached tags or fetches fresh ones if expired.

func (*TagCache) Invalidate added in v0.3.75

func (tc *TagCache) Invalidate()

Invalidate clears the cache so the next GetTags call fetches fresh from Docker Hub. Used by the manual "Check for updates" button so operators can pick up a freshly published release without waiting out the TTL.

type TokenManager

type TokenManager struct {
	// contains filtered or unexported fields
}

TokenManager manages one-time registration tokens.

func NewTokenManager

func NewTokenManager() *TokenManager

NewTokenManager creates a new TokenManager.

func (*TokenManager) Generate

func (tm *TokenManager) Generate() (string, error)

Generate creates a new one-time registration token.

func (*TokenManager) PendingCount

func (tm *TokenManager) PendingCount() int

PendingCount returns the number of valid pending tokens.

func (*TokenManager) Validate

func (tm *TokenManager) Validate(token string) bool

Validate checks if a token is valid (exists and not expired). If valid, the token is consumed (single-use).

type UpdateStore

type UpdateStore struct {
	// contains filtered or unexported fields
}

UpdateStore manages uploaded agent binaries.

func NewUpdateStore

func NewUpdateStore(dataDir string) *UpdateStore

NewUpdateStore creates a new update store.

func (*UpdateStore) DownloadedVersions added in v0.3.6

func (s *UpdateStore) DownloadedVersions() []string

DownloadedVersions returns a sorted list of unique version strings in the store.

func (*UpdateStore) Get

func (s *UpdateStore) Get(osName, arch string) *AgentBinaryInfo

Get returns the binary info for the latest version of a specific OS/arch.

func (*UpdateStore) GetBinary

func (s *UpdateStore) GetBinary(osName, arch string) ([]byte, *AgentBinaryInfo, error)

GetBinary returns the binary data for the latest version of a specific OS/arch.

func (*UpdateStore) GetBinaryVersion added in v0.3.6

func (s *UpdateStore) GetBinaryVersion(version, osName, arch string) ([]byte, *AgentBinaryInfo, error)

GetBinaryVersion returns the binary data for a specific version and OS/arch.

func (*UpdateStore) LatestVersion

func (s *UpdateStore) LatestVersion() string

LatestVersion returns the version string of the most recently uploaded binary.

func (*UpdateStore) List

func (s *UpdateStore) List() []*AgentBinaryInfo

List returns all stored binary infos.

func (*UpdateStore) Store

func (s *UpdateStore) Store(version, osName, arch string, data []byte) (*AgentBinaryInfo, error)

Store saves an agent binary to disk and records its metadata.

type VersionChecker

type VersionChecker struct {
	// contains filtered or unexported fields
}

VersionChecker periodically checks GitHub for new releases.

func NewVersionChecker

func NewVersionChecker(owner, repo string) *VersionChecker

NewVersionChecker creates a new version checker.

func (*VersionChecker) FetchReleases added in v0.3.4

func (vc *VersionChecker) FetchReleases(limit int) ([]ReleaseInfo, error)

FetchReleases fetches the last N releases from GitHub (on-demand, no caching).

func (*VersionChecker) ForceCheck added in v0.3.5

func (vc *VersionChecker) ForceCheck()

ForceCheck triggers an immediate version check (on-demand).

func (*VersionChecker) Latest

func (vc *VersionChecker) Latest() *ReleaseInfo

Latest returns the most recently fetched release info.

func (*VersionChecker) Start

func (vc *VersionChecker) Start()

Start begins periodic version checking.

Directories

Path Synopsis
Package alerting implements the alert rules evaluation engine.
Package alerting implements the alert rules evaluation engine.
Package scheduler implements background jobs for metrics maintenance.
Package scheduler implements background jobs for metrics maintenance.

Jump to

Keyboard shortcuts

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