State Machine
Service state machine
The finite state machine is implemented in the IPProtectionService class
and the states are defined in the IPProtectionStates object.
Service states
The service transitions across the following states:
UNINITIALIZED: Service not initialized or feature disabled.UNAVAILABLE: User not eligible (Nimbus) or signed out with no eligibility; UI hidden.UNAUTHENTICATED: User signed out but eligible; UI shows login.READY: Ready to activate the proxy.
High‑level transitions
Feature disabled →
UNINITIALIZED.During startup, if initialization isn’t complete, use cached state from
IPPStartupCache.Not signed in →
UNAVAILABLEif not eligible, otherwiseUNAUTHENTICATED.If an entitlement is cached/valid →
READY.Otherwise, check enrollment with Guardian (via
IPPEnrollAndEntitleManager): - Not enrolled →UNAVAILABLE(not eligible). - Enrolled → fetch entitlement; if successful →READY, elseUNAVAILABLEwhen not eligible.
Events and integration points
IPProtectionService:StateChangedis dispatched on state changes withdetail.stateanddetail.prevState.Helpers can call
IPProtectionService.updateState()to recompute the state immediately; update any helper-owned data first because the call is synchronous.Public actions:
start(userAction),stop(userAction), andstartLoginFlow(browser).
Proxy manager state machine
The IPPProxyManager layers a proxy‑specific finite state machine on top of
IPProtectionService. It mirrors eligibility changes from the service and
drives the lifecycle of the proxy connection.
Proxy states
NOT_READY: Service is notREADY. Channel filters are torn down and UI should not offer activation.READY: Service isREADYand the proxy can be activated.ACTIVATING:start()is creating a channel filter, fetching a proxy pass, and selecting an endpoint.ACTIVE: Proxy connected. Usage and network observers are reporting metrics.ERROR: A recoverable error occurred while activating or rotating credentials. Errors are kept in a bounded history.
Proxy transitions
IPProtectionService:StateChanged→IPPProxyManager.updateState(): - ServiceREADY→ proxyREADY(resets connection/error history). - Any other service state → proxyNOT_READY(stops active connections).start(userAction)fromREADYmoves toACTIVATING. - Successful activation →ACTIVEand telemetryipprotection.toggled. - Failures (missing entitlement, server list, proxy pass…) →ERRORvia#setErrorState.stop(userAction)fromACTIVE→READYafter closing the channel filter and observers.reset()or helper‑driven recomputations callupdateState()which demotes the proxy back toREADY/NOT_READYand clears the credential cache.Network errors (
proxy-http-errorwith 401) trigger Proxy Pass rotation while stayingACTIVE; repeated failures bubble up through#setErrorState.
Proxy events and hooks
IPPProxyManager:StateChangedis dispatched withdetail.statewhenever the proxy state machine moves.IPPProxyManagerlistens toIPProtectionService:StateChangedand toproxy-http-errorfromIPPNetworkErrorObserver.Consumers can observe
IPPProxyManager.state(or listen for events) to synchronize UI/telemetry with the proxy lifecycle.