Documentation
¶
Index ¶
- type AddSubscriptionInput
- type Controller
- type CoreInstaller
- type CoreSupervisor
- type GeoIPCandidate
- type GeoIPService
- type LoggingRuntime
- type LoggingUpdate
- 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(ctx context.Context) (geoip.Status, error)
- func (m *Manager) GetInstallationStatus(ctx context.Context) (protocol.InstallationStatus, 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) LoggingStatus(ctx context.Context) (protocol.LoggingStatus, 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) ProxyCatalog(ctx context.Context) (mihomo.Proxies, []string, error)
- func (m *Manager) RefreshProvider(ctx context.Context, operation Operation, name string) 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) RestoreRouting(ctx context.Context) error
- func (m *Manager) RollbackPanel(ctx context.Context, operation Operation, panelID string) error
- func (m *Manager) RoutingProxyCatalog(ctx context.Context) (mihomo.Proxies, []string, uint64, string, error)
- func (m *Manager) RoutingStatus(ctx context.Context) (protocol.RoutingStatus, 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) SetupRequired(ctx context.Context) (bool, 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) UpdateLogging(ctx context.Context, operation Operation, update LoggingUpdate) (protocol.LoggingStatus, 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) UpdateRouting(ctx context.Context, op Operation, mode string) (protocol.RoutingStatus, 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(ctx 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 LoggingRuntime ¶ added in v0.9.2
type LoggingRuntime interface {
Apply(context.Context, logging.Config)
Config() logging.Config
Dir() string
}
LoggingRuntime is the daemon-owned file logging configuration boundary.
type LoggingUpdate ¶ added in v0.9.2
LoggingUpdate is a partial file logging configuration mutation.
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) GetInstallationStatus ¶ added in v0.9.3
GetInstallationStatus reports installation observations without a mutation path.
func (*Manager) InstallPanel ¶
func (m *Manager) InstallPanel(ctx context.Context, operation Operation, panelID, pinBuild string) error
InstallPanel prepares a validated build outside the commit section, then installs and 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) LoggingStatus ¶ added in v0.9.2
LoggingStatus returns the complete effective file logging configuration.
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) ProxyCatalog ¶ added in v0.9.4
ProxyCatalog returns complete display metadata and duplicate names. The raw global namespace remains available separately through Proxies for routing.
func (*Manager) RefreshProvider ¶ added in v0.9.3
RefreshProvider delegates native provider refresh to mihomo through the mutation coordinator.
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) RestoreRouting ¶ added in v0.9.4
RestoreRouting reconciles persisted intent before the supervisor reports a healthy core. The supervisor owns its context and retries; no UI is required.
func (*Manager) RollbackPanel ¶
RollbackPanel restores the retained previous build under the mutation lock.
func (*Manager) RoutingProxyCatalog ¶ added in v0.9.4
func (m *Manager) RoutingProxyCatalog(ctx context.Context) (mihomo.Proxies, []string, uint64, string, error)
RoutingProxyCatalog binds complete display metadata and duplicate names to the candidate list's mutation revision and subscription.
func (*Manager) RoutingStatus ¶ added in v0.9.4
RoutingStatus returns saved routing intent and live kernel observation.
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) SetupRequired ¶ added in v0.9.4
SetupRequired derives required setup from effective runtime resources. Optional subscriptions/GeoIP and the historical welcome marker do not force onboarding.
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) UpdateLogging ¶ added in v0.9.2
func (m *Manager) UpdateLogging(ctx context.Context, operation Operation, update LoggingUpdate) (protocol.LoggingStatus, error)
UpdateLogging atomically persists and applies a partial file logging update.
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) UpdateRouting ¶ added in v0.9.4
func (m *Manager) UpdateRouting(ctx context.Context, op Operation, mode string) (protocol.RoutingStatus, error)
UpdateRouting persists and applies a routing mode without closing connections.
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 {
TrustedCore *core.TrustedExecution
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
// Logging applies daemon-owned file logging settings at runtime.
Logging LoggingRuntime
// RefreshLogSecrets replaces the exact subscription URL redaction snapshot.
RefreshLogSecrets func(catalogURLs []string)
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
// LookupTCPOccupant reports the PID listening on a host:port. Nil installs
// platform.LookupTCPOccupant. Tests inject a fake to avoid real socket tables.
LookupTCPOccupant func(string) (int, bool)
// SettingsPath is where config.Save writes settings after system-proxy (and related) mutations.
// Empty skips persistence (in-memory settings only).
SettingsPath string
// SaveSettings persists an independently prepared settings candidate.
// Nil uses config.SaveWithCommit.
SaveSettings func(string, config.Settings) (config.CommitResult, error)
// DiagnosticReporter records internal diagnostics for actual operation execution.
DiagnosticReporter diagnostics.Reporter
// 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)
// InstallationStatus is a read-only app inspector; nil reports unknown.
InstallationStatus func(context.Context) (protocol.InstallationStatus, 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)
// ValidationMode is the no-business install-validation daemon. It refuses
// mutation, background refresh, and core start.
ValidationMode bool
// ActivationPhase is the durable install journal phase. Empty means no Unix
// install journal (Windows / non-root private / already complete).
ActivationPhase string
}
type PanelService ¶
type PanelService interface {
List() []panel.PanelInfo
Active() (panel.Active, error)
ActiveDir() (string, error)
PanelDir(panelID string) (string, error)
PrepareInstall(ctx context.Context, panelID, pinBuild string) (panel.PreparedMutation, 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