AI project · Home network · 2026

A home network that heals itself

At home in China, the things I rely on most need a steady overseas connection: AI tools, US banking, my university sign-in. So I built a network that routes every device in the house on its own. Chinese sites go direct. Everything else leaves through rented US servers, and AI and banking traffic takes one more hop to a residential address. A retired 2019 MacBook is the gateway, Cloudflare runs the control plane, and if any piece breaks, the house drops back to a plain connection in under a second.

AI coding agents wrote almost all of the code. I designed it, ran it and made the calls.

Where a request goes

pick a case

Role
Design, build and run it, with AI coding agents writing the code
Hardware
Retired 2019 MacBook Pro · ASUS mesh routers · four rented servers
Software
mihomo · Xray (VLESS + REALITY) · Asuswrt-Merlin · Cloudflare Workers, D1, KV, Tunnel
Scope
Every device at home, plus phones and laptops away from home
01

Many paths, drawn as graphs

Each way out of the house is a small graph: the client, the servers it passes through, and a rule on every line saying which traffic takes that hop.

A route can be one server, or a chain where only some traffic continues. The everyday route sends overseas traffic to a fast US server and forwards only the AI and banking domain groups to a server on a residential connection, because those sites are the strictest about where you appear to be. Routes are edited by dragging servers onto a canvas and drawing lines between them. The same graphs drive the home gateway and every phone or laptop subscription.

4subscription formats rendered at the edge: V2Ray, Clash, Shadowrocket, sing-box
4 + 1rented servers, plus a CDN relay for when a server's address gets blocked
30rolling snapshots of the whole configuration, plus an off-site copy in Git

The control plane runs entirely on Cloudflare: a Worker serves the panels and renders subscriptions, D1 holds users, servers and route graphs, and KV keeps snapshots. Each server runs a small agent that the Worker reaches through its own tunnel, so no server depends on another one being up. When one server's address became unreachable from home, I added a second way in through a CDN and a switch in the panel. The route names stay the same, so nobody re-imports anything.

  • visual route editor
  • per-hop domain groups
  • display-only nodes that show quota left
  • per-server live health
  • access history
  • direct-connection rules
02

Failing safely, automatically

The rule from the start: if the gateway breaks, nobody at home should notice anything worse than a slower Google. Several layers enforce it.

≈ 0.2–1 sfor the router to send the house direct when the gateway dies (the first version took 6 s)
15 minbetween automatic end-to-end checks of every server, with an email when one fails or recovers
9usage detectors that pause a subscription automatically when it looks shared or abused
  1. Router
    Watchdog on the main router

    A script on the router checks the gateway continuously and withdraws the policy route the moment it stops answering. It finds the MacBook by its network card's hardware address, so the cable can go into any port in the house.

  2. Gateway
    One engine, kept alive by the OS

    The MacBook runs a single routing engine as a system service that restarts itself. Two heartbeats, one from the MacBook and one from the router, report to the cloud, so the panel still knows what is happening when the MacBook is off.

  3. Servers
    Self-tests through the real protocol

    Every 15 minutes the Worker asks each server to run a real client handshake against itself. This exists because once a server looked perfectly healthy while every client had silently stopped working.

  4. People
    Automatic screening

    Each subscription can opt into nine checks: hourly and daily volume, sustained speed, upload ratio, always-on behaviour, concurrent sessions, new connections per minute, unique destinations, a blacklist and per-target rate. A tripped check pauses that one subscription and raises an alert in the dashboard.

  5. Panel
    One button, no terminal

    The home panel turns all of this into a status light and one button: pause, resume or re-apply, plus a cable check and a route picker. It polls slowly when idle and quickly after a click, to stay inside the free tier's daily request limit.

03

The retired MacBook

The gateway is a 2019 MacBook Pro that would otherwise sit in a drawer. With the lid closed and a USB 2.5 GbE adapter, it handles the whole house.

It runs the routing engine in TUN mode as a root service, with a small local status page as a fallback when the cloud panel is unreachable. The router's policy route points every device at it. Nothing on the phones or the TV needs configuring.

The first USB adapter dropped almost one in ten packets it sent under load, which looked like random Wi-Fi trouble until we measured it. A different chipset fixed it.

The clock that broke everything. One morning the MacBook's clock jumped back to January 2024. Every HTTPS certificate became "not yet valid", so encrypted DNS failed, so nothing resolved, so the clock could not sync over the network. That loop never heals by itself. The fix was to set the time by hand and sync against a time server by IP address. The recovery steps are now written down.
04

The dashboard

The real control panel, running on invented data. Edit a route in the node editor, change someone's quota, or open a subscription's QR code. Nothing here reaches a real server.

Subscription and routing dashboard

demo data · in Chinese, as I use it · open full screen ↗

Things to try: 节点编辑 (node editor) opens the route canvas. Drag a server in and click a line to choose which domain groups take that hop. 编辑 on a person shows their subscription items with a live preview, including display-only lines that appear only when, say, fewer than 14 days are left.

05

The home panel

What my family sees. Use the box in the corner to unplug the gateway's cable or power it off, and watch the router take the house direct.

Home gateway panel

demo data · open full screen ↗

Both panels read the same data, as they do in real life. A route you edit in the dashboard shows up in the home panel's route picker and traffic diagram.

06

What broke, and what changed

Most of the design came from incidents. Each one left behind a check, a rule or a page of recovery notes.

WhenWhat people sawCauseWhat changed
Jun 2026Every client "connected" but no page loadedThe site the servers imitate changed its TLS behaviourThe 15-minute self-test and failure emails
2026Speed test passes, no site opensIPv6 attempts on servers that only have IPv4Servers forced to IPv4 for outbound traffic
Aug 2026The whole house offline at onceGateway clock jumped to 2024, a TLS and DNS deadlockRecovery steps that need no DNS
Aug 2026AI sites refusing or failing over TLSDual-stack sites reached over IPv6, bypassing the gatewayIPv6 off at the router, with a written rule to fix both sides together
Sep 2026Slow Wi-Fi upstairs onlyA mesh node showed "online" but its radio was not broadcastingCheck what the radio actually broadcasts, not the saved config
Oct 20265 GHz Wi-Fi gone for 90 secondsAutomatic channel choice moved into a radar-check bandDocumented, with the option to pin a channel
Oct 2026One server unreachable from home onlyIts address was blocked on the home networkA second way in through a CDN, switchable per server
07

Built with AI agents

Claude and Codex wrote the code across three of my computers and cloud sessions. That only worked because of a handoff system I built for them.

Agents forget everything between sessions, and several of them touched this project from different machines. They coordinate through one private repository: shared rules, a plan where every unfinished idea is written down, a short log after every meaningful step, and a rule to push every change immediately. One rule came straight from this project: a behaviour gets one implementation. When an agent copied a panel feature without the code it depended on, I had to report the same kind of bug three times.