Network settings

What a Space can reach: its network preset, the allow and deny lists, and deleting a Space together with its children.

Spaces.network says what a Space can reach and where that is enforced, set_network changes it (a child Space stays within its parent's unless widened), and delete_tree deletes a Space with or without its children. See A Space's network.

Network#

Methods of Spaces.

Spaces.network#

A Space's network: its settings, what they open, where they are enforced (or why its network is cut), and what is always blocked.

async def network(self, space: str) -> SpaceNetworkInfo
ParameterTypeDefault
spaceStringrequired

Returns SpaceNetworkInfo · Async · Raises CuaError

Spaces.ack_network_notice#

Marks the one-time notice about the new network defaults as shown for space (SpaceNetworkInfo.notice_pending).

async def ack_network_notice(self, space: str) -> None
ParameterTypeDefault
spaceStringrequired

Async · Raises CuaError

Spaces.set_network#

Replaces a Space's network settings (see NetworkSettings). A child stays within its parent's unless widen; tree gives its children the same settings. They hold at once where the runtime can change a running guest's network, else from its next start (applied). A Space another computer runs is Unsupported.

async def set_network(self, space: str, settings: NetworkSettings, widen: bool, tree: bool) -> SetNetworkResult
ParameterTypeDefault
spaceStringrequired
settingsNetworkSettingsrequired
widenboolrequired
treeboolrequired

Returns SetNetworkResult · Async · Raises CuaError (Unsupported)

Spaces.delete_tree#

Spaces.delete, with keep_children: its child Spaces become top-level Spaces and keep running instead of being deleted first.

async def delete_tree(self, space: str, keep_children: bool) -> str
ParameterTypeDefault
spaceStringrequired
keep_childrenboolrequired

Returns String · Async · Raises CuaError

NetworkSettings record#

A Space's network settings: a preset and the user's own lists. The host the Space runs on compiles them to rules it enforces outside the guest.

  • internet (the default): the public internet and the Space's own tree; this computer, your local network, cloud metadata, other trees and the cua daemon are blocked;
  • none: no network;
  • localhost: internet, plus this computer's localhost on localhost_ports (every port only with all_localhost_ports);
  • lan: internet, plus your local network (not this computer);
  • localhost+lan: internet, plus both of the above (localhost and lan are independent extras; this is the one preset with both);
  • custom: custom_base (internet or none) plus allow and deny;
  • unprotected: everything but cloud metadata, other trees and the daemon.

A runtime that can't protect a Space yet starts it without network and says so (SpaceInfo.network_note); it never starts it open unless the preset is unprotected.

FieldTypeDefaultDescription
presetString""internet, none, localhost, lan, localhost+lan, custom or unprotected; empty is internet.
localhost_ports / localhostPortsVec<u16>[]localhost and localhost+lan: the ports of this computer's localhost the Space may reach.
all_localhost_ports / allLocalhostPortsboolfalselocalhost and localhost+lan: every port (the daemon's stay blocked).
allowVec<String>[]Destinations that stay reachable (addresses or CIDRs).
denyVec<String>[]Destinations that are blocked (addresses, CIDRs or all).
custom_base / customBaseString""custom: what it starts from, internet (empty) or none.
widened_by / widenedByOption<String>NoneSet when the Space was allowed more than its parent: who and when.
viaOption<String>NoneWhere its internet traffic leaves ("Exit through"): None or internet for its own network, this-computer (the hotspot), space:<name> (a Space of its tree) or socks5://host:port. A child keeps its parent's.

SpaceNetworkInfo record#

A Space's network as cua network show says it (Spaces.network).

Returned by Spaces.network.

FieldTypeDefaultDescription
settingsNetworkSettingsIts settings.
summaryStringOne plain line ("Internet only").
wideningsVec<String>What the settings open beyond internet, one plain line each.
enforcementStringenforced (rules on the host, outside the guest), no_network (its runtime can't protect it yet), open (No protection) or refused; empty when unknown (a Space another computer runs).
pointStringWhere the rules are enforced, or why its network is cut.
noteOption<String>Why its network is not what was asked; None otherwise.
parentOption<String>Its parent and its tree's top-level Space; None for a top-level Space.
rootOption<String>
always_blocked / alwaysBlockedVec<String>What no setting opens, in plain words.
notice_pending / noticePendingboolAn update changed its settings: say so once.
tree_address / treeAddressOption<String>NoneA VM's address in its tree (198.19.0.0/16), where the other members of its tree reach it; None for a container or a Space another computer runs.
topology_json / topologyJsonString""Its topology as JSON text (cua network show --json's topology): its name and address, its tree's members, the host and the ports it may reach there, its policy, its exit and the exit's state, and the path to the other computers of its tree. Empty from an older daemon.

SetNetworkResult record#

What Spaces.set_network did.

Returned by Spaces.set_network.

FieldTypeDefaultDescription
appliedStringnow (the running guest is under them) or next_start.
networkSpaceNetworkInfoThe Space's network after the change.