MudEngine Part 11: Peer-to-Peer with iroh
Congratulations
You tore down the central server and rebuilt the MudEngine as a peer-to-peer application — the host's own machine is the world, the mesh carries the state, and every player is just another endpoint on the topic.
The architecture in three sentences
One desktop process owns the authoritative
GameEngineand broadcasts its answers through iroh-gossip; the same engine answers the host's own actions and every player's requests alike. Desktop players speak QUIC directly; browser players reach the topic through a WebSocket relay — the relay is stateless plumbing, not a second server. TheGameEnginenever touches a socket: it receives aClientMessageand returnsVec<ServerMessage>, and the network layer takes care of the rest.
What you removed compared to Part 10
dioxus/fullstack+dioxus-fullstack— no Axum, nouse_websocket, no SSRserver = ["dioxus/server"]— the feature and the entiresrc/game/server/moduledx servefor the desktop app —cargo runis all you need now- The server's
set_server_url("http://localhost:8080")andcfg(feature = "server")in main.rs — the mesh does not live at an HTTP endpoint
The series is done
You built a multiplayer MUD engine through eleven parts:
- Requirements
- Single-player REPL
- File-based world
- Single-player Dioxus GUI
- Component library
- Multiplayer with WebSockets
- Save & load
- Inventory & chat
- Cooperative quest
- Desktop with Blitz renderer
- Peer-to-peer with iroh
The dungeon is yours — extend the world, add quests, build an editor, or port it to mobile. The engine is in your hands.
| Concept | What it did |
|---|---|
| iroh Endpoint | Each player is a QUIC endpoint identified by an Ed25519 node id |
| iroh-gossip | Plumtree pub-sub mesh — replaces broadcast::Sender across the LAN |
| Topic id (blake3) | Both peers derive the same topic from the name — no config sync |
| mDNS address lookup | Same-network peers find each other's real IP without a relay |
| Router + ALPN | Registers gossip on the endpoint's accept loop — must stay alive |
| Authoritative host | One engine owns state; peers render; no CRDT needed |
| WebSocket relay | Stateless bytes-in/bytes-out bridge — step 2 for browsers |
| GameEngine extraction | Transport-agnostic logic: &mut self → Vec<ServerMessage> |
| Ephemeral client key | No persistent host file needed; dials out |
| Host.secret persistence | Stable host node id across launches — players always rejoin |
- iroh docs — endpoints, gossip, ALPN
- iroh-gossip crate —
TopicId,GossipReceiver,GossipSender - iroh-mdns-address-lookup — LAN shortcut
- blake3 — fast hash for deterministic topic ids
- Dioxus Native (Blitz)
- Part 10: Desktop with Blitz