What you need
- A computer that stays on. A desktop, a laptop or a rented server all work.
- Node.js 20 or newer.
- An address other machines can reach: a public IP or host name with one open TCP port.
- If you will be an exit: a connection you are fine sending other people’s GET requests from.
Install
Two files. The node program imports the library from the file next to it.
curl -o secant.mjs {{ORIGIN}}/lib/secant.js
curl -o node.mjs {{ORIGIN}}/lib/node.mjsStart
node node.mjs --port 9101 --host http://<your public address>:9101--host is the address other nodes put in their layers when your node is the next hop. Leave it out and the node calls itself localhost, which only works on one machine.
--port 9101- Port to listen on. Default 9101.
--host <url>- The address you are reached at. Shown on
GET /id. --data <folder>- Where the identity lives. Default
~/.secant. --no-exit- Refuse to be the last hop. Your node then only relays and never touches the open web.
When the log prints node.ready, other people can route through you.
What the node answers
| Endpoint | What it does |
|---|---|
GET /id | Returns { id, pub, addr, exit, v }. Clients use pub to seal your layer. |
POST /cell | Takes a sealed cell (raw bytes, up to 1 MB). Opens its own layer, then forwards the inner cell to the next address or, if it is the exit, makes the request. |
| Log event | Meaning |
|---|---|
node.identity | Your id and where the key file is. |
node.ready | Listening. |
cell.relay | A layer came off. Bytes in, bytes out, next hop. |
cell.exit | You were the last hop. Host, status and size of the reply. |
cell.refused | An exit request arrived with --no-exit set. |
cell.error | A layer that was not for you, a bad next hop or a request the exit will not make. |
Exit rules
An exit only makes GET and HEAD requests over http or https, waits at most 15 seconds and passes back at most 256 KB. Anything else is refused with cell.error.
--no-exit.Keep it running
- Stop it with Ctrl+C.
- Start it again with the same command. It loads the same identity and keeps its id.
- Use whatever starts programs at boot on your machine, such as a systemd unit or
pm2, so it comes back after a restart.
[Unit]
Description=Secant node
After=network-online.target
[Service]
WorkingDirectory=/opt/secant
ExecStart=/usr/bin/node node.mjs --port 9101 --host http://node.example.org:9101
Restart=always
[Install]
WantedBy=multi-user.targetpm2 start node.mjs --name secant -- --port 9101 --host http://node.example.org:9101
pm2 saveKeys and backups
One file per port: ~/.secant/node-9101.json, written once with mode 600. It holds the private key as JWK and the public key. Lose it and the node gets a new id next time. Copy it somewhere safe if you care about keeping your id.