Documentation
¶
Index ¶
- Constants
- func InstallFromZip(request InstallRequest) (string, error)
- func LoadCredential(path string) (string, error)
- func LoadOrCreateCredential(path string) (string, error)
- func PanelBuildDir(webRoot, panelID, build string) string
- func ResolveFileRoot(buildDir string) string
- func SaveActive(path string, active Active) error
- func UIMount(panelID string) string
- type Active
- type Adapter
- type Entry
- type InstallRequest
- type PanelInfo
- type PreparedMutation
- type Service
- func (s *Service) Activate(ctx context.Context, panelID string) error
- func (s *Service) Active() (Active, error)
- func (s *Service) ActiveDir() (string, error)
- func (s *Service) Install(ctx context.Context, panelID, pinBuild string) error
- func (s *Service) List() []PanelInfo
- func (s *Service) PanelDir(panelID string) (string, error)
- func (s *Service) PrepareInstall(ctx context.Context, panelID, pinBuild string) (PreparedMutation, error)
- func (s *Service) PrepareReinstall(ctx context.Context, panelID string) (PreparedMutation, error)
- func (s *Service) PrepareUpdate(ctx context.Context, panelID string) (PreparedMutation, error)
- func (s *Service) Reinstall(ctx context.Context, panelID string) error
- func (s *Service) RemoveBuild(panelID, build string) error
- func (s *Service) Rollback(ctx context.Context, panelID string) error
- func (s *Service) SetupPath(gatewayHost string) string
- func (s *Service) SetupPathFor(panelID, gatewayHost string) string
- func (s *Service) Uninstall(ctx context.Context, panelID string) error
- func (s *Service) Update(ctx context.Context, panelID string) error
- type ServiceOptions
Constants ¶
const ( IDZashboard = "zashboard" IDMetaCubeXD = "metacubexd" )
Built-in panel identifiers.
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 ¶
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 ¶
LoadOrCreateCredential returns the existing Web credential or generates one once with 0600 permissions.
func PanelBuildDir ¶
PanelBuildDir returns web/{panelID}/{build}/ under webRoot.
func ResolveFileRoot ¶
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 ¶
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.
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 ¶
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 ¶
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.
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
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 ¶
Activate sets active.json to the newest complete installed build for panelID.
func (*Service) ActiveDir ¶
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 ¶
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) PanelDir ¶
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
PrepareReinstall downloads and validates a replacement without deleting the installed tree.
func (*Service) PrepareUpdate ¶ added in v0.4.1
PrepareUpdate downloads and validates the latest build without changing the installed tree.
func (*Service) Reinstall ¶
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 ¶
RemoveBuild deletes an installed build directory when it is not active.
func (*Service) SetupPath ¶
SetupPath returns the default active panel's same-origin setup deep-link (under /__mihari/panels/{id}/).
func (*Service) SetupPathFor ¶
SetupPathFor returns a same-origin setup deep-link mounted at /__mihari/panels/{panelID}/.
Source Files
¶
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. |