Repository navigation
Multi Entry
🌐 English · 简体中文
This page explains Trizano's multi-Entry architecture: how multiple Hub machines form a redundant Entry group via a shared Roster, how Nodes and clients discover and fail over between Entries, why session tickets work across Entries, and how to recover from a failed or compromised Entry.
With a single Entry, if the Hub host crashes or your home internet drops, agent Sessions keep running on their Nodes, but clients lose control until the Hub comes back. Multi-Entry turns each Hub into a replaceable Entry: for example, you can run Entry A on an always-on machine at home and Entry B as an entry-only VPS in the cloud. Every Node connects simultaneously to every Entry with a configured origin. When one Entry goes down, Android and desktop clients fail over automatically to another Entry with Session state and event cursors intact.
flowchart TB
subgraph Clients["Clients"]
App["Android / Desktop (automatic failover)"]
Browser["Browser (shows other Entry links after 10 s offline)"]
end
subgraph Entries["Entry Group (sharing one Roster)"]
E1["Entry A (Root Entry, https://mac-mini.tailnet.ts.net)"]
E2["Entry B (Entry-only VPS, https://code2.example.com)"]
end
subgraph Nodes["Nodes (connected to every Entry with an origin)"]
N1["Node 1 (Local / Reverse)"]
N2["Node 2 (SSH / Reverse)"]
N3["Node 3 (Reverse-only)"]
end
E1 <-->|"EntryService.SyncRoster"| E2
App -->|"Hello 250 ms race / auto failover"| E1
App -.->|"Failover, same ticket"| E2
Browser --> E1
E1 <-->|"Owner channel / SystemService.SyncRoster"| N1
E1 <-->|"SSH / SystemService.SyncRoster"| N2
N3 -->|"Reverse WS + mTLS"| E1
N1 -->|"Reverse WS + mTLS"| E2
N2 -->|"Reverse WS + mTLS"| E2
N3 -->|"Reverse WS + mTLS"| E2
A Roster is an append-only set of signed statements that defines the active set of authorized devices, Nodes, and Entries. Because Entries and Nodes only take the set union and run a deterministic evaluator, they converge to the exact same membership regardless of the order in which statements arrive.
The contract is defined in proto/trizano/roster/v1/roster.proto, with evaluation implemented in server/internal/roster/eval.go:
-
Three statement types (
Statement): Each statement is signed with its issuer's P-256 identity private key into aSignedenvelope (signing payload"trizano-roster-v1\n" || body; raw bytes are stored verbatim and never re-serialized):-
Epoch: Starts a new Roster epoch with an initial member list. Only the root key can sign anEpoch. -
Add: Admits a member (ROLE_DEVICE,ROLE_NODE, orROLE_ENTRY) with its role, ID, display name, public key (or frozen WebAuthn credential JSON for passkey devices), and externalorigin(for Entries). -
Remove: Removes a member by listing all of its activeAddtags (tags).
-
-
Evaluation rules (
Evaluate(root, set)):- Picks the highest-numbered
Epochsigned by the root key as the baseline and ignores statements from older epochs. - Accepts only
Add/Removestatements in the current epoch whose signing chain traces back to the root or an active Entry. - Merges entries sharing the same identity (same role + same public key or passkey credential ID) into one member. If two distinct members under the same role collide on ID, the smaller tag keeps the base ID and the other deterministically receives a 4-character fingerprint suffix (growing by 4 characters if needed).
- Picks the highest-numbered
-
Cascade protection: When removing an Entry, if healthy devices or Nodes were previously approved only by that Entry,
Roster.Removeemits theRemovestatement together with freshAddstatements signed by the current Entry so those innocent members stay authorized. -
Smooth migration from single-Entry setups: On first startup after upgrading an older single-Entry Hub,
server/hub/roster.gouses the localidentity.pemas the root key and generates Epoch 1 from the legacydevicesandnodestables. All subsequent pairings, Node enrollments, and revocations are recorded as Roster statements.
The Entry that initializes the Roster is the root Entry; its identity.pem public key is written as roster_root in every Entry's and Node's database. During normal operation, the root Entry has the exact same authority as any other Entry (all Entries can sign Add / Remove statements and issue session tickets), except that only the host holding the root key can issue a new Epoch.
If an Entry is compromised, its private key leaks, and you suspect it may have silently admitted unknown devices or Entries, remove it from another Entry and—for a clean slate—start a new epoch on the root Entry (server/cmd/trizano-carbon/roster.go, server/hub/roster.go):
# 1. Stop the Hub on the root Entry first (the command refuses to run if admin.sock responds)
# 2. Run on the root Entry; --drop is repeatable with devices/ID, nodes/ID, or entries/ID
trizano-carbon roster reset [--data ~/.trizano/hub] --drop entries/<compromised-entry-id>
# 3. Restart the root Entry Hub; it automatically syncs the new epoch to online Nodes and remaining EntriesWarning
If the root Entry machine is lost permanently, the remaining Entries continue serving normally, but you permanently lose the ability to issue a new epoch. Keep encrypted off-site backups of the root Entry's identity.pem and hub.db using trizano-carbon backup; see Deployment & Operations.
Joining a second machine (such as a public VPS) to an existing Roster reuses NodeEnrollmentService with Role = ENROLLMENT_ROLE_ENTRY (server/cmd/trizano-carbon/entry.go, server/hub/entry.go):
-
Set up external HTTPS: Configure Tailscale Serve, Cloudflare Tunnel, or Caddy on the new host so all Nodes and clients can reach its HTTPS origin (e.g.
https://code2.example.com). -
Run
entry joinagainst an empty data directory:
trizano-carbon entry join https://existing-entry.example.com --origin https://code2.example.com [--data DIR]If --data already contains a Roster, the command refuses to run; specify a fresh --data directory or clear the old directory if you intend to discard its state. The command verifies the existing Entry's Hello signature and prints a 6-digit verification code.
3. Approve the enrollment: Enter the 6-digit code in the web/Android approval card on the existing Entry, or run trizano-carbon approve <6-digit-code> on the existing Entry host. Approving an Entry grants it full authority to sign Roster updates and issue session tickets—approve only machines you fully trust.
4. Start the new Entry: After approval, the new Entry verifies that the returned Roster includes itself, writes roster_root and all statements to hub.db, and exits. Start it normally (adding --no-local-node if this VPS will not run local agents):
trizano-carbon --origin https://code2.example.com --no-local-node [--data DIR]Note the two --origin flags: entry join --origin publishes the URL in the Roster so Nodes and clients know where to connect, while trizano-carbon --origin controls which browser origins are allowed for passkey sign-in and WebSockets. Normally both take the same HTTPS URL.
Roster statements propagate across Entries and Nodes over two complementary paths, so every reachable participant converges even when some direct links are blocked:
-
Entry ↔ Entry direct sync (
EntryService.SyncRoster): Defined inproto/trizano/hub/v1/entry.protoand implemented inserver/hub/entry_sync.go.- Requires no device ticket; request size cap is
4 MiB. The caller sends its public key, a millisecond timestamp, a P-256 signature over"trizano-entry-sync-v1\n" || b64(sha256(receiver_spki)) || "\n" || ts, and its full statement set. - The receiver checks the timestamp skew (±5 minutes), verifies the signature, confirms the caller's public key is an active
ROLE_ENTRYmember in its Roster, merges incoming statements, and returns its own full statement set. - Triggered immediately on Hub startup, immediately whenever the local statement set grows (pushed to every other active Entry with an
origin), and periodically every 10 minutes. Set union is idempotent, preventing sync storms and loops.
- Requires no device ticket; request size cap is
-
Entry ↔ Node bidirectional sync (
SystemService.SyncRoster): Implemented inserver/hub/roster.goandserver/node/roster.go.- Whenever a Node comes online or an Entry's Roster changes, the Entry calls
SystemService.SyncRosteron online Nodes to exchange statements. - When a Node learns new statements, it emits a
RosterChangedevent notifying all other Entries connected to that Node to sync. Even if two Entries cannot reach each other directly, any shared Node bridges their Roster updates. - A Node's
roster_rootis immutable once set: an owner-channel (local/SSH) sync can set the root on first contact, while a Reverse connection can only set a root matching therootpinned inentries.json. Any subsequent sync with a different root fails withPermissionDenied.
- Whenever a Node comes online or an Entry's Roster changes, the Entry calls
A Node's multi-Entry bootstrap configuration is stored in <root>/entries.json (0600, see server/node/join.go) and records two fields:
-
root: The Roster root public key (SPKI DER). -
bootstrap: The Entry used during initialtrizano-h3 join(origin,public_key,node_id), used until the Node syncs the full Roster.
Legacy <root>/hub.json files are automatically converted to entries.json (using the old Hub public key for both root and bootstrap.public_key) and removed on trizano-h3 serve or join.
Once the daemon starts, connectors (server/node/connect.go) maintains outbound links automatically from the Roster:
-
Concurrent multi-Entry links: Spawns one Reverse connector per active Entry with a non-empty
origin. Local and SSH Nodes also open Reverse connections to other Entries once they sync the Roster—you do not need to reconfigure SSH on newly added Entries. - No duplicate links: While an Entry holds an active owner-channel control bridge (local or SSH) to the Node, the Node automatically pauses its Reverse connector to that same Entry and resumes it if the owner channel drops.
-
Removal and backoff: If the synced Roster removes this Node, the daemon immediately stops all Reverse connectors (while keeping local
run/node.sockrunning). If a single Entry does not recognize the Node during handshake (StartNodeConnectreturnsNotFound, or/nodes-connectreturns403withX-Trizano-Revoked: 1), the Node backs off for 5 minutes on that Entry only and retries—accommodating a newly enrolled Node whose Roster update has not yet reached that Entry. -
Cross-Node delegation failover: Nodes track one
OpenControlBridgestream perentry_id(server/node/bridge.go). When issuing a cross-Node delegation call, the Node tries Entries ordered by most recent hello and automatically fails over to the next Entry onUnavailable.
A session credential issued on login or pairing is not an opaque session ID stored in one Entry's database. It is a self-contained trizano.roster.v1.Ticket signed by the issuing Entry's identity.pem (tt1.<body>.<sig>, valid for 30 days; see server/internal/roster/ticket.go).
Any Entry receiving an tt1. ticket validates four conditions offline against its local Roster:
- The ticket signature matches the embedded
issuerpublic key. -
issueris an activeROLE_ENTRYmember in the current Roster. -
deviceis an activeROLE_DEVICEmember in the current Roster. - The ticket has not expired and its random
idis not in this Entry'sticket_logoutstable.
As long as both the issuing Entry and the device remain in the Roster, a ticket issued by Entry A is accepted directly by Entry B with no shared session database and no re-authentication. See Security Model for 24-hour automatic ticket renewal and revocation behavior.
All clients fetch the list of active Entries with origins via DeviceService.ListEntries and refresh it on login, on first verification of a new Entry, and whenever the event stream delivers RosterChanged. You can inspect all known Entries and the currently active one under Settings → Devices & Login (「设置 → 设备与登录」) in the Entries (「入口」) section.
-
Desktop and Android (automatic failover):
-
250 ms
Hellorace: On cold start or reconnect when no Entry is currently connected, the client sendsHelloto the preferred Entry first; if it does not succeed within 250 ms (or fails sooner), it racesHelloagainst the next Entry in parallel (Happy Eyeballs;desktop-go/internal/proxy/upstream.go,android/app/src/main/kotlin/top/onemolchuan/code/net/Hub.kt). The first Entry to respond and pass public-key pinning wins. -
Runtime failover: Android switches to the next Entry in the list after 2 consecutive unreachable attempts, or immediately on ticket rejection or a
Hellopublic-key mismatch (android/app/src/main/kotlin/top/onemolchuan/code/state/Failover.kt). The desktop local proxy fails over across Entries automatically as it forwards requests or opens connections. Before sending a ticket to any Entry for the first time in a process, the client always verifies that Entry'sHellopublic key and timestamp (±5 minutes). -
State and cursor preservation: Failover preserves local state and per-Node
{boot, seq}event cursors, resuming the event stream on the new Entry without re-signing or prompting for biometrics, and displays a one-time notice ("Switched to Entry …" / 「已切换到入口「…」」). The client drops back to the login screen only when every reachable Entry rejects the ticket, avoiding spurious logouts when one Entry has not yet synced a freshly paired device.
-
250 ms
-
Browser (manual switch to another Entry):
- Because WebAuthn passkeys and browser security contexts are strictly scoped to each origin, a web page cannot transparently redirect its API traffic to another Entry's domain.
- When the active Entry remains disconnected and reconnecting for more than 10 seconds, a top banner (
web/src/components/EntryFallbackBanner.tsx) displays links to up to 3 other cached Entries. The first time you open a different Entry's domain in a browser, pair a passkey on that origin as a new device.
English
Getting Started
Deployment & Networking
Architecture & Nodes
Agents
Clients & Development
Project & Community
中文文档
新手指引
部署与网络
架构与节点
智能体
客户端与开发
项目与社区