Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

feat(spaces): Network picker with an "Also allow" list (localhost and local network are siblings) (#6610)

ddupontdff4d01d8e4f
diff --git a/apps/cua-spaces-desktop/src/model/backend.ts b/apps/cua-spaces-desktop/src/model/backend.ts
index b34f6d205f..aed2265d12 100644
--- a/apps/cua-spaces-desktop/src/model/backend.ts
+++ b/apps/cua-spaces-desktop/src/model/backend.ts
@@ -1170,14 +1170,15 @@ export function createExtrasOf(config: Record<string, unknown>): CreateExtras {
}
/** The SDK's `NetworkSettings` for a preset word (`internet`, `none`,
- * `localhost:5432,3000`, `localhost:all`, `lan`, `custom`, `custom:none`,
- * `unprotected`) and lists. `via`: where its internet traffic leaves
+ * `localhost:5432,3000`, `localhost:all`, `lan`, `localhost+lan:5432,3000`, `custom`,
+ * `custom:none`, `unprotected`) and lists. `via`: where its internet traffic leaves
* (`internet`, `this-machine`, `space:<id>`, `socks5://...`); left out:
* the exit it has. */
export function networkSettingsOf(word: string, allow: string[], deny: string[], via?: string) {
const [preset, rest = ""] = word.trim().toLowerCase().split(":", 2) as [string, string?];
- const all = preset === "localhost" && rest === "all";
- const ports = preset === "localhost" && !all ? rest.split(",").map((p) => Number(p.trim())).filter((p) => Number.isInteger(p) && p > 0 && p < 65536) : [];
+ const opensLocalhost = preset === "localhost" || preset === "localhost+lan";
+ const all = opensLocalhost && rest === "all";
+ const ports = opensLocalhost && !all ? rest.split(",").map((p) => Number(p.trim())).filter((p) => Number.isInteger(p) && p > 0 && p < 65536) : [];
return {
preset,
localhostPorts: ports,
diff --git a/apps/cua-spaces-desktop/src/native/generated/cua_sdk.ts b/apps/cua-spaces-desktop/src/native/generated/cua_sdk.ts
index da9160ccf0..39bf6d9b50 100644
--- a/apps/cua-spaces-desktop/src/native/generated/cua_sdk.ts
+++ b/apps/cua-spaces-desktop/src/native/generated/cua_sdk.ts
@@ -14138,6 +14138,8 @@ const FfiConverterTypeNetworkEvent = (() => {
* - `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.
@@ -14148,17 +14150,18 @@ const FfiConverterTypeNetworkEvent = (() => {
*/
export type NetworkSettings = {
/**
- * `internet`, `none`, `localhost`, `lan`, `custom` or `unprotected`;
- * empty is `internet`.
+ * `internet`, `none`, `localhost`, `lan`, `localhost+lan`, `custom` or
+ * `unprotected`; empty is `internet`.
*/
preset: string,
/**
- * `localhost`: the ports of this computer's localhost the Space may
- * reach.
+ * `localhost` and `localhost+lan`: the ports of this computer's
+ * localhost the Space may reach.
*/
localhostPorts: Array<number>,
/**
- * `localhost`: every port (the daemon's stay blocked).
+ * `localhost` and `localhost+lan`: every port (the daemon's stay
+ * blocked).
*/
allLocalhostPorts: boolean,
/**
diff --git a/apps/cua-spaces-desktop/test/network.test.ts b/apps/cua-spaces-desktop/test/network.test.ts
index 814aa59d2f..85a7c4a279 100644
--- a/apps/cua-spaces-desktop/test/network.test.ts
+++ b/apps/cua-spaces-desktop/test/network.test.ts
@@ -44,6 +44,8 @@ describe("network.*", () => {
it("reads the words of a preset", () => {
expect(networkSettingsOf("internet", [], [])).toMatchObject({ preset: "internet", localhostPorts: [], allLocalhostPorts: false });
expect(networkSettingsOf("localhost:all", [], [])).toMatchObject({ preset: "localhost", allLocalhostPorts: true });
+ expect(networkSettingsOf("localhost+lan:5432,3000", [], [])).toMatchObject({ preset: "localhost+lan", localhostPorts: [5432, 3000], allLocalhostPorts: false });
+ expect(networkSettingsOf("localhost+lan:all", [], [])).toMatchObject({ preset: "localhost+lan", localhostPorts: [], allLocalhostPorts: true });
expect(networkSettingsOf("custom:none", ["github.com"], ["10.0.0.0/8"])).toMatchObject({ customBase: "none", allow: ["github.com"], deny: ["10.0.0.0/8"] });
expect(networkSettingsOf("localhost:99999,abc,22", [], []).localhostPorts).toEqual([22]);
});
diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift
index eea93f5939..aa7c7d75c6 100644
--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift
+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift
@@ -913,16 +913,17 @@ public final class LiveSpacesBackend: SpacesBackend, @unchecked Sendable {
}
/// The SDK's `NetworkSettings` for a preset word (`internet`, `none`,
- /// `localhost:5432,3000`, `localhost:all`, `lan`, `custom`, `custom:none`,
- /// `unprotected`) and lists.
+ /// `localhost:5432,3000`, `localhost:all`, `lan`, `localhost+lan:5432,3000`,
+ /// `custom`, `custom:none`, `unprotected`) and lists.
/// `via`: where its internet traffic leaves (`internet`, `this-machine`,
/// `space:<id>`, `socks5://...`); nil keeps the exit it has.
static func networkSettings(word: String, allow: [String], deny: [String], via: String? = nil) -> CuaSDK.NetworkSettings {
let parts = word.trimmingCharacters(in: .whitespaces).lowercased().split(separator: ":", maxSplits: 1).map(String.init)
let preset = parts.first ?? "internet"
let rest = parts.count > 1 ? parts[1] : ""
- let all = preset == "localhost" && rest == "all"
- let ports: [UInt16] = preset == "localhost" && !all
+ let opensLocalhost = preset == "localhost" || preset == "localhost+lan"
+ let all = opensLocalhost && rest == "all"
+ let ports: [UInt16] = opensLocalhost && !all
? rest.split(separator: ",").compactMap { UInt16($0.trimmingCharacters(in: .whitespaces)) }.filter { $0 > 0 }
: []
return CuaSDK.NetworkSettings(
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SecureNetworkTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SecureNetworkTests.swift
index a5636ed897..a4a3ab212f 100644
--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SecureNetworkTests.swift
+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SecureNetworkTests.swift
@@ -32,6 +32,10 @@ struct SecureNetworkTests {
#expect(all.preset == "localhost" && all.allLocalhostPorts)
let ports = LiveSpacesBackend.networkSettings(word: "localhost:5432, 3000", allow: [], deny: [])
#expect(ports.localhostPorts == [5432, 3000] && !ports.allLocalhostPorts)
+ let both = LiveSpacesBackend.networkSettings(word: "localhost+lan:5432, 3000", allow: [], deny: [])
+ #expect(both.preset == "localhost+lan" && both.localhostPorts == [5432, 3000] && !both.allLocalhostPorts)
+ let bothAll = LiveSpacesBackend.networkSettings(word: "localhost+lan:all", allow: [], deny: [])
+ #expect(bothAll.preset == "localhost+lan" && bothAll.localhostPorts.isEmpty && bothAll.allLocalhostPorts)
let custom = LiveSpacesBackend.networkSettings(word: "custom:none", allow: ["github.com"], deny: ["10.0.0.0/8"], via: "this-machine")
#expect(custom.customBase == "none" && custom.allow == ["github.com"] && custom.deny == ["10.0.0.0/8"] && custom.via == "this-machine")
}
diff --git a/apps/cua-spaces-web/src/bridge/__tests__/secure-spaces-flag.test.tsx b/apps/cua-spaces-web/src/bridge/__tests__/secure-spaces-flag.test.tsx
index 032ba7a992..ed907a216f 100644
--- a/apps/cua-spaces-web/src/bridge/__tests__/secure-spaces-flag.test.tsx
+++ b/apps/cua-spaces-web/src/bridge/__tests__/secure-spaces-flag.test.tsx
@@ -98,7 +98,7 @@ describe("Secure Spaces (Labs) on", () => {
));
await waitFor(() => expect(document.querySelector("[data-security-rows]")).not.toBeNull());
expect(document.querySelectorAll("[data-network-row]").length).toBe(2);
- expect(document.querySelector("[data-network-row]")?.textContent).toContain("This computer's localhost");
+ expect(document.querySelector("[data-network-row]")?.textContent).toContain("Internet and this computer's services");
});
it("opens the Network sheet from the row", async () => {
diff --git a/apps/cua-spaces-web/src/bridge/adapters/demo/network.ts b/apps/cua-spaces-web/src/bridge/adapters/demo/network.ts
index d054afb13b..cf3a5b37b8 100644
--- a/apps/cua-spaces-web/src/bridge/adapters/demo/network.ts
+++ b/apps/cua-spaces-web/src/bridge/adapters/demo/network.ts
@@ -144,14 +144,14 @@ export function createDemoNetwork({ now, flags }: { now: () => number; flags: Se
const s = security.get(spaceId);
if (!s) return;
const self = spaceNameOf(spaceId);
- security.set(spaceId, { ...s, network: { ...network, inheritedFrom: undefined }, topology: demoTopology(self, network.via, false, network.preset === "localhost", remote) });
+ security.set(spaceId, { ...s, network: { ...network, inheritedFrom: undefined }, topology: demoTopology(self, network.via, false, (network.preset === "localhost" || network.preset === "localhost+lan"), remote) });
// Children follow a parent's change (its exit too).
for (const [id, child] of security) {
if (child.parent?.id === spaceId) {
security.set(id, {
...child,
network: { ...network, inheritedFrom: s.parent ? undefined : self },
- topology: demoTopology(spaceNameOf(id), network.via, false, network.preset === "localhost", remote),
+ topology: demoTopology(spaceNameOf(id), network.via, false, (network.preset === "localhost" || network.preset === "localhost+lan"), remote),
});
}
}
diff --git a/apps/cua-spaces-web/src/bridge/contracts/network.ts b/apps/cua-spaces-web/src/bridge/contracts/network.ts
index 76ca08182f..cd60964bc8 100644
--- a/apps/cua-spaces-web/src/bridge/contracts/network.ts
+++ b/apps/cua-spaces-web/src/bridge/contracts/network.ts
@@ -8,8 +8,11 @@
* (`?demo=network`).
*/
-/** What a Space may reach. `internet` is the default. */
-export type NetworkPreset = "internet" | "none" | "localhost" | "lan" | "custom";
+/**
+ * What a Space may reach. `internet` is the default. `localhost` and `lan` are each
+ * Internet only plus one extra; `localhost+lan` has both.
+ */
+export type NetworkPreset = "internet" | "none" | "localhost" | "lan" | "localhost+lan" | "custom";
export interface SpaceNetwork {
preset: NetworkPreset;
diff --git a/apps/cua-spaces-web/src/bridge/network.ts b/apps/cua-spaces-web/src/bridge/network.ts
index e3238375f6..355ebdbc9b 100644
--- a/apps/cua-spaces-web/src/bridge/network.ts
+++ b/apps/cua-spaces-web/src/bridge/network.ts
@@ -52,7 +52,7 @@ export function reasonWords(reason: string): string {
/** The page's network settings from the host's answer. */
export function networkFromWire(w: SpaceNetworkWire, parentName?: string): SpaceNetwork {
- const preset = (["internet", "none", "localhost", "lan", "custom"] as const).includes(w.preset as NetworkPreset)
+ const preset = (["internet", "none", "localhost", "lan", "localhost+lan", "custom"] as const).includes(w.preset as NetworkPreset)
? (w.preset as NetworkPreset)
: "internet";
return {
@@ -117,7 +117,8 @@ export function topologyFromJson(text: string | undefined): SpaceTopology | unde
export function networkWord(n: SpaceNetwork): string {
switch (n.preset) {
case "localhost":
- return n.localhostPorts && n.localhostPorts.length > 0 ? `localhost:${n.localhostPorts.join(",")}` : "localhost:all";
+ case "localhost+lan":
+ return n.localhostPorts && n.localhostPorts.length > 0 ? `${n.preset}:${n.localhostPorts.join(",")}` : `${n.preset}:all`;
case "custom":
return n.base === "none" ? "custom:none" : "custom";
default:
diff --git a/apps/cua-spaces-web/src/bridge/new-space-hooks.ts b/apps/cua-spaces-web/src/bridge/new-space-hooks.ts
index bc00bd3eff..99184a5243 100644
--- a/apps/cua-spaces-web/src/bridge/new-space-hooks.ts
+++ b/apps/cua-spaces-web/src/bridge/new-space-hooks.ts
@@ -131,7 +131,7 @@ export function useNewSpaceWizard(): NewSpaceWizardHook {
// The Network choice under Advanced (Internet only unless changed).
const net = ctx.adapter?.network;
if (net && net.wizardPreset !== "internet") {
- args = { ...args, network: net.wizardPreset === "localhost" ? "localhost:all" : net.wizardPreset };
+ args = { ...args, network: net.wizardPreset === "localhost" || net.wizardPreset === "localhost+lan" ? `${net.wizardPreset}:all` : net.wizardPreset };
}
net?.setWizardPreset("internet");
update((x) => ({ ...x, open: false, state: null, pinnedEnv: null }));
diff --git a/apps/cua-spaces-web/src/bridge/protocol.ts b/apps/cua-spaces-web/src/bridge/protocol.ts
index 63c697ba5e..cf6d79cbaa 100644
--- a/apps/cua-spaces-web/src/bridge/protocol.ts
+++ b/apps/cua-spaces-web/src/bridge/protocol.ts
@@ -285,7 +285,8 @@ export interface HostOperations
"network.get": { args: { spaceId: string }; result: SpaceNetworkWire };
/** Replaces a Space's network (`cua network set`): `network` is the
* preset word (`internet`, `none`, `localhost:5432,3000`, `localhost:all`,
- * `lan`, `custom`, `custom:none`, `unprotected`); `widen` lets a child
+ * `lan`, `localhost+lan:5432,3000` (both extras), `custom`, `custom:none`,
+ * `unprotected`); `widen` lets a child
* reach more than its parent (the user's own choice, recorded). */
"network.set": {
args: {
diff --git a/apps/cua-spaces-web/src/components/network/network-picker.test.tsx b/apps/cua-spaces-web/src/components/network/network-picker.test.tsx
new file mode 100644
index 0000000000..e2784f57b2
--- /dev/null
+++ b/apps/cua-spaces-web/src/components/network/network-picker.test.tsx
@@ -0,0 +1,123 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+import { createMemoryHistory, createRootRoute, createRouter, RouterProvider } from "@tanstack/react-router";
+import { act, cleanup, render, waitFor } from "@testing-library/react";
+import { afterEach, describe, expect, it } from "vitest";
+
+import { BridgeProvider, type DataAdapter } from "@/bridge";
+import { createDemoAdapter } from "@/bridge/adapters/demo";
+import { noCore } from "@/bridge/__tests__/testCore";
+
+import { NetworkSheet } from "./network-sheet";
+import { openNetworkSheet } from "./use-network";
+
+afterEach(cleanup);
+
+const RESEARCH = "local:research-swarm";
+const WORKER = "local:swarm-worker-1";
+
+function open(id: string) {
+ const adapter: DataAdapter = createDemoAdapter({ latencyMs: 0, network: new Set(["network"]) });
+ const router = createRouter({ routeTree: createRootRoute({ component: () => <NetworkSheet spaceName={(x) => x} /> }), history: createMemoryHistory({ initialEntries: ["/"] }) });
+ render(
+ <BridgeProvider adapter={adapter} core={noCore}>
+ <RouterProvider router={router} />
+ </BridgeProvider>,
+ );
+ return { adapter, id, ready: () => waitFor(() => expect(document.querySelector("[data-network-sheet]")).not.toBeNull()) };
+}
+
+const q = (sel: string) => document.querySelector<HTMLElement>(sel);
+const extra = (id: string) => q(`[data-network-extra="${id}"]`);
+const box = (id: string) => extra(id)!.querySelector<HTMLElement>('[role="checkbox"]')!;
+const checked = (id: string) => box(id).getAttribute("aria-checked") === "true";
+const click = (el: HTMLElement) => act(() => el.click());
+
+describe("the Network picker", () => {
+ it("shows Internet only with nothing ticked, and two independent boxes", async () => {
+ const t = open(RESEARCH);
+ act(() => openNetworkSheet(t.id));
+ await t.ready();
+ expect(q('[data-network-preset="internet"]')?.getAttribute("data-selected")).toBe("true");
+ expect(q('[data-network-preset="localhost"]')).toBeNull();
+ expect(q('[data-network-preset="lan"]')).toBeNull();
+ expect(q("[data-network-extras]")?.textContent).toContain("Also allow");
+ expect(extra("localhost")?.textContent).toContain("Services on this computer");
+ expect(extra("localhost")?.textContent).toContain("Lets the Space use services running on this computer, like a database or dev server.");
+ expect(extra("lan")?.textContent).toContain("Other devices on my network");
+ expect(extra("lan")?.textContent).toContain("Lets the Space reach printers, routers, NAS and other computers on your network.");
+ expect(checked("localhost")).toBe(false);
+ expect(checked("lan")).toBe(false);
+ expect(q("[data-network-warning]")).toBeNull();
+ expect(q("[data-network-sheet]")?.getAttribute("data-preset")).toBe("internet");
+ });
+
+ it("ticks one box: its warning shows, and only localhost asks for ports", async () => {
+ const t = open(RESEARCH);
+ act(() => openNetworkSheet(t.id));
+ await t.ready();
+ click(box("lan"));
+ expect(checked("lan")).toBe(true);
+ expect(checked("localhost")).toBe(false);
+ expect(q("[data-network-sheet]")?.getAttribute("data-preset")).toBe("lan");
+ expect(q("[data-network-warning]")?.textContent).toContain("reach every computer on your network");
+ expect(q("[data-network-ports]")).toBeNull();
+ click(box("lan"));
+ click(box("localhost"));
+ expect(q("[data-network-sheet]")?.getAttribute("data-preset")).toBe("localhost");
+ expect(q("[data-network-ports]")).not.toBeNull();
+ });
+
+ it("ticks both, saves the combination, and unticking one leaves the other", async () => {
+ const t = open(RESEARCH);
+ act(() => openNetworkSheet(t.id));
+ await t.ready();
+ click(box("localhost"));
+ click(box("lan"));
+ expect(checked("localhost") && checked("lan")).toBe(true);
+ expect(q("[data-network-sheet]")?.getAttribute("data-preset")).toBe("localhost+lan");
+ expect(document.querySelectorAll("[data-network-warning]").length).toBe(2);
+ click(box("localhost"));
+ expect(q("[data-network-sheet]")?.getAttribute("data-preset")).toBe("lan");
+ click(box("localhost"));
+ click(q("[data-network-save]")!);
+ expect(t.adapter.network?.get(t.id)?.network.preset).toBe("localhost+lan");
+ });
+
+ it("hides the extras for No network and for Custom", async () => {
+ const t = open(RESEARCH);
+ act(() => openNetworkSheet(t.id));
+ await t.ready();
+ click(box("lan"));
+ click(q('[data-network-preset="none"] button')!);
+ expect(q("[data-network-extras]")).toBeNull();
+ expect(q("[data-network-sheet]")?.getAttribute("data-preset")).toBe("none");
+ click(q('[data-network-preset="internet"] button')!);
+ expect(q("[data-network-sheet]")?.getAttribute("data-preset")).toBe("internet");
+ expect(checked("lan")).toBe(false);
+ click(q('[data-network-preset="custom"] button')!);
+ expect(q("[data-network-extras]")).toBeNull();
+ });
+
+ it("keeps the extras when Internet only is clicked while they are ticked", async () => {
+ const t = open(RESEARCH);
+ act(() => openNetworkSheet(t.id));
+ await t.ready();
+ click(box("lan"));
+ click(q('[data-network-preset="internet"] button')!);
+ expect(checked("lan")).toBe(true);
+ });
+
+ it("stops a child from ticking what its parent does not allow", async () => {
+ // swarm-worker-1 is a child of research-swarm; the demo host gives it Internet only here.
+ const t = open(WORKER);
+ act(() => openNetworkSheet(t.id));
+ await t.ready();
+ for (const id of ["localhost", "lan"]) {
+ expect(box(id).hasAttribute("data-disabled")).toBe(true);
+ expect(extra(id)?.textContent).toContain("More than research-swarm allows");
+ }
+ expect(q('[data-network-preset="none"] button')?.hasAttribute("disabled")).toBe(false);
+ });
+});
diff --git a/apps/cua-spaces-web/src/components/network/network-sheet.tsx b/apps/cua-spaces-web/src/components/network/network-sheet.tsx
index d5dc98bc8d..b60ab56327 100644
--- a/apps/cua-spaces-web/src/components/network/network-sheet.tsx
+++ b/apps/cua-spaces-web/src/components/network/network-sheet.tsx
@@ -6,6 +6,7 @@ import { useEffect, useState } from "react";
import type { NetworkPreset, SpaceNetwork, SpaceTopology } from "@/bridge/contracts/network";
import { Button } from "@/components/ui/button";
+import { Checkbox } from "@/components/ui/checkbox";
import { Dialog, DialogPopup, DialogTitle } from "@/components/ui/dialog";
import { DetailsDisclosure, GroupedRow, GroupedSection, SectionHeading } from "@/components/ui/grouped";
import { Input } from "@/components/ui/input";
@@ -13,13 +14,15 @@ import { Segmented } from "@/components/ui/segmented";
import { Select } from "@/components/ui/select";
import { cn } from "@/lib/utils";
-import { PRESETS, alwaysBlocked, exitDescription, presetInfo, validEntry, validProxy } from "./presets";
+import { EXTRAS, PRESETS, alwaysBlocked, exceeds, exitDescription, extrasOf, isInternetBase, presetWith, validEntry, validProxy } from "./presets";
import { closeNetworkSheet, useNetworkPreview, useNetworkSheetFor } from "./use-network";
/**
- * A Space's Network sheet. Presets as radio rows
- * (Internet only by default), Custom's allow and block lists, what is
- * always blocked, and for a child Space what its parent allows.
+ * A Space's Network sheet. The base as radio rows (Internet only by
+ * default), under Internet only an "Also allow" list of two independent
+ * checkboxes (services on this computer, other devices on the network),
+ * Custom's allow and block lists, what is always blocked, and for a child
+ * Space what its parent allows.
*/
export function NetworkSheet({ spaceName }: { spaceName: (id: string) => string }) {
const store = useNetworkPreview();
@@ -78,7 +81,10 @@ function NetworkSheetBody({
const [widen, setWiden] = useState(false);
const pick = (preset: NetworkPreset) => setN((x) => ({ ...x, preset }));
// A child Space: nothing looser than its parent, unless widened here on purpose.
- const ceiling = parent && !widen ? presetInfo(initial.preset).rank : Infinity;
+ const ceiling = parent && !widen ? initial.preset : null;
+ const tooMuch = (preset: NetworkPreset) => ceiling !== null && exceeds(preset, ceiling);
+ const extras = extrasOf(n.preset);
+ const setExtra = (id: "localhost" | "lan", on: boolean) => setN((x) => ({ ...x, preset: presetWith({ ...extrasOf(x.preset), [id]: on }) }));
const inherited = Boolean(initial.inheritedFrom) && n.preset === initial.preset;
return (
<Dialog open onOpenChange={(open) => !open && closeNetworkSheet()}>
@@ -95,9 +101,9 @@ function NetworkSheetBody({
</p>
) : null}
<GroupedSection role="radiogroup" aria-label="Network">
- {PRESETS.map((p) => {
- const selected = n.preset === p.id;
- const looser = p.rank > ceiling;
+ {PRESETS.filter((p) => p.id === "internet" || p.id === "none" || p.id === "custom").map((p) => {
+ const selected = p.id === "internet" ? isInternetBase(n.preset) : n.preset === p.id;
+ const looser = tooMuch(p.id);
return (
<div key={p.id} data-network-preset={p.id} data-selected={selected || undefined}>
<button
@@ -105,7 +111,7 @@ function NetworkSheetBody({
role="radio"
aria-checked={selected}
disabled={looser}
- onClick={() => pick(p.id)}
+ onClick={() => !selected && pick(p.id)}
className="flex w-full cursor-default items-start gap-3 px-4 py-2.5 text-left outline-none hover:bg-accent/50 focus-visible:bg-accent/50 disabled:hover:bg-transparent"
>
<Radio on={selected} className={cn("mt-0.5", looser && "opacity-40")} />
@@ -118,19 +124,42 @@ function NetworkSheetBody({
</span>
{looser ? <span className="mt-0.5 shrink-0 text-xs text-muted-foreground">More than {parent} allows</span> : null}
</button>
- {selected && p.warning ? (
- <div className="px-4 pb-3 pl-11">
- <p data-network-warning="" className="flex items-start gap-2 rounded-lg bg-warning/10 px-3 py-2 text-xs">
- <TriangleAlertIcon className="mt-px size-3.5 shrink-0 text-warning" />
- {p.warning}
- </p>
- {p.id === "localhost" ? <Ports ports={n.localhostPorts ?? []} onChange={(localhostPorts) => setN((x) => ({ ...x, localhostPorts }))} /> : null}
- </div>
- ) : null}
</div>
);
})}
</GroupedSection>
+ {isInternetBase(n.preset) ? (
+ <div data-network-extras="" className="mt-4">
+ <SectionHeading>Also allow</SectionHeading>
+ <GroupedSection className="mt-2" role="group" aria-label="Also allow">
+ {EXTRAS.map((x) => {
+ const on = extras[x.id];
+ const looser = tooMuch(presetWith({ ...extras, [x.id]: true }));
+ return (
+ <div key={x.id} data-network-extra={x.id} data-selected={on || undefined}>
+ <label className={cn("flex w-full cursor-default items-start gap-3 px-4 py-2.5", !looser && "hover:bg-accent/50")}>
+ <Checkbox className="mt-0.5" checked={on} disabled={looser && !on} aria-label={x.title} onCheckedChange={(v) => setExtra(x.id, v)} />
+ <span className={cn("min-w-0 flex-1", looser && !on && "opacity-50")}>
+ <span className="block text-[13px]">{x.title}</span>
+ <span className="mt-px block text-xs text-muted-foreground">{x.description}</span>
+ </span>
+ {looser && !on ? <span className="mt-0.5 shrink-0 text-xs text-muted-foreground">More than {parent} allows</span> : null}
+ </label>
+ {on ? (
+ <div className="px-4 pb-3 pl-11">
+ <p data-network-warning="" className="flex items-start gap-2 rounded-lg bg-warning/10 px-3 py-2 text-xs">
+ <TriangleAlertIcon className="mt-px size-3.5 shrink-0 text-warning" />
+ {x.warning}
+ </p>
+ {x.id === "localhost" ? <Ports ports={n.localhostPorts ?? []} onChange={(localhostPorts) => setN((y) => ({ ...y, localhostPorts }))} /> : null}
+ </div>
+ ) : null}
+ </div>
+ );
+ })}
+ </GroupedSection>
+ </div>
+ ) : null}
{parent && !widen ? (
<button
type="button"
diff --git a/apps/cua-spaces-web/src/components/network/presets.test.ts b/apps/cua-spaces-web/src/components/network/presets.test.ts
new file mode 100644
index 0000000000..3cd56795e5
--- /dev/null
+++ b/apps/cua-spaces-web/src/components/network/presets.test.ts
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+import { describe, expect, it } from "vitest";
+
+import type { NetworkPreset, SpaceNetwork } from "@/bridge/contracts/network";
+import { networkWord } from "@/bridge/network";
+
+import { exceeds, extrasOf, isInternetBase, networkSummary, presetWith } from "./presets";
+
+const net = (preset: NetworkPreset, extra: Partial<SpaceNetwork> = {}): SpaceNetwork => ({ preset, allow: [], deny: [], enforced: true, ...extra });
+
+describe("the two extras under Internet only", () => {
+ it("are independent: each preset says which it has", () => {
+ expect(extrasOf("internet")).toEqual({ localhost: false, lan: false });
+ expect(extrasOf("localhost")).toEqual({ localhost: true, lan: false });
+ expect(extrasOf("lan")).toEqual({ localhost: false, lan: true });
+ expect(extrasOf("localhost+lan")).toEqual({ localhost: true, lan: true });
+ expect(extrasOf("none")).toEqual({ localhost: false, lan: false });
+ });
+
+ it("combine back into a preset, both ways round", () => {
+ for (const p of ["internet", "localhost", "lan", "localhost+lan"] as const) {
+ expect(presetWith(extrasOf(p))).toBe(p);
+ expect(isInternetBase(p)).toBe(true);
+ }
+ expect(isInternetBase("none")).toBe(false);
+ expect(isInternetBase("custom")).toBe(false);
+ });
+
+ it("are siblings: neither is above the other", () => {
+ expect(exceeds("lan", "localhost")).toBe(true);
+ expect(exceeds("localhost", "lan")).toBe(true);
+ expect(exceeds("localhost", "localhost")).toBe(false);
+ expect(exceeds("lan", "lan")).toBe(false);
+ });
+});
+
+describe("a child Space can't have more than its parent", () => {
+ it("holds for the base", () => {
+ expect(exceeds("internet", "none")).toBe(true);
+ expect(exceeds("none", "internet")).toBe(false);
+ expect(exceeds("custom", "internet")).toBe(false);
+ expect(exceeds("internet", "custom")).toBe(false);
+ expect(exceeds("localhost", "none")).toBe(true);
+ });
+
+ it("holds for each extra, and for both", () => {
+ expect(exceeds("localhost", "internet")).toBe(true);
+ expect(exceeds("lan", "internet")).toBe(true);
+ expect(exceeds("localhost+lan", "internet")).toBe(true);
+ expect(exceeds("localhost+lan", "localhost")).toBe(true);
+ expect(exceeds("localhost+lan", "lan")).toBe(true);
+ expect(exceeds("localhost+lan", "localhost+lan")).toBe(false);
+ expect(exceeds("localhost", "localhost+lan")).toBe(false);
+ expect(exceeds("lan", "localhost+lan")).toBe(false);
+ expect(exceeds("internet", "localhost+lan")).toBe(false);
+ });
+});
+
+describe("the Details summary", () => {
+ it("reads naturally for each combination", () => {
+ expect(networkSummary(net("internet"))).toBe("Internet only");
+ expect(networkSummary(net("localhost"))).toBe("Internet and this computer's services");
+ expect(networkSummary(net("lan"))).toBe("Internet and your local network");
+ expect(networkSummary(net("localhost+lan"))).toBe("Internet, this computer's services and your local network");
+ expect(networkSummary(net("none"))).toBe("No network");
+ expect(networkSummary(net("custom"))).toBe("Custom");
+ });
+
+ it("has no dot separators", () => {
+ for (const p of ["internet", "localhost", "lan", "localhost+lan", "none", "custom"] as const) expect(networkSummary(net(p))).not.toMatch(/[·•]/);
+ });
+});
+
+describe("the word the host takes", () => {
+ it("keeps the old words and adds the combination", () => {
+ expect(networkWord(net("internet"))).toBe("internet");
+ expect(networkWord(net("lan"))).toBe("lan");
+ expect(networkWord(net("localhost", { localhostPorts: [5432, 3000] }))).toBe("localhost:5432,3000");
+ expect(networkWord(net("localhost", { localhostPorts: [] }))).toBe("localhost:all");
+ expect(networkWord(net("localhost+lan", { localhostPorts: [5432, 3000] }))).toBe("localhost+lan:5432,3000");
+ expect(networkWord(net("localhost+lan", { localhostPorts: [] }))).toBe("localhost+lan:all");
+ });
+});
diff --git a/apps/cua-spaces-web/src/components/network/presets.ts b/apps/cua-spaces-web/src/components/network/presets.ts
index fe05c9fa76..c1dffa2806 100644
--- a/apps/cua-spaces-web/src/components/network/presets.ts
+++ b/apps/cua-spaces-web/src/components/network/presets.ts
@@ -13,26 +13,67 @@ export interface PresetInfo {
description: string;
/** Opens more than the default: says so when chosen. */
warning?: string;
- /** How open it is: a child Space can't go above its parent's. */
- rank: number;
}
+/** What a preset adds to Internet only. The two extras are independent of each other. */
+export interface Extras {
+ /** Services running on this computer, on listed ports. */
+ localhost: boolean;
+ /** Printers, routers, NAS and other devices on the local network. */
+ lan: boolean;
+}
+
+export const extrasOf = (p: NetworkPreset): Extras => ({ localhost: p === "localhost" || p === "localhost+lan", lan: p === "lan" || p === "localhost+lan" });
+
+/** The Internet-only preset with these extras: `internet`, `localhost`, `lan` or `localhost+lan`. */
+export const presetWith = ({ localhost, lan }: Extras): NetworkPreset => (localhost && lan ? "localhost+lan" : localhost ? "localhost" : lan ? "lan" : "internet");
+
+/** Internet only with the extras ("Also allow"), or something else. */
+export const isInternetBase = (p: NetworkPreset) => p === "internet" || p === "localhost" || p === "lan" || p === "localhost+lan";
+
+/**
+ * Whether `p` opens more than `ceiling`, a parent's preset: a child Space can't. Having
+ * any network is more than none; each extra is more only where the ceiling lacks it, so
+ * neither extra is above the other.
+ */
+export function exceeds(p: NetworkPreset, ceiling: NetworkPreset): boolean {
+ const reaches = (x: NetworkPreset) => (x === "none" ? 0 : 1);
+ if (reaches(p) > reaches(ceiling)) return true;
+ const a = extrasOf(p);
+ const c = extrasOf(ceiling);
+ return (a.localhost && !c.localhost) || (a.lan && !c.lan);
+}
+
+/** The two "Also allow" choices under Internet only. */
+export const EXTRAS: { id: keyof Extras; title: string; description: string; warning: string }[] = [
+ {
+ id: "localhost",
+ title: "Services on this computer",
+ description: "Lets the Space use services running on this computer, like a database or dev server.",
+ warning: "Only for code you trust. Programs in this Space could read or change data in those services.",
+ },
+ {
+ id: "lan",
+ title: "Other devices on my network",
+ description: "Lets the Space reach printers, routers, NAS and other computers on your network.",
+ warning: "Only for code you trust. Programs in this Space could reach every computer on your network.",
+ },
+];
+
export const PRESETS: PresetInfo[] = [
{
id: "internet",
- title: "Internet only (default)",
+ title: "Internet only",
short: "Internet only",
description: "Reaches the internet and its own child Spaces. Can't reach this computer, your local network or other Spaces.",
- rank: 1,
},
- { id: "none", title: "No network", short: "No network", description: "No connections in or out. Cua can still show and control the Space.", rank: 0 },
+ { id: "none", title: "No network", short: "No network", description: "No connections in or out. Cua can still show and control the Space." },
{
id: "localhost",
title: "Allow this computer's localhost",
short: "This computer's localhost",
description: "Lets the Space use services running on this computer, like a database or dev server.",
warning: "Only for code you trust. Programs in this Space could read or change data in those services.",
- rank: 2,
},
{
id: "lan",
@@ -40,16 +81,26 @@ export const PRESETS: PresetInfo[] = [
short: "Local network",
description: "Lets the Space reach printers, routers, NAS and other computers on your network.",
warning: "Only for code you trust. Programs in this Space could reach every computer on your network.",
- rank: 3,
},
- { id: "custom", title: "Custom", short: "Custom", description: "Choose domains and address ranges.", rank: 1 },
+ {
+ id: "localhost+lan",
+ title: "Allow this computer's localhost and my local network",
+ short: "Localhost and local network",
+ description: "Lets the Space use services on this computer and reach the other devices on your network.",
+ warning: "Only for code you trust. Programs in this Space could use services on this computer and reach every computer on your network.",
+ },
+ { id: "custom", title: "Custom", short: "Custom", description: "Choose domains and address ranges." },
];
export const presetInfo = (id: NetworkPreset) => PRESETS.find((p) => p.id === id)!;
-/** "Internet only (default)", "No network", "Custom". */
+/** "Internet only", "Internet and this computer's services", "No network", "Custom". */
export function networkSummary(n: SpaceNetwork): string {
- if (n.preset === "internet") return n.inheritedFrom ? "Internet only" : "Internet only (default)";
+ const e = extrasOf(n.preset);
+ if (e.localhost && e.lan) return "Internet, this computer's services and your local network";
+ if (e.localhost) return "Internet and this computer's services";
+ if (e.lan) return "Internet and your local network";
+ if (n.preset === "internet") return "Internet only";
return presetInfo(n.preset).short;
}
diff --git a/apps/cua-spaces-web/src/components/network/space-security.tsx b/apps/cua-spaces-web/src/components/network/space-security.tsx
index ba4342f2ff..44348a6082 100644
--- a/apps/cua-spaces-web/src/components/network/space-security.tsx
+++ b/apps/cua-spaces-web/src/components/network/space-security.tsx
@@ -80,7 +80,7 @@ function NetworkButton({ spaceId, summary }: { spaceId: string; summary: string
>
<span className="shrink-0 text-muted-foreground">Network</span>
<span className="flex min-w-0 items-center gap-1">
- <span className="truncate">{summary}</span>
+ <span className="truncate" title={summary}>{summary}</span>
<ChevronRightIcon className="size-3.5 shrink-0 text-muted-foreground" />
</span>
</button>
@@ -108,7 +108,7 @@ export function SecurityRows({ spaceId, className }: { spaceId: string; classNam
>
<span className="shrink-0 text-muted-foreground">Network</span>
<span className="flex min-w-0 items-center gap-1">
- <span className="truncate">{networkSummary(s.network)}</span>
+ <span className="truncate" title={networkSummary(s.network)}>{networkSummary(s.network)}</span>
<ChevronRightIcon className="size-3.5 shrink-0 text-muted-foreground" />
</span>
</button>
diff --git a/docs/content/docs/cua-cli/reference/cli/sharing-and-networks.mdx b/docs/content/docs/cua-cli/reference/cli/sharing-and-networks.mdx
index 1c8c663114..e45ed07614 100644
--- a/docs/content/docs/cua-cli/reference/cli/sharing-and-networks.mdx
+++ b/docs/content/docs/cua-cli/reference/cli/sharing-and-networks.mdx
@@ -285,7 +285,7 @@ cua network set [OPTIONS] <SPACE>
| Flag | Type | Default | Description |
| --- | --- | --- | --- |
-| <span id="cua-network-set--network"></span>`--network` | string | | `internet`, `none`, `localhost:<ports>` (or `localhost:all`), `lan`, `custom`, `custom:none` or `unprotected` (No protection). Left out: the preset it has (to change only `--via`). |
+| <span id="cua-network-set--network"></span>`--network` | string | | `internet`, `none`, `localhost:<ports>` (or `localhost:all`), `lan`, `localhost+lan:<ports>` (both), `custom`, `custom:none` or `unprotected` (No protection). Left out: the preset it has (to change only `--via`). |
| <span id="cua-network-set--via"></span>`--via` | string | | Where its internet traffic leaves: `internet` (its own network, the default), `this-computer` (this computer's network: the hotspot), `space:<name>` (a Space of its tree) or `socks5://host:port`. Its rules apply first; if the exit goes away, its internet stops (it never falls back). A child keeps its parent's. Left out: the exit it has. |
| <span id="cua-network-set--allow"></span>`--allow` | string | | Allow this destination (IP, CIDR, or a name such as `pypi.org` or `*.github.com` on runtimes behind the Cua network gateway; repeat for more). Repeatable. |
| <span id="cua-network-set--deny"></span>`--deny` | string | | Block this destination (IP, CIDR, `all`, or a name on runtimes behind the Cua network gateway; repeat for more). A deny wins over the Space's own tree: it blocks a member of the tree too. Repeatable. |
diff --git a/docs/content/docs/cua-sdk/reference/protocol/daemon-egress.mdx b/docs/content/docs/cua-sdk/reference/protocol/daemon-egress.mdx
index d5549e1ff9..1fdab99a6e 100644
--- a/docs/content/docs/cua-sdk/reference/protocol/daemon-egress.mdx
+++ b/docs/content/docs/cua-sdk/reference/protocol/daemon-egress.mdx
@@ -59,8 +59,11 @@ host compiles them to. `Space.network_settings` and
daemon are blocked;
- "none": no network;
- "localhost": "internet", plus the host's loopback on
- `localhost_ports` (every port only with `all_localhost_ports`);
+ `localhost_ports` (every port only with `all_localhost_ports`; the ports
+ go with "localhost+lan" too);
- "lan": "internet", plus the local network (not the host itself);
+- "localhost+lan": "internet", plus both of the above (the two extras are
+ independent; 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.
diff --git a/docs/content/docs/cua-sdk/reference/spaces/network.mdx b/docs/content/docs/cua-sdk/reference/spaces/network.mdx
index 81ddd398df..288ad6e628 100644
--- a/docs/content/docs/cua-sdk/reference/spaces/network.mdx
+++ b/docs/content/docs/cua-sdk/reference/spaces/network.mdx
@@ -237,6 +237,8 @@ and the cua daemon are blocked;
- `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.
@@ -247,9 +249,9 @@ preset is `unprotected`.
| Field | Type | Default | Description |
| --- | --- | --- | --- |
-| `preset` | `String` | `""` | `internet`, `none`, `localhost`, `lan`, `custom` or `unprotected`; empty is `internet`. |
-| `localhost_ports` / `localhostPorts` | `Vec<u16>` | `[]` | `localhost`: the ports of this computer's localhost the Space may reach. |
-| `all_localhost_ports` / `allLocalhostPorts` | `bool` | `false` | `localhost`: every port (the daemon's stay blocked). |
+| `preset` | `String` | `""` | `internet`, `none`, `localhost`, `lan`, `localhost+lan`, `custom` or `unprotected`; empty is `internet`. |
+| `localhost_ports` / `localhostPorts` | `Vec<u16>` | `[]` | `localhost` and `localhost+lan`: the ports of this computer's localhost the Space may reach. |
+| `all_localhost_ports` / `allLocalhostPorts` | `bool` | `false` | `localhost` and `localhost+lan`: every port (the daemon's stay blocked). |
| `allow` | `Vec<String>` | `[]` | Destinations that stay reachable (addresses or CIDRs). |
| `deny` | `Vec<String>` | `[]` | Destinations that are blocked (addresses, CIDRs or `all`). |
| `custom_base` / `customBase` | `String` | `""` | `custom`: what it starts from, `internet` (empty) or `none`. |
diff --git a/libs/cua/crates/cua-cli/src/network_cmd.rs b/libs/cua/crates/cua-cli/src/network_cmd.rs
index 9a488d458b..0d0cb85359 100644
--- a/libs/cua/crates/cua-cli/src/network_cmd.rs
+++ b/libs/cua/crates/cua-cli/src/network_cmd.rs
@@ -56,7 +56,8 @@ pub enum NetworkCmd {
/// Space id or name.
space: String,
/// `internet`, `none`, `localhost:<ports>` (or `localhost:all`),
- /// `lan`, `custom`, `custom:none` or `unprotected` (No protection).
+ /// `lan`, `localhost+lan:<ports>` (both), `custom`, `custom:none` or
+ /// `unprotected` (No protection).
/// Left out: the preset it has (to change only `--via`).
#[arg(long, value_name = "PRESET")]
network: Option<String>,
diff --git a/libs/cua/crates/cua-sdk/src/native/spaces.rs b/libs/cua/crates/cua-sdk/src/native/spaces.rs
index bf92f2b7c9..54288404a6 100644
--- a/libs/cua/crates/cua-sdk/src/native/spaces.rs
+++ b/libs/cua/crates/cua-sdk/src/native/spaces.rs
@@ -290,6 +290,8 @@ impl EgressEnforcement {
/// - `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.
@@ -299,17 +301,18 @@ impl EgressEnforcement {
/// preset is `unprotected`.
#[derive(Debug, Clone, Default, PartialEq, Eq, uniffi::Record, Deserialize)]
pub struct NetworkSettings {
- /// `internet`, `none`, `localhost`, `lan`, `custom` or `unprotected`;
- /// empty is `internet`.
+ /// `internet`, `none`, `localhost`, `lan`, `localhost+lan`, `custom` or
+ /// `unprotected`; empty is `internet`.
#[uniffi(default)]
#[serde(default)]
pub preset: String,
- /// `localhost`: the ports of this computer's localhost the Space may
- /// reach.
+ /// `localhost` and `localhost+lan`: the ports of this computer's
+ /// localhost the Space may reach.
#[uniffi(default)]
#[serde(default)]
pub localhost_ports: Vec<u16>,
- /// `localhost`: every port (the daemon's stay blocked).
+ /// `localhost` and `localhost+lan`: every port (the daemon's stay
+ /// blocked).
#[uniffi(default)]
#[serde(default)]
pub all_localhost_ports: bool,
diff --git a/libs/cua/crates/cua-spaces/src/cloud.rs b/libs/cua/crates/cua-spaces/src/cloud.rs
index 054c1ec000..a41d99ffe3 100644
--- a/libs/cua/crates/cua-spaces/src/cloud.rs
+++ b/libs/cua/crates/cua-spaces/src/cloud.rs
@@ -243,7 +243,7 @@ fn cloud_network(
};
}
match settings.preset {
- P::Localhost | P::Lan => Err(Error::invalid(format!(
+ P::Localhost | P::Lan | P::LocalhostLan => Err(Error::invalid(format!(
"a Space in your cloud account ({word}) can't reach this computer or your local \
network; use internet (the default), none or custom"
))),
diff --git a/libs/cua/crates/cua-spaces/src/host_ports.rs b/libs/cua/crates/cua-spaces/src/host_ports.rs
index 3dda965090..0631e5aa76 100644
--- a/libs/cua/crates/cua-spaces/src/host_ports.rs
+++ b/libs/cua/crates/cua-spaces/src/host_ports.rs
@@ -66,7 +66,7 @@ pub(crate) type HostPortsTable = tokio::sync::Mutex<BTreeMap<String, HostPortsRu
/// The ports a Space's settings publish at `localhost` (the `localhost`
/// preset's listed ports; `all` publishes none).
pub fn published_ports(settings: &crate::network::NetworkSettings) -> Vec<u16> {
- if settings.preset != crate::network::NetworkPreset::Localhost || settings.all_localhost_ports {
+ if !settings.preset.opens_localhost() || settings.all_localhost_ports {
return Vec::new();
}
let mut v = settings.localhost_ports.clone();
diff --git a/libs/cua/crates/cua-spaces/src/network.rs b/libs/cua/crates/cua-spaces/src/network.rs
index 1d03cde98e..5c0c12b124 100644
--- a/libs/cua/crates/cua-spaces/src/network.rs
+++ b/libs/cua/crates/cua-spaces/src/network.rs
@@ -382,7 +382,8 @@ pub(crate) struct CreateNetwork {
/// Settings from one word as the CLI, SDK and MCP take it: `internet`
/// (`default` and empty too), `none`, `lan`, `unprotected`, `custom` (from
-/// `internet`), `custom:none`, `localhost:5432,3000` or `localhost:all`,
+/// `internet`), `custom:none`, `localhost:5432,3000` or `localhost:all`
+/// (`localhost+lan:5432,3000` adds the local network too),
/// with `allow` and `deny` lists on top.
pub fn parse_network(word: &str, allow: &[String], deny: &[String]) -> Result<NetworkSettings> {
let w = word.trim();
@@ -398,10 +399,10 @@ pub fn parse_network(word: &str, allow: &[String], deny: &[String]) -> Result<Ne
let mut s = NetworkSettings::preset(preset);
match (preset, rest) {
(_, None) => {}
- (NetworkPreset::Localhost, Some(r)) if r.trim().eq_ignore_ascii_case("all") => {
+ (p, Some(r)) if p.opens_localhost() && r.trim().eq_ignore_ascii_case("all") => {
s.all_localhost_ports = true
}
- (NetworkPreset::Localhost, Some(r)) => {
+ (p, Some(r)) if p.opens_localhost() => {
for p in r.split(',').map(str::trim).filter(|p| !p.is_empty()) {
let port =
p.parse::<u16>().ok().filter(|p| *p > 0).ok_or_else(|| {
@@ -877,6 +878,15 @@ mod tests {
assert!(p("localhost:all").unwrap().all_localhost_ports);
assert!(p("localhost").is_err(), "ports are needed");
assert!(p("localhost:0").is_err());
+ let b = p("localhost+lan:5432, 3000").unwrap();
+ assert_eq!(b.preset, NetworkPreset::LocalhostLan);
+ assert_eq!(b.localhost_ports, [5432, 3000]);
+ assert!(p("localhost+lan:all").unwrap().all_localhost_ports);
+ assert!(p("localhost+lan").is_err(), "ports are needed");
+ assert_eq!(
+ p("lan+localhost:80").unwrap().preset,
+ NetworkPreset::LocalhostLan
+ );
assert_eq!(p("custom:none").unwrap().custom_base, NetworkPreset::None);
assert!(p("lan:5432").is_err());
assert!(p("open").is_err());
@@ -905,6 +915,12 @@ mod tests {
let lan = NetworkSettings::preset(NetworkPreset::Lan);
let e = refuse_widening_by_agent(&lan, None).unwrap_err();
assert!(e.to_string().contains("cua network set"), "{e}");
+ // Both extras together are the user's to choose too, and from `lan`
+ // alone they are more than the Space has.
+ let both = parse_network("localhost+lan:5432", &[], &[]).unwrap();
+ assert!(refuse_widening_by_agent(&both, None).is_err());
+ assert!(refuse_widening_by_agent(&both, Some(&lan)).is_err());
+ assert!(refuse_widening_by_agent(&lan, Some(&both)).is_err());
assert!(
refuse_widening_by_agent(&NetworkSettings::preset(NetworkPreset::Unprotected), None)
.is_err()
diff --git a/libs/cua/crates/cua-spaces/src/topology.rs b/libs/cua/crates/cua-spaces/src/topology.rs
index 0aa0df6dfd..31e2f6f22f 100644
--- a/libs/cua/crates/cua-spaces/src/topology.rs
+++ b/libs/cua/crates/cua-spaces/src/topology.rs
@@ -70,13 +70,12 @@ pub struct Member {
/// `at_localhost`: the Space's daemon publishes the host's ports on its own
/// loopback (`crate::host_ports`), so `localhost:<port>` works as written.
pub fn host_section(settings: &NetworkSettings, at_localhost: bool) -> Value {
- let ports: Vec<u16> = if settings.preset == crate::network::NetworkPreset::Localhost {
+ let ports: Vec<u16> = if settings.preset.opens_localhost() {
settings.localhost_ports.clone()
} else {
Vec::new()
};
- let all =
- settings.preset == crate::network::NetworkPreset::Localhost && settings.all_localhost_ports;
+ let all = settings.preset.opens_localhost() && settings.all_localhost_ports;
json!({
"name": HOST_NAME,
"ports": ports,
diff --git a/libs/cua/crates/cua-vmm/src/network.rs b/libs/cua/crates/cua-vmm/src/network.rs
index ff5d2431ca..afa7656905 100644
--- a/libs/cua/crates/cua-vmm/src/network.rs
+++ b/libs/cua/crates/cua-vmm/src/network.rs
@@ -4,7 +4,9 @@
//! **Presets.** [`NetworkPreset::Internet`] is the default: the public
//! internet and the Space's own tree. [`NetworkPreset::None`] reaches
//! nothing. [`NetworkPreset::Localhost`] and [`NetworkPreset::Lan`] add the
-//! host's loopback (on listed ports) or the local network.
+//! host's loopback (on listed ports) or the local network, each on top of
+//! `internet` and independent of the other; [`NetworkPreset::LocalhostLan`]
+//! (`localhost+lan`) adds both.
//! [`NetworkPreset::Custom`] starts from `internet` or `none` and adds the
//! user's allow and deny lists. [`NetworkPreset::Unprotected`] opens
//! everything but the platform denies.
@@ -67,6 +69,11 @@ pub enum NetworkPreset {
Localhost,
/// `internet`, plus the local network.
Lan,
+ /// `internet`, plus the host's loopback on listed ports and the local
+ /// network: `localhost` and `lan` together. The two extras are
+ /// independent; this is the one preset that has both.
+ #[serde(rename = "localhost+lan")]
+ LocalhostLan,
/// `internet` or `none`, plus the user's allow and deny lists.
Custom,
/// Everything but the platform denies.
@@ -75,11 +82,12 @@ pub enum NetworkPreset {
impl NetworkPreset {
/// Every preset.
- pub const ALL: [NetworkPreset; 6] = [
+ pub const ALL: [NetworkPreset; 7] = [
NetworkPreset::Internet,
NetworkPreset::None,
NetworkPreset::Localhost,
NetworkPreset::Lan,
+ NetworkPreset::LocalhostLan,
NetworkPreset::Custom,
NetworkPreset::Unprotected,
];
@@ -91,6 +99,7 @@ impl NetworkPreset {
NetworkPreset::None => "none",
NetworkPreset::Localhost => "localhost",
NetworkPreset::Lan => "lan",
+ NetworkPreset::LocalhostLan => "localhost+lan",
NetworkPreset::Custom => "custom",
NetworkPreset::Unprotected => "unprotected",
}
@@ -103,25 +112,53 @@ impl NetworkPreset {
NetworkPreset::None => "No network",
NetworkPreset::Localhost => "Allow this computer's localhost",
NetworkPreset::Lan => "Allow my local network",
+ NetworkPreset::LocalhostLan => "Allow this computer's localhost and my local network",
NetworkPreset::Custom => "Custom",
NetworkPreset::Unprotected => "No protection",
}
}
+ /// Whether the preset opens the host's loopback (on listed ports):
+ /// `localhost`, alone or with `lan`.
+ pub fn opens_localhost(self) -> bool {
+ matches!(self, NetworkPreset::Localhost | NetworkPreset::LocalhostLan)
+ }
+
+ /// Whether the preset opens the local network: `lan`, alone or with
+ /// `localhost`.
+ pub fn opens_lan(self) -> bool {
+ matches!(self, NetworkPreset::Lan | NetworkPreset::LocalhostLan)
+ }
+
+ /// The `internet` preset plus the extras asked for: `internet`,
+ /// `localhost`, `lan` or `localhost+lan`.
+ pub fn with_extras(localhost: bool, lan: bool) -> NetworkPreset {
+ match (localhost, lan) {
+ (false, false) => NetworkPreset::Internet,
+ (true, false) => NetworkPreset::Localhost,
+ (false, true) => NetworkPreset::Lan,
+ (true, true) => NetworkPreset::LocalhostLan,
+ }
+ }
+
/// Parses a preset word (case-insensitive). `default` is `internet`,
- /// as the old `network="default"` was.
+ /// as the old `network="default"` was; `lan+localhost` is
+ /// `localhost+lan`.
pub fn parse(text: &str) -> Result<NetworkPreset, PolicyError> {
let t = text.trim().to_ascii_lowercase();
if t == "default" {
return Ok(NetworkPreset::Internet);
}
+ if t == "lan+localhost" {
+ return Ok(NetworkPreset::LocalhostLan);
+ }
NetworkPreset::ALL
.into_iter()
.find(|p| p.as_str() == t)
.ok_or_else(|| {
PolicyError(format!(
- "network {text:?}: expected internet, none, localhost, lan, custom or \
- unprotected"
+ "network {text:?}: expected internet, none, localhost, lan, localhost+lan, \
+ custom or unprotected"
))
})
}
@@ -359,7 +396,7 @@ impl NetworkSettings {
.into(),
));
}
- let localhost = self.preset == NetworkPreset::Localhost;
+ let localhost = self.preset.opens_localhost();
if !localhost && (!self.localhost_ports.is_empty() || self.all_localhost_ports) {
return Err(PolicyError(
"localhost ports go with the localhost preset".into(),
@@ -470,19 +507,21 @@ impl NetworkSettings {
/// and anything stricter.
pub fn widenings(&self) -> Vec<String> {
let mut out = Vec::new();
- match self.preset {
- NetworkPreset::Lan => out.push("Allows your local network".to_string()),
- NetworkPreset::Localhost if self.all_localhost_ports => {
- out.push("Allows this computer's localhost (all ports)".to_string())
- }
- NetworkPreset::Localhost => out.push(format!(
- "Allows this computer's localhost (ports {})",
- join_ports(&self.localhost_ports)
- )),
- NetworkPreset::Unprotected => {
- out.push("No protection: allows everything but cloud metadata".to_string())
- }
- NetworkPreset::Internet | NetworkPreset::None | NetworkPreset::Custom => {}
+ if self.preset.opens_localhost() {
+ out.push(if self.all_localhost_ports {
+ "Allows this computer's localhost (all ports)".to_string()
+ } else {
+ format!(
+ "Allows this computer's localhost (ports {})",
+ join_ports(&self.localhost_ports)
+ )
+ });
+ }
+ if self.preset.opens_lan() {
+ out.push("Allows your local network".to_string());
+ }
+ if self.preset == NetworkPreset::Unprotected {
+ out.push("No protection: allows everything but cloud metadata".to_string());
}
if let Ok(rules) = self.custom.split_domains().0.parse() {
for r in rules.rules.iter().filter(|r| r.accept) {
@@ -511,10 +550,10 @@ impl NetworkSettings {
fn preset_summary(&self) -> String {
match self.preset {
- NetworkPreset::Localhost if self.all_localhost_ports => {
+ p if p.opens_localhost() && self.all_localhost_ports => {
format!("{} (all ports)", self.preset.label())
}
- NetworkPreset::Localhost => format!(
+ p if p.opens_localhost() => format!(
"{} (ports {})",
self.preset.label(),
join_ports(&self.localhost_ports)
@@ -546,7 +585,7 @@ impl NetworkSettings {
},
..Default::default()
};
- if preset == P::Localhost {
+ if preset.opens_localhost() {
let both_all = self.all_localhost_ports && parent.all_localhost_ports;
out.all_localhost_ports = both_all;
if !both_all {
@@ -558,7 +597,9 @@ impl NetworkSettings {
_ => mine.into_iter().filter(|p| theirs.contains(p)).collect(),
};
if out.localhost_ports.is_empty() {
- out.preset = P::Internet;
+ // No port both list: the localhost extra goes, a shared
+ // `lan` extra stays.
+ out.preset = NetworkPreset::with_extras(false, preset.opens_lan());
}
}
}
@@ -620,7 +661,7 @@ impl NetworkSettings {
}
fn ports_of(s: &NetworkSettings) -> Vec<u16> {
- if s.preset == NetworkPreset::Localhost {
+ if s.preset.opens_localhost() {
s.localhost_ports.clone()
} else {
Vec::new()
@@ -641,9 +682,14 @@ fn meet(a: &NetworkSettings, b: &NetworkSettings) -> (NetworkPreset, NetworkPres
match (pa, pb) {
(P::Unprotected, other) | (other, P::Unprotected) => (other, P::Internet),
(P::Custom, _) | (_, P::Custom) => (P::Custom, P::Internet),
- (P::Lan, P::Lan) => (P::Lan, P::Internet),
- (P::Localhost, P::Localhost) => (P::Localhost, P::Internet),
- (P::Internet | P::Lan | P::Localhost, _) => (P::Internet, P::Internet),
+ // The two extras are independent: the meet keeps those both open.
+ (P::Internet | P::Lan | P::Localhost | P::LocalhostLan, _) => (
+ P::with_extras(
+ pa.opens_localhost() && pb.opens_localhost(),
+ pa.opens_lan() && pb.opens_lan(),
+ ),
+ P::Internet,
+ ),
(P::None, _) => (P::None, P::Internet),
}
}
@@ -844,7 +890,7 @@ pub fn vm_rules(
/// daemon's. Every port is refused for VMs: a namespace forwards listed
/// ports only. Empty for any other preset or under the old default.
pub fn vm_localhost_ports(settings: Option<&NetworkSettings>) -> Result<Vec<u16>, PolicyError> {
- let Some(s) = settings.filter(|s| s.preset == NetworkPreset::Localhost) else {
+ let Some(s) = settings.filter(|s| s.preset.opens_localhost()) else {
return Ok(Vec::new());
};
if Mode::from_env() == Mode::Legacy {
@@ -1056,7 +1102,7 @@ pub fn compile_mode(
}
// 3. The host: only `localhost` opens its aliases, on its ports.
if !unprotected {
- if settings.preset == NetworkPreset::Localhost {
+ if settings.preset.opens_localhost() {
for ip in dedup(ctx.host_aliases.iter().copied()) {
r.push(Rule {
ports: (!settings.all_localhost_ports)
@@ -1090,7 +1136,7 @@ pub fn compile_mode(
for n in default_reserved() {
r.push(Rule::net(n, false, Reason::DefaultReserved));
}
- if settings.preset != NetworkPreset::Lan {
+ if !settings.preset.opens_lan() {
for n in default_lan() {
r.push(Rule::net(n, false, Reason::DefaultLan));
}
diff --git a/libs/cua/crates/cua-vmm/src/network/tests.rs b/libs/cua/crates/cua-vmm/src/network/tests.rs
index 7ec4315db6..ee956840e7 100644
--- a/libs/cua/crates/cua-vmm/src/network/tests.rs
+++ b/libs/cua/crates/cua-vmm/src/network/tests.rs
@@ -647,7 +647,7 @@ fn settings() -> impl Strategy<Value = NetworkSettings> {
..Default::default()
};
match preset {
- NetworkPreset::Localhost => {
+ p if p.opens_localhost() => {
s.localhost_ports = ports;
s.all_localhost_ports = all || s.localhost_ports.is_empty();
s.localhost_ports.dedup();
@@ -719,7 +719,7 @@ proptest! {
prop_assert!(!asked.allows_port(ip(host), Proto::Tcp, 3200));
}
// Only localhost (or no protection) reaches the host.
- if !matches!(s.preset, NetworkPreset::Localhost | NetworkPreset::Unprotected) {
+ if !(s.preset.opens_localhost() || s.preset == NetworkPreset::Unprotected) {
for host in ["10.0.2.2", "192.168.64.1", "192.168.1.20", "203.0.113.7", "::ffff:10.0.2.2"] {
for port in PORTS {
prop_assert!(!asked.allows_port(ip(host), Proto::Tcp, port), "{:?} {}", s, host);
@@ -1114,3 +1114,159 @@ fn the_summary_names_the_exit() {
"Internet only, through the Space proxy"
);
}
+
+fn both(ports: &[u16]) -> NetworkSettings {
+ NetworkSettings {
+ preset: NetworkPreset::LocalhostLan,
+ localhost_ports: ports.to_vec(),
+ ..Default::default()
+ }
+}
+
+#[test]
+fn localhost_and_lan_are_independent_extras_and_together_open_both() {
+ let r = secure(&both(&[5432]));
+ // The host's loopback on the listed port only.
+ assert!(r.allows_port(ip("10.0.2.2"), Proto::Tcp, 5432));
+ assert!(!r.allows_port(ip("10.0.2.2"), Proto::Tcp, 22));
+ // The local network, plus the internet.
+ for ok in ["192.168.0.9", "10.9.9.9", "fd00::5", "1.1.1.1"] {
+ assert!(r.allows(ip(ok)), "{ok}");
+ }
+ // Still closed: the host's other addresses, cloud metadata, CGNAT.
+ for blocked in ["192.168.1.20", "169.254.169.254", "100.64.1.1", "127.0.0.1"] {
+ assert!(!r.allows(ip(blocked)), "{blocked}");
+ }
+ // Neither single preset opens the other's extra.
+ assert!(!secure(&localhost(&[5432])).allows(ip("192.168.0.9")));
+ assert!(
+ !secure(&NetworkSettings::preset(NetworkPreset::Lan)).allows_port(
+ ip("10.0.2.2"),
+ Proto::Tcp,
+ 5432
+ )
+ );
+ // Its ports are checked like localhost's.
+ assert!(both(&[]).validate().is_err());
+ assert!(both(&[0]).validate().is_err());
+ let all = NetworkSettings {
+ preset: NetworkPreset::LocalhostLan,
+ all_localhost_ports: true,
+ ..Default::default()
+ };
+ assert!(all.validate().is_ok());
+ // Ports belong to the presets that open localhost only.
+ let mut lan = NetworkSettings::preset(NetworkPreset::Lan);
+ lan.localhost_ports = vec![1];
+ assert!(lan.validate().is_err());
+}
+
+#[test]
+fn localhost_lan_words_json_and_old_values() {
+ assert_eq!(
+ NetworkPreset::parse("localhost+lan").unwrap(),
+ NetworkPreset::LocalhostLan
+ );
+ assert_eq!(
+ NetworkPreset::parse("LAN+Localhost").unwrap(),
+ NetworkPreset::LocalhostLan
+ );
+ assert_eq!(NetworkPreset::LocalhostLan.as_str(), "localhost+lan");
+ // The old words still mean what they did.
+ assert_eq!(
+ NetworkPreset::parse("localhost").unwrap(),
+ NetworkPreset::Localhost
+ );
+ assert_eq!(NetworkPreset::parse("lan").unwrap(), NetworkPreset::Lan);
+ for p in NetworkPreset::ALL {
+ assert_eq!(NetworkPreset::parse(p.as_str()).unwrap(), p);
+ let j = serde_json::to_string(&p).unwrap();
+ assert_eq!(j, format!("\"{}\"", p.as_str()));
+ assert_eq!(serde_json::from_str::<NetworkPreset>(&j).unwrap(), p);
+ }
+ // Settings files written before the combination keep loading.
+ let old: NetworkSettings =
+ serde_json::from_str(r#"{"preset":"localhost","localhost_ports":[5432]}"#).unwrap();
+ assert_eq!(old, localhost(&[5432]));
+ let old: NetworkSettings = serde_json::from_str(r#"{"preset":"lan"}"#).unwrap();
+ assert_eq!(old, NetworkSettings::preset(NetworkPreset::Lan));
+ let new: NetworkSettings =
+ serde_json::from_str(r#"{"preset":"localhost+lan","localhost_ports":[3000]}"#).unwrap();
+ assert_eq!(new, both(&[3000]));
+ assert_eq!(
+ NetworkPreset::with_extras(true, true),
+ NetworkPreset::LocalhostLan
+ );
+ assert_eq!(
+ NetworkPreset::with_extras(false, false),
+ NetworkPreset::Internet
+ );
+}
+
+#[test]
+fn localhost_lan_summary_and_widenings_name_both() {
+ let s = both(&[5432, 3000]);
+ assert_eq!(
+ s.summary(),
+ "Allow this computer's localhost and my local network (ports 5432, 3000)"
+ );
+ let w = s.widenings();
+ assert_eq!(w.len(), 2, "{w:?}");
+ assert!(w[0].contains("localhost (ports 5432, 3000)"), "{w:?}");
+ assert_eq!(w[1], "Allows your local network");
+}
+
+#[test]
+fn localhost_lan_children_keep_only_the_extras_both_open() {
+ let lan = NetworkSettings::preset(NetworkPreset::Lan);
+ // A child can only have less than its parent, and the two extras are
+ // independent.
+ assert_eq!(both(&[5432]).intersect(&both(&[5432])), both(&[5432]));
+ assert_eq!(both(&[5432]).intersect(&lan), lan);
+ assert_eq!(lan.intersect(&both(&[5432])), lan);
+ assert_eq!(
+ both(&[5432, 3000]).intersect(&localhost(&[5432])),
+ localhost(&[5432])
+ );
+ assert_eq!(
+ localhost(&[5432]).intersect(&both(&[5432, 3000])),
+ localhost(&[5432])
+ );
+ assert_eq!(
+ both(&[5432]).intersect(&NetworkSettings::internet()),
+ NetworkSettings::internet()
+ );
+ assert_eq!(
+ NetworkSettings::internet().intersect(&both(&[5432])),
+ NetworkSettings::internet()
+ );
+ assert_eq!(
+ both(&[5432]).intersect(&NetworkSettings::none()),
+ NetworkSettings::none()
+ );
+ // Both open, but no port in common: the local network stays, the
+ // localhost extra goes.
+ assert_eq!(both(&[1]).intersect(&both(&[2])), lan);
+ assert_eq!(
+ both(&[1]).intersect(&localhost(&[2])),
+ NetworkSettings::internet()
+ );
+ // Ports under a combination parent narrow like localhost's.
+ assert_eq!(both(&[1, 2]).intersect(&both(&[2, 3])), both(&[2]));
+ // Lan and localhost are siblings: neither is under the other.
+ assert_eq!(
+ lan.intersect(&localhost(&[5432])),
+ NetworkSettings::internet()
+ );
+}
+
+#[test]
+fn vms_forward_localhost_lan_ports_too() {
+ if Mode::from_env() == Mode::Legacy {
+ return;
+ }
+ assert_eq!(
+ vm_localhost_ports(Some(&both(&[3000, 5432]))).unwrap(),
+ [3000, 5432]
+ );
+}
diff --git a/libs/cua/kotlin/src/main/kotlin/ai/cua/sdk/cua_sdk.kt b/libs/cua/kotlin/src/main/kotlin/ai/cua/sdk/cua_sdk.kt
index 1c15bfc08c..99fbed8066 100644
--- a/libs/cua/kotlin/src/main/kotlin/ai/cua/sdk/cua_sdk.kt
+++ b/libs/cua/kotlin/src/main/kotlin/ai/cua/sdk/cua_sdk.kt
@@ -39525,6 +39525,8 @@ public object FfiConverterTypeNetworkEvent: FfiConverterRustBuffer<NetworkEvent>
* - `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.
@@ -39535,19 +39537,20 @@ public object FfiConverterTypeNetworkEvent: FfiConverterRustBuffer<NetworkEvent>
*/
data class NetworkSettings (
/**
- * `internet`, `none`, `localhost`, `lan`, `custom` or `unprotected`;
- * empty is `internet`.
+ * `internet`, `none`, `localhost`, `lan`, `localhost+lan`, `custom` or
+ * `unprotected`; empty is `internet`.
*/
var `preset`: kotlin.String = ""
,
/**
- * `localhost`: the ports of this computer's localhost the Space may
- * reach.
+ * `localhost` and `localhost+lan`: the ports of this computer's
+ * localhost the Space may reach.
*/
var `localhostPorts`: List<kotlin.UShort> = listOf()
,
/**
- * `localhost`: every port (the daemon's stay blocked).
+ * `localhost` and `localhost+lan`: every port (the daemon's stay
+ * blocked).
*/
var `allLocalhostPorts`: kotlin.Boolean = false
,
diff --git a/libs/cua/proto/cua/daemon/v1/egress.proto b/libs/cua/proto/cua/daemon/v1/egress.proto
index aa2081a114..3cfaa29377 100644
--- a/libs/cua/proto/cua/daemon/v1/egress.proto
+++ b/libs/cua/proto/cua/daemon/v1/egress.proto
@@ -42,8 +42,11 @@ message SetSpaceEgressResponse {}
// daemon are blocked;
// - "none": no network;
// - "localhost": "internet", plus the host's loopback on
-// `localhost_ports` (every port only with `all_localhost_ports`);
+// `localhost_ports` (every port only with `all_localhost_ports`; the ports
+// go with "localhost+lan" too);
// - "lan": "internet", plus the local network (not the host itself);
+// - "localhost+lan": "internet", plus both of the above (the two extras are
+// independent; 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.
diff --git a/libs/cua/python/src/cua/_native.py b/libs/cua/python/src/cua/_native.py
index 0988c5eddd..9ba77528b6 100644
--- a/libs/cua/python/src/cua/_native.py
+++ b/libs/cua/python/src/cua/_native.py
@@ -19583,6 +19583,8 @@ class NetworkSettings:
- `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.
diff --git a/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift b/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift
index 2a85ef6aea..e03ca53197 100644
--- a/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift
+++ b/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift
@@ -31833,6 +31833,8 @@ public func FfiConverterTypeNetworkEvent_lower(_ value: NetworkEvent) -> RustBuf
* - `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.
@@ -31843,17 +31845,18 @@ public func FfiConverterTypeNetworkEvent_lower(_ value: NetworkEvent) -> RustBuf
*/
public struct NetworkSettings: Equatable, Hashable {
/**
- * `internet`, `none`, `localhost`, `lan`, `custom` or `unprotected`;
- * empty is `internet`.
+ * `internet`, `none`, `localhost`, `lan`, `localhost+lan`, `custom` or
+ * `unprotected`; empty is `internet`.
*/
public var preset: String
/**
- * `localhost`: the ports of this computer's localhost the Space may
- * reach.
+ * `localhost` and `localhost+lan`: the ports of this computer's
+ * localhost the Space may reach.
*/
public var localhostPorts: [UInt16]
/**
- * `localhost`: every port (the daemon's stay blocked).
+ * `localhost` and `localhost+lan`: every port (the daemon's stay
+ * blocked).
*/
public var allLocalhostPorts: Bool
/**
@@ -31884,15 +31887,16 @@ public struct NetworkSettings: Equatable, Hashable {
// declare one manually.
public init(
/**
- * `internet`, `none`, `localhost`, `lan`, `custom` or `unprotected`;
- * empty is `internet`.
+ * `internet`, `none`, `localhost`, `lan`, `localhost+lan`, `custom` or
+ * `unprotected`; empty is `internet`.
*/preset: String = "",
/**
- * `localhost`: the ports of this computer's localhost the Space may
- * reach.
+ * `localhost` and `localhost+lan`: the ports of this computer's
+ * localhost the Space may reach.
*/localhostPorts: [UInt16] = [],
/**
- * `localhost`: every port (the daemon's stay blocked).
+ * `localhost` and `localhost+lan`: every port (the daemon's stay
+ * blocked).
*/allLocalhostPorts: Bool = false,
/**
* Destinations that stay reachable (addresses or CIDRs).
diff --git a/libs/cua/typescript/src/native/cua_sdk.ts b/libs/cua/typescript/src/native/cua_sdk.ts
index 42b6273052..8b5f6b48bb 100644
--- a/libs/cua/typescript/src/native/cua_sdk.ts
+++ b/libs/cua/typescript/src/native/cua_sdk.ts
@@ -14132,6 +14132,8 @@ const FfiConverterTypeNetworkEvent = (() => {
* - `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.
@@ -14142,17 +14144,18 @@ const FfiConverterTypeNetworkEvent = (() => {
*/
export type NetworkSettings = {
/**
- * `internet`, `none`, `localhost`, `lan`, `custom` or `unprotected`;
- * empty is `internet`.
+ * `internet`, `none`, `localhost`, `lan`, `localhost+lan`, `custom` or
+ * `unprotected`; empty is `internet`.
*/
preset: string,
/**
- * `localhost`: the ports of this computer's localhost the Space may
- * reach.
+ * `localhost` and `localhost+lan`: the ports of this computer's
+ * localhost the Space may reach.
*/
localhostPorts: Array<number>,
/**
- * `localhost`: every port (the daemon's stay blocked).
+ * `localhost` and `localhost+lan`: every port (the daemon's stay
+ * blocked).
*/
allLocalhostPorts: boolean,
/**
diff --git a/scripts/docs-generators/cli-specs/cua.json b/scripts/docs-generators/cli-specs/cua.json
index 6dfc27dec3..7758b8d94f 100644
--- a/scripts/docs-generators/cli-specs/cua.json
+++ b/scripts/docs-generators/cli-specs/cua.json
@@ -10367,7 +10367,7 @@
"aliases": [],
"default_value": null,
"env": null,
- "help": "`internet`, `none`, `localhost:<ports>` (or `localhost:all`), `lan`, `custom`, `custom:none` or `unprotected` (No protection). Left out: the preset it has (to change only `--via`)",
+ "help": "`internet`, `none`, `localhost:<ports>` (or `localhost:all`), `lan`, `localhost+lan:<ports>` (both), `custom`, `custom:none` or `unprotected` (No protection). Left out: the preset it has (to change only `--via`)",
"hidden": false,
"is_optional": true,
"multiple_values": false,