NervesGate.Network (nerves_gate v0.1.0)

Copy Markdown

Ethernet and Internet uplink configuration with protected trials and rollback.

Commands

propose/4 applies settings temporarily and returns {:ok, trial_id}. confirm/2 saves that trial; cancel/2 restores saved settings. Both return :ok after completion. Rejected or failed commands return {:error, reason}. Manual trials expire after 60 seconds. First setup through verified USB may auto-save within 15 seconds. A caller timeout does not cancel admitted work.

Queries and notifications

validate/1, ready?/2 and conflicts/2 are pure checks. status/1 reads the current trial, settings and interfaces. Subscribe with observe/1 before reading; notifications are hints to read again, not complete status maps.

The server argument defaults to this module. VintageNet owns saved settings. Failed restoration sets :network_restore_failed; successful restoration clears it.

Summary

Functions

Cancel the matching trial. Replies after saved settings have been restored.

Returns a specification to start this module under a supervisor.

Save the matching, unexpired trial after checking current readiness. Replies after saving.

List observed subnet conflicts for these settings without performing I/O.

Subscribe the caller to network workflow and adapter properties; read status afterward.

Apply a temporary trial and return its ID after application.

Check that observed topology/settings match the proposal, without subnet conflicts.

Read config, trial, observed interfaces, phase, readiness, recovery and the last error.

Validate and normalize string-keyed settings without reading or changing hardware.

Functions

cancel(id, server \\ __MODULE__)

@spec cancel(String.t(), GenServer.server()) :: :ok | {:error, term()}

Cancel the matching trial. Replies after saved settings have been restored.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

confirm(id, server \\ __MODULE__)

@spec confirm(String.t(), GenServer.server()) :: :ok | {:error, term()}

Save the matching, unexpired trial after checking current readiness. Replies after saving.

conflicts(observed, network)

@spec conflicts(map() | nil, map()) :: list()

List observed subnet conflicts for these settings without performing I/O.

observe(server \\ __MODULE__)

@spec observe(GenServer.server()) :: :ok | {:error, :unavailable}

Subscribe the caller to network workflow and adapter properties; read status afterward.

propose(network, server \\ __MODULE__, access \\ nil, expected \\ :any)

@spec propose(map(), GenServer.server(), map() | nil, map() | :any) ::
  {:ok, String.t()} | {:error, term()}

Apply a temporary trial and return its ID after application.

Immediately-ready first USB setup waits for auto-save before replying. If still settling, it returns a pending trial. access must come from trusted server observations of both socket endpoints, never user input; omit it for manual setup. Supply expected to reject a draft if the saved network settings have changed.

ready?(observed, network)

@spec ready?(map() | nil, map()) :: boolean()

Check that observed topology/settings match the proposal, without subnet conflicts.

status(server \\ __MODULE__)

@spec status(GenServer.server()) :: map()

Read config, trial, observed interfaces, phase, readiness, recovery and the last error.

validate(network)

@spec validate(map()) :: {:ok, map()} | {:error, term()}

Validate and normalize string-keyed settings without reading or changing hardware.