Skip to content

Network Topology

root edited this page Dec 4, 2026 · 6 revisions

Network Topology & Data Paths

🌐 English · 简体中文

This page documents Trizano's end-to-end network architecture from clients to Nodes, the transport and authentication used on each hop, the Hub reverse proxy and WebSocket bridges, the desktop local proxy, and cross-Node delegation data paths. It is aimed at operators planning firewall rules, troubleshooting connectivity, or understanding internal traffic flow.

End-to-End Topology

All clients talk exclusively to an Entry Hub; Nodes never open listening network ports. Whether a Node runs locally, over SSH, inside WSL, natively on Windows, or behind NAT as a Reverse Node, every Hub-to-Node link carries the same HTTP/2 (h2c) channel underneath.

flowchart LR
    subgraph Clients["Clients"]
        Web["Browser (Web UI)"]
        Android["Android Client"]
        Desktop["Desktop App (Local Proxy 127.0.0.1:47801)"]
    end

    Proxy["HTTPS Reverse Proxy / Tunnel (Tailscale Serve · Cloudflare Tunnel · Caddy)"]
    Hub["Entry Hub (trizano-carbon): 127.0.0.1:47900 · admin.sock"]

    subgraph Nodes["Nodes (trizano-h3)"]
        Local["Local Node: attach ⇄ run/node.sock"]
        SSH["SSH Node (Linux/macOS): ssh stdio ⇄ attach"]
        WSL["WSL Distro Node: [ssh] wsl.exe --exec attach"]
        Win["Windows Native Node: ssh cmd/PS ⇄ attach"]
        Rev["Reverse Node (behind NAT): outbound WS /nodes-connect"]
    end

    Web -->|"HTTPS / WSS"| Proxy
    Android -->|"HTTPS / WSS"| Proxy
    Desktop -->|"HTTPS / WSS"| Proxy
    Proxy -->|"HTTP/1.1 · h2c · WS"| Hub

    Hub -->|"Local stdio → h2c"| Local
    Hub -->|"OpenSSH stdio → h2c"| SSH
    Hub -->|"wsl.exe stdio → h2c"| WSL
    Hub -->|"OpenSSH stdio → h2c"| Win
    Rev -->|"WS → mutual TLS 1.3 → h2c"| Hub
Loading

Transport and Authentication by Hop

Connections split into client-to-Hub access and five Node access modes. Below is the initiator, underlying transport, and authentication mechanism for each link.

Client → Reverse Proxy → Hub

Initiated by the client. External traffic terminates TLS at Tailscale Serve, Cloudflare Tunnel, or Caddy and forwards to 127.0.0.1:47900; local access can connect directly to http://localhost:47900. Unary RPCs and server streams use Connect (over HTTP/1.1 or h2c), while bidirectional streams (terminal, preview, browser) use WebSockets.

  • Authentication: Browsers sign in with WebAuthn passkeys and send either the trizano_session cookie (HttpOnly; SameSite=Strict) or Authorization: Bearer. Android and desktop clients authenticate by signing with a local P-256 device key, pin the Hub's public key during pairing, and verify AuthService.Hello before sending an tt1. ticket to an Entry for the first time in a process. See Security Model for the full flow.

Hub → Local Node

Initiated by the Hub (LocalDialer, server/hub/nodes/dial.go). The Hub spawns trizano-h3 attach, which connects to ~/.trizano/node/run/node.sock (starting the daemon detached if it is not already running) and bridges its stdin/stdout to that Unix socket. The Hub runs an h2c client over the stdio pipe.

  • Authentication: Relies on OS filesystem permissions—the Node directory is 0700 and run/node.sock is 0600, restricting access to the current OS user. Connections over this socket carry the owner-channel marker.

Hub → SSH Node (Linux / macOS)

Initiated by the Hub (RemoteDialer, server/hub/nodes/remote.go). The Hub invokes the system ssh -T client (on Unix with ControlMaster=auto and ControlPersist=10m, sockets under <data>/ssh/%C; see server/hub/sshx/sshx.go) to run <remote-dir>/bin/<build>/trizano-h3 attach --root <remote-dir>/node on the remote host. The Hub wraps the ssh child process stdin/stdout as a net.Conn and runs h2c over it.

  • Authentication: Reuses OpenSSH keys, ssh-agent, ~/.ssh/config, and remote filesystem permissions.
  • Keepalive and reconnection: The h2c connection sends a ping after 10 s idle and drops if no reply arrives within 5 s (or on write timeout). On disconnect, the Hub closes that host's ControlMaster and reconnects with exponential backoff from 1 s to 30 s (backoff resets once the connection stays healthy for 1 minute; see server/hub/nodes/node.go).

Hub → WSL Distro Node

Initiated by the Hub using the same RemoteDialer stdio + h2c pipeline:

  • When the Hub runs on Windows locally, it spawns wsl.exe -d <distro> --exec <remote-dir>/bin/<build>/trizano-h3 attach --root <remote-dir>/node (with WSL_UTF8=1).
  • For WSL on a remote Windows host, it runs ssh <host> wsl.exe -d <distro> --exec …. Authentication relies on local OS permissions or OpenSSH.

Hub → Windows Native Node

Initiated by the Hub (server/hub/nodes/windows.go). Installs and upgrades transfer binaries via sftp -b -; at runtime, the Hub executes .\.trizano\bin\<build>\trizano-h3.exe attach --root .\.trizano\node over OpenSSH (supporting cmd.exe, Windows PowerShell, and PowerShell 7) and runs h2c over stdio. Authentication relies on OpenSSH.

Reverse Node → Hub

Initiated outbound by the Node daemon (ReverseConnector, server/node/connect.go and server/hub/enrollment.go), traversing NAT, reverse proxies, and Cloudflare Tunnel:

  1. Challenge handshake: The Node calls the public RPC NodeEnrollmentService.StartNodeConnect with its node_id, a 32-byte client_nonce, and its locally held Roster statements. The Hub returns a one-time connect_id, a 32-byte challenge (valid for 30 s), and a proof signed by the Hub's private key.
  2. Signature verification and WebSocket upgrade: After verifying the Hub's signature against its pinned Entry public key, the Node signs a trizano-connect-node-v2 message bound to the Hub's public key and sends GET /nodes-connect with X-Trizano-Connect-Id and X-Trizano-Node-Signature. The Hub atomically consumes the challenge, verifies the Node's signature, and upgrades the connection to a standard WebSocket.
  3. Inner mutual TLS 1.3 + h2c: Inside the WebSocket binary frames, both sides establish mutual TLS 1.3 pinned to their long-term P-256 public keys (ALPN trizano-node-h2, 15 s handshake timeout). Inside that TLS tunnel, the Node serves h2c and the Hub's ReverseDialer acts as the h2c client for all Node RPCs.
  4. Keepalive: The Hub's h2c layer keeps its 10 s idle ping / 5 s timeout, and the Node additionally sends a ws.Ping every 30 s (10 s timeout) to stay well below proxy idle cutoffs such as Cloudflare's ~100 s timeout.

Path-Prefix Reverse Proxy and Three WebSocket Bridges

Rather than forwarding Node RPCs method by method, the Hub routes /nodes/{node}/<procedure> uniformly to the target Node in server/hub/nodes/registry.go.

HTTP / Connect Reverse Proxy

Clients construct a Connect transport per Node with base URL /nodes/{node}. When a request arrives, the Hub looks up the online Node for {node}, strips the /nodes/{node} prefix, and proxies the request verbatim over that Node's h2c connection without decoding payloads. Plain HTTP endpoints on the Node (/attachments uploads, /raw files, /media image previews) use the same prefix.

At the proxy boundary, the Hub rejects client access to internal and sensitive system procedures (403), strips Authorization and Cookie headers before forwarding, and enforces isolation headers on responses. See Security Model.

Three WebSocket Bidirectional Bridges

Browsers (and Android/desktop clients speaking standard WebSockets) cannot initiate Connect HTTP/2 bidirectional streams directly. The Hub intercepts three procedure paths under /nodes/{node}/ when Upgrade: websocket is present and bridges them to the Node's h2c bidirectional streams:

Procedure path (under /nodes/{node}) Message types Purpose Source
/trizano.node.v1.TerminalService/AttachTerminal AttachTerminalRequest / AttachTerminalResponse Interactive I/O and resize events for PTY terminals and native agent TUIs server/hub/nodes/terminal.go
/trizano.node.v1.PreviewService/Dial DialRequest / DialResponse Tunnels TCP byte streams from remote 127.0.0.1:<port> dev servers to the same local port on the client, including close_write half-close server/hub/nodes/preview.go
/trizano.node.v1.BrowserService/AttachTab AttachTabRequest / AttachTabResponse Frame streaming and mouse/keyboard/touch input for the Node's managed headless browser server/hub/nodes/browser.go

All three bridges follow the same conventions:

  • Origin checks and framing: Only origins matching the request Host or the Hub's --origin list are allowed. The default 32 KiB read limit is removed (SetReadLimit(-1)). Each binary WebSocket frame holds one raw protobuf message with no extra framing.
  • Close codes: 1000 normal close; 1003 invalid protobuf frame; 4400 (invalid argument / precondition, such as an unlistening port), 4401 (unauthenticated), 4403 (permission denied), and 4404 (terminal or Node not found) signal non-retryable errors so the client stops reconnecting; other transport or transient failures close with 1011.

Event Stream

Each client maintains a single server-streaming RPC to the Hub: trizano.hub.v1.EventService/Watch, carrying its Entry cursor and per-Node {boot, seq} cursors. The Hub buffers only Entry-level events (Node online/offline, pairings, enrollments, Roster changes) and opens one node.v1.EventService/Watch stream to each online Node, wrapping incoming events as node_event messages and emitting a heartbeat every 10 s when idle. See Event Sync for cursor resume, replay windows, and tiered catch-up.

Desktop Local Proxy (47801)

The desktop app (desktop-go/internal/proxy/proxy.go, upstream.go) embeds the same web frontend and serves it from a local loopback HTTP server loaded by the WebView:

  • Port strategy: Prefers 127.0.0.1:47801 so the WebView keeps a stable origin for localStorage preferences. If 47801 is busy, it falls back to an ephemeral port rather than failing to launch.
  • Window isolation: Every request's Host must match the proxy's own listen address, and any Origin header must match http://127.0.0.1:<port>, or the proxy returns 403—blocking DNS rebinding and cross-site requests.
  • Three responsibilities:
    1. Serves the embedded static web assets.
    2. Exposes /_desktop/* control endpoints (mode switching, standalone embedded Hub lifecycle, device-key signing, native notifications and badges, local preview port forwarding), all requiring the per-launch random X-Trizano-Desktop-Secret header.
    3. Reverse-proxies /trizano.* and /nodes/* (including the three WebSocket bridges) to the active Entry, injects the locally stored tt1. ticket, strips Set-Cookie and X-Trizano-Token from responses (saving renewed tickets locally), and handles Hello verification and multi-Entry failover.

The desktop app also bundles a preview port forwarder (desktop-go/internal/forward): opening a remote dev-server preview binds the exact same 127.0.0.1:<port> locally (failing rather than remapping if occupied, so CORS and OAuth redirect URLs remain consistent), tunneling each local TCP connection over a PreviewService/Dial WebSocket to the Hub.

Cross-Node Agent Delegation Data Path

An agent Session can delegate subtasks to an agent on another machine through the injected CLI or built-in MCP server. Traffic traverses the Node's private orchestration socket, the control bridge (SystemService.OpenControlBridge) between Node and Entry, and the Hub's bridge dispatcher (server/node/orch_http.go, server/node/bridge.go, server/hub/orch.go):

sequenceDiagram
    participant Agent as "Source Node Agent Process"
    participant SrcNode as "Source Node (trizano-h3)"
    participant Hub as "Entry Hub (trizano-carbon)"
    participant DstNode as "Target Node (trizano-h3)"

    Note over SrcNode,Hub: Hub opens SystemService.OpenControlBridge bidi stream when Node connects

    Agent->>SrcNode: POST /internal/orch/{method} (via orch/s.sock + Bearer HMAC token)
    SrcNode->>SrcNode: Verify HMAC token (session ID + hop) and MaxCrossNodeHops (1)
    SrcNode->>Hub: Send OpenControlBridgeResponse {call_id, method, payload}
    Note over SrcNode: With multiple Entries, tries by most recent hello; fails over on Unavailable
    Hub->>Hub: handleBridgeCall routes method and enforces hop limit
    Hub->>DstNode: Invoke Connect RPC over target Node h2c (CreateSession / SendMessage / WatchSession, etc.)
    DstNode-->>Hub: RPC response
    Hub-->>SrcNode: Send BridgeReply {call_id, payload / error} on control bridge
    SrcNode-->>Agent: Return JSON response
Loading

If the target Node is temporarily absent from the current Entry's registry (for example while reconnecting), the Hub's bridgeNodeClient translates NotFound into a retryable Unavailable, letting the source Node try another Entry's control bridge or keeping watch deliveries within their retry window instead of assuming the target disappeared permanently. See Multi-Agent Orchestration for the delegation protocol, watch callbacks, and permission mapping.

Ports and Sockets Reference

All default TCP ports and Unix sockets used by Trizano at runtime:

Address / Path Process Binding Notes
127.0.0.1:47900 trizano-carbon (Hub) TCP loopback Default Hub web UI and API port; configurable with --listen (server/cmd/trizano-carbon/main.go)
127.0.0.1:47910 Desktop standalone embedded Hub TCP loopback (optional 0.0.0.0) Default port for desktop standalone mode; configurable in settings, increments automatically if busy (desktop-go/internal/store/store.go)
127.0.0.1:47801 Desktop local proxy TCP loopback Default WebView proxy port; falls back to a random port if busy (desktop-go/internal/desktop/desktop.go)
127.0.0.1:5733 Vite dev server TCP loopback Development only (make dev-web); proxies /trizano.hub.v1. and /nodes/ to 47900 (web/vite.config.ts)
127.0.0.1:<port> Desktop / Android preview forwarder TCP loopback Bound on demand to match the remote dev server port, tunneled via PreviewService/Dial
~/.trizano/hub/admin.sock trizano-carbon (Hub) Unix socket Owner admin channel inside the 0700 data directory; serves DeviceService and NodeService (server/hub/hub.go)
~/.trizano/hub/ssh/%C OpenSSH client Unix socket SSH ControlMaster multiplexing sockets; not created on Windows (server/hub/sshx/sshx.go)
~/.trizano/node/run/node.sock trizano-h3 Unix socket (0600) Node owner channel (h2c) for attach, stop, and admin; Shutdown is accepted only here (server/node/daemon.go)
~/.trizano/node/orch/s.sock trizano-h3 Unix socket (0600) Agent orchestration channel (h2c); serves only POST /internal/orch/{method} for sandboxed agents (server/node/daemon.go)
~/.trizano/node/run/tmux.sock tmux (managed by Node) Unix socket Dedicated socket for persistent terminal sessions when tmux is available (server/node/node.go)

Clone this wiki locally