Skip to content

Lightweight native Discord client for Windows, Linux and macOS, written in Rust. No Electron, no browser engine.

3.2 KB
Raw Blame

RustCord registry

The small service behind the RustCord badge. It keeps one row per RustCord user:

column what it is
k SHA-256 of rustcord-user:<Discord user ID> (never the ID itself)
joined when that user first showed up (the service's clock, Unix seconds)
seen their last hello (RustCord says hello every 5 minutes while open)
hidden "Show that I use RustCord" turned off

Nothing else is stored: no names, tokens, IP addresses or messages. The rows live in a private database that only this service can open, and the service never hands out a list of them: a client can only ask about users whose IDs it already has (the profiles it is drawing, 50 at a time). registry.mjs is the whole protocol.

Try it locally

node server/dev.mjs

Then start RustCord with RUSTCORD_REGISTRY_URL=http://127.0.0.1:8787. Tests: node --test server/test.mjs.

Put it online (Cloudflare Workers, free plan)

You need a Cloudflare account (free, no card). From this folder:

  1. npx wrangler login (opens the browser to sign in)
  2. Copy wrangler.example.toml to wrangler.toml (that copy stays on your PC: it is in .gitignore). npx wrangler d1 create rustcord-registry, then paste the database_id it prints into it
  3. npx wrangler d1 execute rustcord-registry --remote --file=schema.sql
  4. npx wrangler deploy (prints the address, like https://rustcord-registry.<you>.workers.dev)

Build RustCord with that address in the RUSTCORD_REGISTRY_URL environment variable, or put it on the first line of a file registry-url.local in the repository root (also in .gitignore), which build-installer.cmd reads. A build without either has no registry.

If the account can't register a workers.dev subdomain (step 4 fails), deploy it as a Pages project instead, which gets a pages.dev address: copy pages/wrangler.example.toml to pages/wrangler.toml with the same database_id, then from server/pages: npx wrangler pages project create rustcord-registry --production-branch main --force and npx wrangler pages deploy --branch main --force (the latter again to publish a change).

What it does not do

  • It can't prove who is who. A hello is not tied to a Discord login (that would mean sending Discord tokens to this service, which RustCord never does). Someone who writes their own client could say hello for another person's ID and give them a badge, or hide a badge until that person's RustCord says hello again. A join date can't be changed once it exists.
  • It can be asked about anyone. Whoever has a list of Discord user IDs can ask which of them use RustCord and when they were last seen. That is what the badge shows anyway, and why "Show that I use RustCord" is off until you turn it on.
  • No rate limiting of its own. Add a Cloudflare rate-limiting rule on /v1/* if it's abused.
  • Free-plan size. D1's free plan allows 100,000 row writes a day; a user open all day writes 288, so roughly 350 all-day users before it needs the paid plan or a longer hello interval (HELLO_EVERY in registry.rs).