Documentation
¶
Index ¶
- type AddSubscriptionInput
- type Controller
- type CoreInstaller
- type CoreSupervisor
- type GeoIPCandidate
- type GeoIPService
- type Manager
- func (m *Manager) ActivatePanel(ctx context.Context, operation Operation, panelID string) error
- func (m *Manager) ActivePanel(context.Context) (panel.Active, error)
- func (m *Manager) AddSubscription(ctx context.Context, operation Operation, input AddSubscriptionInput) (subscription.PublicProfile, error)
- func (m *Manager) ApplyDesiredSystemProxy(ctx context.Context) error
- func (m *Manager) BrowserSessions() int
- func (m *Manager) Capabilities() []string
- func (m *Manager) ClearOwnedSystemProxy(ctx context.Context) error
- func (m *Manager) CloseAllConnections(ctx context.Context, operation Operation) error
- func (m *Manager) CloseConnection(ctx context.Context, operation Operation, id string) error
- func (m *Manager) Connections(ctx context.Context) (mihomo.Connections, error)
- func (m *Manager) DelayGroup(ctx context.Context, group, testURL string, timeoutMilliseconds int) (mihomo.Delays, error)
- func (m *Manager) DelayProxy(ctx context.Context, name, testURL string, timeoutMilliseconds int) (uint16, error)
- func (m *Manager) DisableSystemProxy(ctx context.Context, op Operation) (protocol.SystemProxyStatus, error)
- func (m *Manager) DisableTun(ctx context.Context, op Operation) (protocol.TunStatus, error)
- func (m *Manager) EnableSystemProxy(ctx context.Context, op Operation, force bool) (protocol.SystemProxyStatus, error)
- func (m *Manager) EnableTun(ctx context.Context, op Operation, force bool) (protocol.TunStatus, error)
- func (m *Manager) GeoIPStatus(context.Context) (geoip.Status, error)
- func (m *Manager) Install(ctx context.Context, operation Operation) (core.InstallResult, error)
- func (m *Manager) InstallPanel(ctx context.Context, operation Operation, panelID, pinBuild string) error
- func (m *Manager) ListPanels(context.Context) ([]panel.PanelInfo, error)
- func (m *Manager) LocalCore(ctx context.Context) (core.LocalCoreInfo, error)
- func (m *Manager) LookupGeoIP(_ context.Context, addresses []netip.Addr) ([]geoip.Record, error)
- func (m *Manager) Observe(observation supervisor.Observation)
- func (m *Manager) OnboardingStatus(ctx context.Context) (onboarding.Snapshot, error)
- func (m *Manager) OpenWebGUI(_ context.Context, panelID string) (string, string, error)
- func (m *Manager) Panels(context.Context) ([]panel.PanelInfo, error)
- func (m *Manager) Proxies(ctx context.Context) (mihomo.Proxies, error)
- func (m *Manager) RefreshSubscription(ctx context.Context, operation Operation, id string) (subscription.PublicProfile, error)
- func (m *Manager) ReinstallPanel(ctx context.Context, operation Operation, panelID string) error
- func (m *Manager) RemoveSubscription(ctx context.Context, operation Operation, id string) error
- func (m *Manager) Restart(ctx context.Context, operation Operation) error
- func (m *Manager) RollbackPanel(ctx context.Context, operation Operation, panelID string) error
- func (m *Manager) RuleProviders(ctx context.Context) (mihomo.RuleProviders, error)
- func (m *Manager) Rules(ctx context.Context) (mihomo.Rules, error)
- func (m *Manager) Run(ctx context.Context) error
- func (m *Manager) SelectProxy(ctx context.Context, operation Operation, group, name string) error
- func (m *Manager) ServiceStatus(context.Context) (protocol.ServiceStatus, error)
- func (m *Manager) SetSubscription(ctx context.Context, operation Operation, id string, ...) (subscription.PublicProfile, error)
- func (m *Manager) SetSubscriptionEnabled(ctx context.Context, operation Operation, id string, enabled bool) (subscription.PublicProfile, error)
- func (m *Manager) Snapshot() state.Snapshot
- func (m *Manager) Stream(ctx context.Context, kind mihomo.StreamKind, ...) error
- func (m *Manager) Subscriptions() subscription.PublicCatalog
- func (m *Manager) SystemProxyStatus(ctx context.Context) (protocol.SystemProxyStatus, error)
- func (m *Manager) TUIPreferences() preferences.Preferences
- func (m *Manager) TunStatus(ctx context.Context) (protocol.TunStatus, error)
- func (m *Manager) UninstallPanel(ctx context.Context, operation Operation, panelID string) error
- func (m *Manager) UpdateGeoIP(ctx context.Context, operation Operation) (geoip.Status, error)
- func (m *Manager) UpdateOnboarding(ctx context.Context, operation Operation, update onboarding.Update) (onboarding.Snapshot, error)
- func (m *Manager) UpdatePanel(ctx context.Context, operation Operation, panelID string) error
- func (m *Manager) UpdateRuleProvider(ctx context.Context, operation Operation, name string) error
- func (m *Manager) UpdateTUIPreferences(ctx context.Context, operation Operation, update preferences.Update) (preferences.Preferences, error)
- func (m *Manager) UseSubscription(ctx context.Context, operation Operation, id string) (subscription.PublicProfile, error)
- func (m *Manager) WebGUIStatus(context.Context) (protocol.WebGUIStatus, error)
- func (m *Manager) WebListenAddr() string
- type Operation
- type Options
- type PanelService
- type PreparedCore
- type SetSubscriptionInput
- type WebGateway
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddSubscriptionInput ¶
type Controller ¶
type Controller interface {
Proxies(context.Context) (mihomo.Proxies, error)
SelectProxy(context.Context, string, string) error
DelayGroup(context.Context, string, string, int) (mihomo.Delays, error)
DelayProxy(context.Context, string, string, int) (uint16, error)
Connections(context.Context) (mihomo.Connections, error)
CloseConnection(context.Context, string) error
CloseAllConnections(context.Context) error
Rules(context.Context) (mihomo.Rules, error)
RuleProviders(context.Context) (mihomo.RuleProviders, error)
UpdateRuleProvider(context.Context, string) error
Configs(context.Context) (map[string]any, error)
PatchConfigs(context.Context, map[string]any) error
Stream(context.Context, mihomo.StreamKind, func(json.RawMessage) error) error
}
type CoreInstaller ¶
type CoreSupervisor ¶
type GeoIPCandidate ¶
GeoIPCandidate is the minimal prepared-pair contract used by the mutation coordinator.
type GeoIPService ¶
GeoIPService is the local lookup and health boundary used by the runtime.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) ActivatePanel ¶
ActivatePanel switches the active panel pointer under the mutation lock.
func (*Manager) ActivePanel ¶
ActivePanel returns the active panel pointer without secrets.
func (*Manager) AddSubscription ¶
func (m *Manager) AddSubscription(ctx context.Context, operation Operation, input AddSubscriptionInput) (subscription.PublicProfile, error)
func (*Manager) ApplyDesiredSystemProxy ¶
ApplyDesiredSystemProxy best-effort enables the OS proxy when settings desire it. Intended for daemon startup; failures are returned but callers may ignore them.
func (*Manager) BrowserSessions ¶
BrowserSessions returns the approximate concurrent authenticated Web gateway sessions.
func (*Manager) Capabilities ¶
func (*Manager) ClearOwnedSystemProxy ¶
ClearOwnedSystemProxy best-effort disables the OS proxy when Mihari owns it. Intended for graceful daemon shutdown; failures are returned but callers may ignore them.
func (*Manager) CloseAllConnections ¶
func (*Manager) CloseConnection ¶
func (*Manager) Connections ¶
func (*Manager) DelayGroup ¶
func (*Manager) DelayProxy ¶
func (*Manager) DisableSystemProxy ¶
func (m *Manager) DisableSystemProxy(ctx context.Context, op Operation) (protocol.SystemProxyStatus, error)
DisableSystemProxy clears Mihari-owned system proxy (policy i). Foreign proxies are refused without OS write or desired-state change.
func (*Manager) DisableTun ¶
DisableTun persists managed TUN enable=false (block stays non-empty so subscription tun stays overridden).
func (*Manager) EnableSystemProxy ¶
func (m *Manager) EnableSystemProxy(ctx context.Context, op Operation, force bool) (protocol.SystemProxyStatus, error)
EnableSystemProxy turns on the OS system proxy for the mixed endpoint. When a foreign proxy is active, force must be true to overwrite it.
func (*Manager) EnableTun ¶
func (m *Manager) EnableTun(ctx context.Context, op Operation, force bool) (protocol.TunStatus, error)
EnableTun persists managed TUN enable=true and applies it to the running core. When other TUN adapters are detected (routing conflict or loop risk), force must be true to proceed. Disable is never gated (see mutateTun).
func (*Manager) GeoIPStatus ¶
GeoIPStatus returns the current redacted database health.
func (*Manager) InstallPanel ¶
func (m *Manager) InstallPanel(ctx context.Context, operation Operation, panelID, pinBuild string) error
InstallPanel downloads and installs outside the commit section, then bumps revision.
func (*Manager) ListPanels ¶
ListPanels returns redacted panel install state.
func (*Manager) LocalCore ¶ added in v0.4.0
LocalCore reports whether the configured core binary already satisfies setup locally (mihomo -v succeeds), so onboarding can hint "use existing" without a network install. Read-only: no lock, no store mutation. Mirrors the Install setup fast-path predicate (design §4.3), DRY — same DetectVersion judgment.
func (*Manager) LookupGeoIP ¶
LookupGeoIP resolves a bounded batch from daemon-owned local databases.
func (*Manager) Observe ¶
func (m *Manager) Observe(observation supervisor.Observation)
func (*Manager) OnboardingStatus ¶
func (*Manager) OpenWebGUI ¶
OpenWebGUI returns a one-shot local open URL that includes the Web access token. panelID selects which installed panel to open; empty uses the default active panel. Callers must not log or persist the result beyond immediately launching a browser.
func (*Manager) RefreshSubscription ¶
func (m *Manager) RefreshSubscription(ctx context.Context, operation Operation, id string) (subscription.PublicProfile, error)
func (*Manager) ReinstallPanel ¶
ReinstallPanel uninstalls then reinstalls outside/inside commit as needed, then bumps revision. Download runs outside the commit section after uninstall clears local state.
func (*Manager) RemoveSubscription ¶
func (*Manager) RollbackPanel ¶
RollbackPanel restores the retained previous build under the mutation lock.
func (*Manager) RuleProviders ¶
func (*Manager) SelectProxy ¶
func (*Manager) ServiceStatus ¶ added in v0.4.0
ServiceStatus reports the OS service registration state for onboarding review. Advisory: a nil injector or any error resolves to "unknown" and never fails, so the endpoint stays 200 and onboarding is never blocked (design §5.3, §8).
func (*Manager) SetSubscription ¶
func (m *Manager) SetSubscription(ctx context.Context, operation Operation, id string, input SetSubscriptionInput) (subscription.PublicProfile, error)
func (*Manager) SetSubscriptionEnabled ¶
func (m *Manager) SetSubscriptionEnabled(ctx context.Context, operation Operation, id string, enabled bool) (subscription.PublicProfile, error)
func (*Manager) Stream ¶
func (m *Manager) Stream(ctx context.Context, kind mihomo.StreamKind, receive func(json.RawMessage) error) error
func (*Manager) Subscriptions ¶
func (m *Manager) Subscriptions() subscription.PublicCatalog
func (*Manager) SystemProxyStatus ¶
SystemProxyStatus returns desired intent plus live OS observation.
func (*Manager) TUIPreferences ¶
func (m *Manager) TUIPreferences() preferences.Preferences
func (*Manager) TunStatus ¶
TunStatus returns desired managed TUN intent plus live observation from mihomo when available.
func (*Manager) UninstallPanel ¶
UninstallPanel removes all local builds for a panel under the mutation lock.
func (*Manager) UpdateGeoIP ¶
UpdateGeoIP prepares outside the mutation gate and commits under revision control.
func (*Manager) UpdateOnboarding ¶
func (m *Manager) UpdateOnboarding(ctx context.Context, operation Operation, update onboarding.Update) (onboarding.Snapshot, error)
func (*Manager) UpdatePanel ¶
UpdatePanel installs a newer build when available, then bumps revision.
func (*Manager) UpdateRuleProvider ¶
func (*Manager) UpdateTUIPreferences ¶
func (m *Manager) UpdateTUIPreferences(ctx context.Context, operation Operation, update preferences.Update) (preferences.Preferences, error)
func (*Manager) UseSubscription ¶
func (m *Manager) UseSubscription(ctx context.Context, operation Operation, id string) (subscription.PublicProfile, error)
func (*Manager) WebGUIStatus ¶
WebGUIStatus returns a secret-free gateway and panel status for local clients.
func (*Manager) WebListenAddr ¶
WebListenAddr returns the bound Web gateway address when available.
type Options ¶
type Options struct {
Store *state.Store
Coordinator *state.Coordinator
Installer CoreInstaller
InstallRequest core.InstallRequest
Supervisor CoreSupervisor
Controller Controller
BinaryExists func() bool
Subscriptions *subscription.Service
Preferences *preferences.Service
Settings config.Settings
RuntimeConfig string
StagingDir string
ValidateConfig func(context.Context, string) error
RunScheduler func(context.Context) error
GeoIP GeoIPService
PrepareGeoIP func(context.Context) (GeoIPCandidate, error)
Onboarding *onboarding.Service
Panels PanelService
// WebGateway is the optional loopback browser gateway. Failures do not stop the core supervisor.
WebGateway WebGateway
// WebOpenToken is the Web access credential used only to mint open-browser URLs for local clients.
// It must never appear in status DTOs, logs, or default CLI output.
WebOpenToken string
// SysProxy is the OS system-proxy backend. Nil installs the platform default in New.
SysProxy sysproxy.Backend
// TunDetect is the TUN conflict detection backend. Nil installs the platform default in New.
TunDetect tundetect.Backend
// SettingsPath is where config.Save writes settings after system-proxy (and related) mutations.
// Empty skips persistence (in-memory settings only).
SettingsPath string
// ServiceStatus reports the OS service registration state for onboarding review.
// Optional; nil reports "unknown". Injected as a func (not *service.Manager) to keep
// runtime free of the service package and break the main↔daemon assembly cycle.
ServiceStatus func() (string, error)
// OnBackgroundError receives non-cancellation failures from the web gateway
// and owned scheduler. Optional; nil keeps the previous discard behavior.
OnBackgroundError func(component string, err error)
}
type PanelService ¶
type PanelService interface {
List() []panel.PanelInfo
Active() (panel.Active, error)
ActiveDir() (string, error)
PanelDir(panelID string) (string, error)
Install(ctx context.Context, panelID, pinBuild string) error
PrepareUpdate(ctx context.Context, panelID string) (panel.PreparedMutation, error)
Activate(ctx context.Context, panelID string) error
Rollback(ctx context.Context, panelID string) error
Uninstall(ctx context.Context, panelID string) error
PrepareReinstall(ctx context.Context, panelID string) (panel.PreparedMutation, error)
SetupPath(gatewayHost string) string
SetupPathFor(panelID, gatewayHost string) string
}
PanelService is the daemon-owned panel lifecycle boundary used by the mutation coordinator.
type PreparedCore ¶
type PreparedCore = core.PreparedCore