PC Controller
Controlling a Windows PC from a phone, without opening a port.
- Year
- 2026
- Status
- In production
- Stack
- KotlinJetpack ComposeKtorCompose DesktopWebSocketSQLiteDocker
The problem
I wanted to turn my PC on and off from my phone, from anywhere. The obvious solution — open a port on the router and talk to the PC directly — means permanently exposing a personal machine to the internet. I went looking for an architecture where that never happens.
The architecture
Three components, and one rule: the phone never talks to the PC directly. Everything goes through an intermediary server, and it's the PC that reaches out to the server, never the other way around.
The decisions that matter
- 01
An outbound connection instead of an open port
The Windows agent opens a secure WebSocket to the server itself and keeps it alive. So the PC has nothing listening: reaching it from outside would mean compromising the server first. The same principle protects the server, which reaches out to Cloudflare instead of accepting inbound connections.
- 02
Waking a machine that's off
A PC that's powered down obviously can't hold a connection open. Powering on goes through Wake-on-LAN instead: the server broadcasts a magic packet on the local network. That forces the container to run in host network mode — on a standard Docker network the broadcast never leaves the machine, a detail that cost me a fair amount of time.
- 03
Confirm rather than assume
The server doesn't consider the PC awake because it sent the packet, but because the agent started reporting in again within 90 seconds. What the interface shows is a verified state, not an intention.
- 04
A secret that's never left in the clear
The agent token is encrypted by Windows itself, tied to that machine's user account. Even reading the disk gets you nothing usable from another computer.