panel

package
v0.9.4-dev.3 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: GPL-3.0 Imports: 20 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

Index

Constants

View Source
const (
	IDZashboard  = "zashboard"
	IDMetaCubeXD = "metacubexd"
)

Built-in panel identifiers.

View Source
const UIPathPrefix = "/__mihari/panels"

UIPathPrefix is the URL mount prefix for concurrent panel static trees. Each installed panel is available at /__mihari/panels/{panelID}/ independently of the default active panel. The prefix is under /__mihari/ so it never collides with mihomo controller routes such as /ui.

Variables

This section is empty.

Functions

func InstallFromZip

func InstallFromZip(request InstallRequest) (string, error)

InstallFromZip extracts a validated panel archive into staging, then atomically promotes it to web/{panelID}/{build}/. The caller must supply a unique build id.

func LoadCredential

func LoadCredential(path string) (string, error)

LoadCredential reads the Web access credential from path. This token authenticates browsers to the Web gateway and must never be the controller secret.

func LoadOrCreateCredential

func LoadOrCreateCredential(path string) (string, error)

LoadOrCreateCredential returns the existing Web credential or generates one once with 0600 permissions.

func PanelBuildDir

func PanelBuildDir(webRoot, panelID, build string) string

PanelBuildDir returns web/{panelID}/{build}/ under webRoot.

func PrepareInstallCandidate added in v0.9.3

func PrepareInstallCandidate(request InstallRequest) (string, error)

PrepareInstallCandidate extracts and hoists a panel zip using the existing archive policy. The zip must already have been copied through a trusted fd.

func ResolveFileRoot

func ResolveFileRoot(buildDir string) string

ResolveFileRoot finds the directory that should be served for a panel build tree. Preference order: index.html at root, dist/index.html, then the shallowest nested index.html. Returns empty string when no index.html is present.

func SaveActive

func SaveActive(path string, active Active) error

SaveActive atomically replaces active.json after validating panel and build identity. Both Panel and Build must be set together, or both empty to clear the default panel while optionally retaining Previous entries for other panels.

func UIMount

func UIMount(panelID string) string

UIMount returns the absolute URL path prefix for panelID (no trailing slash).

Types

type Active

type Active struct {
	Panel    string            `json:"panel"`
	Build    string            `json:"build"`
	Previous map[string]string `json:"previous,omitempty"`
}

Active is the atomic pointer to the panel build served by the Web gateway. Previous maps panel ID → retained prior build for one-step rollback.

func LoadActive

func LoadActive(path string) (Active, error)

LoadActive reads active.json. Missing file yields an empty Active without error.

type Adapter

type Adapter interface {
	ID() string
	DisplayName() string
	// ResolveLatest returns build id and download URL using an injected HTTP client.
	ResolveLatest(ctx context.Context) (build string, assetURL string, err error)
	// SetupPath returns a same-origin setup deep-link path+query (no secret, no controller host).
	SetupPath(gatewayHost string) string
}

Adapter resolves distribution assets and same-origin setup deep-links for a built-in panel.

type Entry

type Entry struct {
	ID   string
	Name string
}

Entry is a catalog record for a supported Web panel adapter.

func BuiltInCatalog

func BuiltInCatalog() []Entry

BuiltInCatalog returns the first-release panel adapters in stable order. Entries describe capability only; install state lives under web/{id}/{build}/ and active.json.

func Lookup

func Lookup(id string) (Entry, bool)

Lookup returns the catalog entry for id when the panel is supported.

type InstallRequest

type InstallRequest struct {
	PanelID    string
	Build      string
	Archive    string
	StagingDir string
	WebRoot    string
}

InstallRequest describes a local zip install into the versioned web tree.

type PanelInfo

type PanelInfo struct {
	ID             string
	Name           string
	Active         bool
	InstalledBuild string
	LatestBuild    string
	RollbackBuild  string
	Health         string
}

PanelInfo is a redacted view of one supported panel's install state.

type PreparedMutation added in v0.4.1

type PreparedMutation interface {
	Identity() string
	Valid() bool
	Commit() error
	Cleanup()
}

PreparedMutation is a validated panel candidate whose filesystem mutation is deferred until Commit.

type Service

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

Service owns panel install trees under web/ and the active.json pointer.

func Open

func Open(options ServiceOptions) (*Service, error)

Open constructs a panel service. Adapters may be empty for path-only tests.

func (*Service) Activate

func (s *Service) Activate(ctx context.Context, panelID string) error

Activate sets active.json to the newest complete installed build for panelID.

func (*Service) Active

func (s *Service) Active() (Active, error)

Active returns the current active.json pointer.

func (*Service) ActiveDir

func (s *Service) ActiveDir() (string, error)

ActiveDir returns the filesystem path of the active panel static tree, or empty if none. Nested archive layouts (dist/, single GitHub zipball root) are resolved.

func (*Service) Install

func (s *Service) Install(ctx context.Context, panelID, pinBuild string) error

Install prepares and commits a panel build for callers outside the runtime coordinator. Runtime callers use PrepareInstall so its mutation gate remains authoritative.

func (*Service) List

func (s *Service) List() []PanelInfo

List returns catalog entries with install/active metadata (no secrets).

func (*Service) PanelDir

func (s *Service) PanelDir(panelID string) (string, error)

PanelDir returns the static file root for an installed panel, independent of the default active pointer. When panelID is the default active panel, the active build is preferred; otherwise the newest ready build.

func (*Service) PrepareInstall added in v0.9.2

func (s *Service) PrepareInstall(ctx context.Context, panelID, pinBuild string) (PreparedMutation, error)

PrepareInstall downloads and validates a panel build without changing the installed tree. pinBuild selects a specific already-resolved asset only when the adapter's ResolveLatest is replaced by a test adapter; for production adapters, pinBuild when non-empty must match the resolved build id after ResolveLatest (download URL still comes from the adapter).

func (*Service) PrepareReinstall added in v0.4.1

func (s *Service) PrepareReinstall(ctx context.Context, panelID string) (PreparedMutation, error)

PrepareReinstall downloads and validates a replacement without deleting the installed tree.

func (*Service) PrepareUpdate added in v0.4.1

func (s *Service) PrepareUpdate(ctx context.Context, panelID string) (PreparedMutation, error)

PrepareUpdate downloads and validates the latest build without changing the installed tree.

func (*Service) Reinstall

func (s *Service) Reinstall(ctx context.Context, panelID string) error

Reinstall uninstalls panelID then installs the latest build. When the panel was the default active panel, it is re-activated after install.

func (*Service) RemoveBuild

func (s *Service) RemoveBuild(panelID, build string) error

RemoveBuild deletes an installed build directory when it is not active.

func (*Service) Rollback

func (s *Service) Rollback(ctx context.Context, panelID string) error

Rollback restores the retained previous build for panelID when present.

func (*Service) SetupPath

func (s *Service) SetupPath(gatewayHost string) string

SetupPath returns the default active panel's same-origin setup deep-link (under /__mihari/panels/{id}/).

func (*Service) SetupPathFor

func (s *Service) SetupPathFor(panelID, gatewayHost string) string

SetupPathFor returns a same-origin setup deep-link mounted at /__mihari/panels/{panelID}/.

func (*Service) Uninstall

func (s *Service) Uninstall(ctx context.Context, panelID string) error

Uninstall removes all installed builds for panelID and clears default/rollback pointers that referenced them. Other installed panels are left intact.

func (*Service) Update

func (s *Service) Update(ctx context.Context, panelID string) error

Update installs the latest build when it differs from the current installed build for panelID.

type ServiceOptions

type ServiceOptions struct {
	WebRoot    string
	WebActive  string
	StagingDir string
	Adapters   []Adapter
	HTTPClient *http.Client
	MaxBytes   int64
	AllowHTTP  bool
}

ServiceOptions configures panel install roots and adapters.

Directories

Path Synopsis
Package archive provides safe extraction helpers for panel distribution zips.
Package archive provides safe extraction helpers for panel distribution zips.
Package metacubexd implements the MetaCubeXD panel adapter.
Package metacubexd implements the MetaCubeXD panel adapter.
Package release provides small GitHub API helpers for panel distribution discovery.
Package release provides small GitHub API helpers for panel distribution discovery.
Package zashboard implements the Zashboard panel adapter.
Package zashboard implements the Zashboard panel adapter.

Jump to

Keyboard shortcuts

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