Docs / Start

Run a node

Your machine joins the circle, opens one layer of every cell it gets and passes the rest on. It never holds both ends of a line.

$SECANTsoonChartBuy $SECANT

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.mjs

Start

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

EndpointWhat it does
GET /idReturns { id, pub, addr, exit, v }. Clients use pub to seal your layer.
POST /cellTakes 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 eventMeaning
node.identityYour id and where the key file is.
node.readyListening.
cell.relayA layer came off. Bytes in, bytes out, next hop.
cell.exitYou were the last hop. Host, status and size of the reply.
cell.refusedAn exit request arrived with --no-exit set.
cell.errorA 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.

WARNINGSites see the exit’s IP address, not the user’s. If that is a problem on your connection, start with --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.target

Keys 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.