# Architecture

## Architecture: CLI · Starter · Box · Page

```
 you (your user)                        │  box user “onionpod” (no login)              │  network
────────────────────────────────────────┼──────────────────────────────────────────────┼──────────
 🪟 Starter  (double-click)             │                                              │
 ⌨️ CLI      (onionpod …)               │  🧅 Box (box program, /opt/onionpod)         │
        │                               │     start · stop · status · test …           │
        └── sudo, ONLY these calls ─────┼──►  └─ pod: workspace · tor · fw · probe ────┼──► Tor only
            (no password prompt)        │        Tor Browser · Session · ~/Transit     │
        setup.sh / update / config ─────┼──► root (sudo once): user, /opt, /etc        │
 🌐 Page  (website + docs, separate, knows nothing about your computer)                │
```

- **Starter** and **CLI** run as **you** — they may operate the box only through a narrow sudo rule
  (exactly the box program's actions, as user `onionpod`).
- The **Box** runs as its **own user** without login, rootless, with rolled user IDs — it sees neither your
  home nor your network. The only way out: Tor.
- root is only needed for setup, updates and security-relevant settings (`/etc/onionpod`).

## The box in detail

```
 your computer (Ubuntu)
 ┌───────────────────────────────────────────────────────────────────────────────┐
 │  TigerVNC viewer ◄── pixels · 127.0.0.1 · one-time password ───┐   🧅 top bar │
 │                                                                │              │
 │  ┌──────────── Pod "onionpod" · rootless · user IDs rolled ─────────────────┐ │
 │  │  workspace ──TCP/DNS──► fw (nftables) ──► tor ──Tor──► Internet          │ │
 │  │  Tor Browser             only Tor may exit     SOCKS · TransPort ·       │ │
 │  │  openbox · menu          rest → Tor or DROP    DNSPort · .onion          │ │
 │  │  probe: leak-test container — deliberately tries to get past Tor         │ │
 │  └──────────────────────────────────────────────────────────────────────────┘ │
 │  ✕ unreachable from the box: router · home network · host · IPv6 · UDP        │
 └───────────────────────────────────────────────────────────────────────────────┘
```

## The containers

| Container | Job |
|---|---|
| **fw** | sets up the firewall (nftables) in the pod's shared network: only the Tor process may reach the network; everything else is redirected to Tor or dropped — and counted |
| **tor** | Tor with SOCKS, TransPort (transparent redirection), DNSPort and `.onion` automap; the ControlPort is blocked for apps |
| **workspace** | Tor Browser (without its own Tor), openbox, bar, start menu, Xvnc |
| **probe** | short-lived, during the leak test: deliberately tries to get past Tor |

## Rootless and rolled

Everything runs under the dedicated user `onionpod` (no login, home with 700). Every start picks a different one of
16 user ID ranges — the box's processes never run under your ID or a fixed one.

## No bridge to the computer

- no X11 socket, no home folder, no Docker/Podman socket in the box
- the screen comes via **TigerVNC**: Xvnc in the box, only on `127.0.0.1:5909`, one viewer, the password burns
  after a single use
- the firewall accepts only this one port from outside

## Where things live

| Location | Content | Owner |
|---|---|---|
| your source | `setup.sh` and components (for updates) | you |
| `/opt/onionpod` | programs, launcher, top bar icon, texts | root |
| `/var/lib/onionpod` | images, Tor state, browser profile (bookmarks) | `onionpod` |
| `/etc/onionpod/config` | version, user, language | root |
| `/etc/onionpod/lock` | lock password (hash) | root |
| `/etc/sudoers.d/onionpod` | you may only run `start/stop/status/build/test` as `onionpod` | root |
| `~/.config/onionpod/starter` | desktop icon yes/no | you |
| `~/.local/state/onionpod/` | setup.sh logs | you |

Why root for programs and rules? Because otherwise any program running under your user could silently change a
firewall entry — a leak past Tor.

## Versions

One version for everything (`VERSION`): setup.sh, launcher and box image (label). The launcher refuses to run if the
image and the programs do not match, and points to `onionpod update`.
