diff --git a/CLAUDE.md b/CLAUDE.md index 0fce7d1..4f40a05 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -45,7 +45,7 @@ Never modify: `data/` contents on the server (`/root/Dezio/data`, live user data - Build and test on this PC: `source ~/.cargo/env; cargo build --release` and `cargo test` (about 227 unit tests). Tests that need the internet are `#[ignore]`d (`cargo test live_ -- --ignored`). - Without `DEZIO_LIVE=1` the binary only lists its commands and exits. **Never run it with the real token on this PC**: the live bot would answer twice. - Local website for testing: `cargo build && DISCORD_BOT_TOKEN=dev-placeholder target/debug/dezio --web-dev` โ†’ http://127.0.0.1:8099 (also the `dezio-web-dev` entry in `.claude/launch.json`). -- Server: the Chromebook, `ssh root@192.168.1.71` (Arch Linux, x86_64). Bot in `/root/Dezio` (binary `dezio`, `assets/`, `web/`, `data/`, `.env`). `dezio-bot.service` runs `/root/Dezio/dezio --headless`, Restart=always; website on 127.0.0.1:8080, public at https://astar76sites.parore-gila.ts.net. Logs: `journalctl -u dezio-bot`. +- Server: the Chromebook, `ssh root@192.168.1.71` (Arch Linux, x86_64). Bot in `/root/Dezio` (binary `dezio`, `assets/`, `web/`, `data/`, `.env`). `dezio-bot.service` runs `/root/Dezio/dezio --headless`, Restart=always; website on 127.0.0.1:8080, public at https://astar76.com. Logs: `journalctl -u dezio-bot`. - The server's line is slow: measured about 425 KB/s down and **114 KB/s (โ‰ˆ 0.9 Mbit/s) up**, on `wlan0`. `dezio-shape.service` (deploy/shape-upload.sh, installed as `/usr/local/bin/dezio-shape`) caps internet-bound upload at 800 kbit with fq_codel so voice packets go first. Voice and every upload share that. - Discord HTTP client: one twilight `Client` with a 180 s timeout for every call (`src/main.rs`). `/download` retries uploads 3 times (`UPLOAD_RETRIES`), so a file that can't finish in 180 s costs 9+ minutes (seen 2026-11-12: a 9.2 MB video, 3 timeouts, handler took 792 s). - Discord's attachment limit for bots is 10 MiB unless the server is boosted (tier 2: 50 MiB, tier 3: 100 MiB). `media::upload_limit` reads the server's tier; `FALLBACK_UPLOAD_LIMIT` lives in `download/plan.rs`. @@ -64,7 +64,7 @@ Never modify: `data/` contents on the server (`/root/Dezio/data`, live user data - Upload time, not file size, is what breaks: at ~100 KB/s a 10 MiB file needs ~105 s on an idle line and much longer with voice. Any upload path must think in seconds. - Retrying a whole upload that timed out just repeats the timeout. Retry only on errors that can succeed the second time. - yt-dlp, ffmpeg, gallery-dl and curl are child processes fed user links: never pass user text where it can become an option (`--`), keep the private-network check (`safe_redirects`, music's check) on every fetch. -- Security testing runs against a **local copy only** (`--web-dev` on 127.0.0.1). Never send attack traffic to https://astar76sites.parore-gila.ts.net or Discord. Never connect to Tor or proxies. +- Security testing runs against a **local copy only** (`--web-dev` on 127.0.0.1). Never send attack traffic to https://astar76.com or Discord. Never connect to Tor or proxies. - Discord changes can't be tested on this PC; things only the owner checks in Discord are marked ๐Ÿง‘. - `/help` pages and slash registration change when commands are added or removed: run the help-limits test. diff --git a/Plans/03a Website path/S006a-dezio-path.md b/Plans/03a Website path/S006a-dezio-path.md index c1b1145..0216f75 100644 --- a/Plans/03a Website path/S006a-dezio-path.md +++ b/Plans/03a Website path/S006a-dezio-path.md @@ -4,7 +4,7 @@ > Files touched: src/web/{mod,activity}.rs, src/hosted.rs, src/commands/gameboy.rs, web/**/*.{html,js,css}, docs/topgg.md, deploy/landing/index.html (new) ## Goal -Move all of Dezio's website (site, dashboard, API, OAuth, Game Boy Activity, hosted `/f/` files) from the root of https://archlinux.tail7c4f5e.ts.net to https://archlinux.tail7c4f5e.ts.net/dezio/ (D-013). The root `/` becomes a very simple static landing page with links to `/dezio/` and `/git/`; the owner will improve it later, so keep it minimal. `/git` (Forgejo) stays as is. +Move all of Dezio's website (site, dashboard, API, OAuth, Game Boy Activity, hosted `/f/` files) from the root of https://astar76.com to https://astar76.com/dezio/ (D-013). The root `/` becomes a very simple static landing page with links to `/dezio/` and `/git/`; the owner will improve it later, so keep it minimal. `/git` (Forgejo) stays as is. ## Read - `src/web/mod.rs` lines 1โ€“70 (config, `DASHBOARD_URL`) and 280โ€“320 (router) @@ -17,8 +17,8 @@ Move all of Dezio's website (site, dashboard, API, OAuth, Game Boy Activity, hos - [x] Base path: derive it from the path part of `DASHBOARD_URL` (e.g. `https://โ€ฆts.net/dezio` โ†’ `/dezio`; none โ†’ `/`). Check with `tailscale serve --help` / docs whether `--set-path /dezio` strips the prefix before proxying (it is believed to strip it). Make the router work both ways: nest all routes under the base path and also accept un-prefixed paths, OR rely on stripping โ€” pick one, say which in DECISIONS (D-013 addition). Cookie `Path` must match the base path. - [x] Pages: every absolute link in `web/site`, `web/dashboard`, `web/activity` (`href="/โ€ฆ"`, `src="/โ€ฆ"`, `fetch("/apiโ€ฆ")`, `/login`, `/assets`, `/images`, `/dashboard`, `/activity/api/โ€ฆ`) works under `/dezio/`. Prefer relative paths; where a page needs the base, inject it from the server once (no per-page copy-paste). OAuth `redirect_uri` stays `DASHBOARD_URL + "/callback"`. Redirects the server sends (login, logout, `slash_redirect`) carry the base path. - [x] Hosted links (`hosted::store`) and `/gameboy` links come from `DASHBOARD_URL`, so they follow; check nothing else hard-codes `/f/` or `/activity` at the root. -- [x] Landing page: `deploy/landing/index.html`, one small static page (title, two links: Dezio โ†’ `/dezio/`, Source โ†’ `/git/`), plain inline CSS, no JS. Write the deploy commands into the plan's test file for S011, do not run them: copy to `/srv/landing/` on the server, `tailscale serve --bg --set-path / /srv/landing` (static files), `tailscale serve --bg --set-path /dezio http://127.0.0.1:8080`, set `DASHBOARD_URL=https://archlinux.tail7c4f5e.ts.net/dezio` in `/root/Dezio/.env` (back it up first). Keep Funnel on. -- [x] Docs: `docs/topgg.md` website URL โ†’ `/dezio/`; the module comments in `src/web/mod.rs`, `src/web/activity.rs`, `src/commands/gameboy.rs` that name the portal setup. ๐Ÿง‘ list for the owner in the test file: Discord Developer Portal โ†’ OAuth2 Redirects add `https://archlinux.tail7c4f5e.ts.net/dezio/callback`; Activities โ†’ URL Mappings `/` โ†’ `archlinux.tail7c4f5e.ts.net/dezio/activity`; top.gg website field. +- [x] Landing page: `deploy/landing/index.html`, one small static page (title, two links: Dezio โ†’ `/dezio/`, Source โ†’ `/git/`), plain inline CSS, no JS. Write the deploy commands into the plan's test file for S011, do not run them: copy to `/srv/landing/` on the server, `tailscale serve --bg --set-path / /srv/landing` (static files), `tailscale serve --bg --set-path /dezio http://127.0.0.1:8080`, set `DASHBOARD_URL=https://astar76.com/dezio` in `/root/Dezio/.env` (back it up first). Keep Funnel on. +- [x] Docs: `docs/topgg.md` website URL โ†’ `/dezio/`; the module comments in `src/web/mod.rs`, `src/web/activity.rs`, `src/commands/gameboy.rs` that name the portal setup. ๐Ÿง‘ list for the owner in the test file: Discord Developer Portal โ†’ OAuth2 Redirects add `https://astar76.com/dezio/callback`; Activities โ†’ URL Mappings `/` โ†’ `astar76.com/dezio/activity`; top.gg website field. - [x] Unit test for the base-path parsing (pure function). - [x] Test file `docs/tests/S006a-dezio-path.md`: local checks with `DASHBOARD_URL=http://127.0.0.1:8099/dezio --web-dev` (every page, asset, API call, login redirect, `/f/` link, activity page under the prefix; root of the local server does not serve Dezio pages), the deploy commands above, and the ๐Ÿง‘ portal list. - [x] PROGRESS entry, INDEX line, commit `S006a: โ€ฆ` diff --git a/Plans/04 Security/S007-website-security.md b/Plans/04 Security/S007-website-security.md index 6c0b11f..610e297 100644 --- a/Plans/04 Security/S007-website-security.md +++ b/Plans/04 Security/S007-website-security.md @@ -25,7 +25,7 @@ Find and fix security faults in the website, dashboard API, OAuth sign-in and Ga - The test file lists every checklist item with a finding or "fine because โ€ฆ". ## Pitfalls -- Never send traffic to https://archlinux.tail7c4f5e.ts.net or Discord. No Tor or proxies. +- Never send traffic to https://astar76.com or Discord. No Tor or proxies. - Never run the bot with the real token; `--web-dev` uses `DISCORD_BOT_TOKEN=dev-placeholder`. - Don't break the existing web tests in `src/web/mod.rs`. diff --git a/Plans/05 Test and release/S011-deploy-and-owner-check.md b/Plans/05 Test and release/S011-deploy-and-owner-check.md index 225f7cd..4ceaecd 100644 --- a/Plans/05 Test and release/S011-deploy-and-owner-check.md +++ b/Plans/05 Test and release/S011-deploy-and-owner-check.md @@ -14,7 +14,7 @@ Deploy the finished bot to the Chromebook, check it starts cleanly, and have the ## Steps - [x] Gate: no open HIGH check or HIGH known bug; otherwise stop and report to the orchestrator (open HIGH are only "not run" Discord/voice/browser checks; owner accepted: "Yes, deploy") - [x] Tell the orchestrator before deploying; `cargo build --release`; scp to `dezio.new`; on the server back up `dezio` as `dezio.bak-`, move in, `rsync -a` changed `assets/` and `web/`, `systemctl restart dezio-bot` -- [x] Check `systemctl status dezio-bot` and `journalctl -u dezio-bot -n 50`: logged in, commands registered, no errors; `curl -sI https://archlinux.tail7c4f5e.ts.net` (plain GET, not attack traffic) returns 200 +- [x] Check `systemctl status dezio-bot` and `journalctl -u dezio-bot -n 50`: logged in, commands registered, no errors; `curl -sI https://astar76.com` (plain GET, not attack traffic) returns 200 - [ ] ๐Ÿง‘ Owner tries `/caption` and `/speechbubble` (every option, a GIF and a video) and `/download` of a ~9 MB video; record the answers in the test report - [ ] PROGRESS entry, INDEX line, commit `S011: โ€ฆ` and push to `origin` @@ -45,4 +45,4 @@ MED 10. `/convert` result over 8.5 MB gives a link (S001-8); `/convert` and caption on a normal mp4 work (S008-13). 11. Start `/caption` on a long video, then another at once: "You already have a media job running" (S008-14). 12. fm commands with a linked account (S006); `/convert` timeout and `/play` lookup timeout messages (S002-10,11). -13. Open `https://archlinux.tail7c4f5e.ts.net/dezio/` (S007-10; works only after the S006a tailscale/.env change, still pending). +13. Open `https://astar76.com/dezio/` (S007-10; works only after the S006a tailscale/.env change, still pending). diff --git a/README.md b/README.md index c661ba4..857b935 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@

โž• Add to your server ยท - Website ยท + Website ยท Support server

diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index c76b822..7fbae84 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -14,5 +14,5 @@ - D-010 โ€” 2026-12-01 โ€” The fm commands read ListenBrainz (free, no key) instead of the Last.fm API, which needs Pro for everything but scrobbling from 2026-12-01. Same commands and cards; links are stored separately in `data/listenbrainz.json` (`data/lastfm.json` is kept, untouched); song links still go to the Last.fm website (free, and the Listen button reads them). Lyrics song search uses Deezer (popularity-ranked, no key). The Last.fm version is the git tag `lastfm-api-backup`. โ€” Owner request. โ€” all fm commands. - D-011 โ€” 2026-12-01 โ€” Covers come from a chain (`src/commands/lastfm/covers.rs`): the release ID in the player's own tags (Cover Art Archive) โ†’ ListenBrainz's match โ†’ the release group โ†’ Deezer โ†’ iTunes; Deezer/iTunes results count only when artist and title match. Artist photos: Deezer โ†’ MusicBrainz/Wikimedia. Play counts match by MusicBrainz ID before names. โ€” MusicBrainz art alone left many covers blank; owner asked for the most reliable sources with fallbacks. โ€” fm commands. - D-012 โ€” 2026-12-01 โ€” All fm logic must get its data from ListenBrainz and MusicBrainz (plus the D-011 cover/photo fallbacks); leftover Last.fm API logic and Last.fm-only fields are replaced or removed. Song links to the Last.fm website stay. โ€” Owner request after the Last.fm API change. โ€” S006, S010. -- D-013 โ€” 2026-12-01 โ€” All of Dezio's website (site, dashboard, API, OAuth, Game Boy Activity, hosted `/f/` files) moves to https://archlinux.tail7c4f5e.ts.net/dezio/. The root `/` serves a minimal static landing page (links to `/dezio/` and `/git/`), which the owner will improve in a later session; old root links to Dezio are not redirected. `/git` stays Forgejo. โ€” Owner request. โ€” S006a, S007, S011. +- D-013 โ€” 2026-12-01 โ€” All of Dezio's website (site, dashboard, API, OAuth, Game Boy Activity, hosted `/f/` files) moves to https://astar76.com/dezio/. The root `/` serves a minimal static landing page (links to `/dezio/` and `/git/`), which the owner will improve in a later session; old root links to Dezio are not redirected. `/git` stays Forgejo. โ€” Owner request. โ€” S006a, S007, S011. - D-013 addition โ€” 2026-12-01 โ€” Base path = path part of `DASHBOARD_URL` (`/dezio`, none โ†’ root). The router serves every route both under the base and un-prefixed, so it works whether `tailscale serve --set-path` strips the prefix or not. HTML pages carry `__BASE__` (server replaces it); dashboard JS reads ``; site pages use relative paths; the Activity derives its base from `location.pathname` (so it also works at `/` inside Discord). Cookie `Path` = base. โ€” Avoids guessing tailscale's behaviour. โ€” S006a, S011. diff --git a/docs/tests/S006a-dezio-path.md b/docs/tests/S006a-dezio-path.md index 8885580..aff10da 100644 --- a/docs/tests/S006a-dezio-path.md +++ b/docs/tests/S006a-dezio-path.md @@ -19,13 +19,13 @@ Run: `DASHBOARD_URL=http://127.0.0.1:8099/dezio DISCORD_BOT_TOKEN=dev-placeholde - Landing: `scp deploy/landing/index.html root@192.168.1.71:/srv/landing/index.html` (mkdir `/srv/landing` first). - `tailscale serve --bg --set-path / /srv/landing` - `tailscale serve --bg --set-path /dezio http://127.0.0.1:8080` (keep Funnel on; keep the `/git` mapping). -- In `/root/Dezio/.env`: `DASHBOARD_URL=https://archlinux.tail7c4f5e.ts.net/dezio`, then restart `dezio-bot`. -- Check `https://archlinux.tail7c4f5e.ts.net/`, `/dezio/`, `/git/`. The router accepts the prefix stripped or not. +- In `/root/Dezio/.env`: `DASHBOARD_URL=https://astar76.com/dezio`, then restart `dezio-bot`. +- Check `https://astar76.com/`, `/dezio/`, `/git/`. The router accepts the prefix stripped or not. ## Owner checklist ๐Ÿง‘ -- Developer Portal โ†’ OAuth2 โ†’ Redirects: add `https://archlinux.tail7c4f5e.ts.net/dezio/callback`. -- Activities โ†’ URL Mappings: `/` โ†’ `archlinux.tail7c4f5e.ts.net/dezio/activity`. -- top.gg website field: `https://archlinux.tail7c4f5e.ts.net/dezio/`. +- Developer Portal โ†’ OAuth2 โ†’ Redirects: add `https://astar76.com/dezio/callback`. +- Activities โ†’ URL Mappings: `/` โ†’ `astar76.com/dezio/activity`. +- top.gg website field: `https://astar76.com/dezio/`. ## Doubts - Whether tailscale strips `/dezio` (both handled, not verified). diff --git a/docs/tests/S007-website-security.md b/docs/tests/S007-website-security.md index b311bd5..79ebd21 100644 --- a/docs/tests/S007-website-security.md +++ b/docs/tests/S007-website-security.md @@ -38,7 +38,7 @@ copy (`DASHBOARD_URL=http://127.0.0.1:8099/dezio`); a Result of `pass` means it | 5 | HIGH | PATCH `/dezio/api/user` with cookie `dezio_session=devtoken` and: no `x-csrf-token`; `Origin: http://evil.test`; no Origin; `Content-Type: text/plain` | 403, 403, 403, 415 | integration (curl) | pass | | 6 | HIGH | `curl --path-as-is` `/dezio/assets/../../.env`, `/dezio/f/../../.env` | 404 | integration | pass | | 7 | MED | 21 POSTs to `/dezio/activity/api/token` with `{"code":"x"}` in one minute (use a stub: do NOT let these reach Discord, e.g. run without network) | 21st โ†’ 429 "Too many sign-ins" | integration | pass (no network: 20 x 401, 21st and 22nd 429) | -| 8 | MED | `DEZIO_ACTIVITY_DEV=1`, POST `/dezio/activity/api/dev-session` plain; with `X-Forwarded-For: 1.2.3.4`; with `Host: archlinux.tail7c4f5e.ts.net` | session; 404; 404 | integration | pass | +| 8 | MED | `DEZIO_ACTIVITY_DEV=1`, POST `/dezio/activity/api/dev-session` plain; with `X-Forwarded-For: 1.2.3.4`; with `Host: astar76.com` | session; 404; 404 | integration | pass | | 9 | MED | GET `/dezio` and `/dezio?a=//evil.test` | 308 to `/dezio/` and `/dezio/?a=//evil.test` (relative, same host) | integration | pass | | 10 | MED | Open the site at `https://โ€ฆ/dezio` on the live server after deploy | lands on `/dezio/`, CSS and images load | by hand ๐Ÿง‘ | not run: live site, owner | | 11 | MED | Dashboard with `?error=busy` | shows "Too many sign-ins right nowโ€ฆ" | screen | pass (text present in app.js; page not looked at) | diff --git a/docs/topgg.md b/docs/topgg.md index 8958f45..805eb39 100644 --- a/docs/topgg.md +++ b/docs/topgg.md @@ -8,8 +8,8 @@ Copy each block into the matching field on the bot's Top.gg edit page. |---|---| | Invite URL | https://discord.com/oauth2/authorize?client_id=1387839600017412106&scope=bot%20applications.commands&permissions=8 | | Support server | https://discord.gg/UnSga5DmR7 | -| Website | https://archlinux.tail7c4f5e.ts.net/dezio/ | -| GitHub / source | https://archlinux.tail7c4f5e.ts.net/git/astar76/Dezio | +| Website | https://astar76.com/dezio/ | +| GitHub / source | https://astar76.com/git/astar76/Dezio | | Prefix | `D!` (every command is also a slash command) | | Library | Rust (twilight + songbird) | @@ -55,9 +55,9 @@ Chess, Connect 4, tic-tac-toe, Wordle, hangman, minesweeper, 2048, Akinator, Coo AI chat with a personality you can change per server, anime GIF actions, confessions, a phone-call system between servers, quotes you can style, emoji tools, weather, translation, wikipedia / web / image search, a calculator and a **Game Boy you can play inside Discord** (Activity). ## Links -- **Website & dashboard:** https://archlinux.tail7c4f5e.ts.net/dezio/ +- **Website & dashboard:** https://astar76.com/dezio/ - **Support server:** https://discord.gg/UnSga5DmR7 -- **Source code:** https://archlinux.tail7c4f5e.ts.net/git/astar76/Dezio +- **Source code:** https://astar76.com/git/astar76/Dezio - Privacy policy and terms are on the website. Written in **Rust** for speed. Add it, type `/help`, and you're done. diff --git a/src/web/activity.rs b/src/web/activity.rs index 39c59f5..220ba74 100644 --- a/src/web/activity.rs +++ b/src/web/activity.rs @@ -16,7 +16,7 @@ //! GET /activity/api/art/ the game's cover (public): an image next to the ROM wins, else SteamGridDB //! (STEAMGRIDDB_API_KEY), cached in data/gameboy/art //! -//! Developer Portal setup (once): Activities โ†’ Settings โ†’ enable; Activities โ†’ URL Mappings โ†’ `/` โ†’ `/activity` (e.g. archlinux.tail7c4f5e.ts.net/dezio/activity) +//! Developer Portal setup (once): Activities โ†’ Settings โ†’ enable; Activities โ†’ URL Mappings โ†’ `/` โ†’ `/activity` (e.g. astar76.com/dezio/activity) //! (no https://); OAuth2 โ†’ Redirects needs at least one entry (the dashboard's /callback is there already). //! DEZIO_ACTIVITY_DEV=1 adds POST /activity/api/dev-session, a test sign-in for requests from 127.0.0.1. //! Everything else under /api needs the session from /api/token (`Authorization: Bearer โ€ฆ`). diff --git a/src/web/mod.rs b/src/web/mod.rs index 7da073f..3f116e3 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -1,6 +1,6 @@ //! The web dashboard: Dezio's website plus per-user and per-server settings, served by the bot itself. //! -//! Everything below lives under the path of DASHBOARD_URL (https://archlinux.tail7c4f5e.ts.net/dezio โ†’ /dezio; D-013). +//! Everything below lives under the path of DASHBOARD_URL (https://astar76.com/dezio โ†’ /dezio; D-013). //! Un-prefixed paths work too. HTML pages get that path in place of `__BASE__`. //! / the website (web/site/: index, terms, privacy, assets/, images/) //! /dashboard the settings app (web/dashboard/), which talks to /api/โ€ฆ @@ -431,8 +431,8 @@ mod tests { #[test] fn base_path_from_dashboard_url() { - assert_eq!(base_path("https://archlinux.tail7c4f5e.ts.net/dezio"), "/dezio"); - assert_eq!(base_path("https://archlinux.tail7c4f5e.ts.net/dezio/"), "/dezio"); + assert_eq!(base_path("https://astar76.com/dezio"), "/dezio"); + assert_eq!(base_path("https://astar76.com/dezio/"), "/dezio"); assert_eq!(base_path("http://127.0.0.1:8099/a/b"), "/a/b"); assert_eq!(base_path("http://192.168.1.71:8080"), ""); assert_eq!(base_path("http://192.168.1.71:8080/"), "");